Merge from 1.7 branch, revisions 3559-3607. Fixed for GUI clipping, PCX loader, and OSX project.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@3608 dfc29bdd-3216-0410-991c-e03cc46cb475
master
hybrid 2011-03-13 19:15:48 +00:00
parent e902058263
commit 418b861827
6 changed files with 114 additions and 56 deletions

View File

@ -261,6 +261,10 @@ The following names can be queried for the given types:
-----------------------------
Changes in 1.7.3 (??.??.2011)
- Fix clipping in CGUITabControl
- Fix clipping in CGUITable, reported by ceyron
- Skip bone weights and additional information in ms3d file if no joint was defined before.
- Fix mem leak in CImage, found by mloren.

View File

@ -641,8 +641,10 @@ void CGUITabControl::draw()
skin->draw3DTabButton(this, false, frameRect, &AbsoluteClippingRect, VerticalAlignment);
// draw text
core::rect<s32> textClipRect(frameRect); // TODO: exact size depends on borders in draw3DTabButton which we don't get with current interface
textClipRect.clipAgainst(AbsoluteClippingRect);
font->draw(text, frameRect, Tabs[i]->getTextColor(),
true, true, &frameRect);
true, true, &textClipRect);
}
}
@ -659,8 +661,10 @@ void CGUITabControl::draw()
skin->draw3DTabButton(this, true, frameRect, &AbsoluteClippingRect, VerticalAlignment);
// draw text
core::rect<s32> textClipRect(frameRect); // TODO: exact size depends on borders in draw3DTabButton which we don't get with current interface
textClipRect.clipAgainst(AbsoluteClippingRect);
font->draw(activeTab->getText(), frameRect, activeTab->getTextColor(),
true, true, &frameRect);
true, true, &textClipRect);
tr.UpperLeftCorner.X = AbsoluteRect.UpperLeftCorner.X;
tr.LowerRightCorner.X = left - 1;

View File

@ -896,13 +896,10 @@ void CGUITable::draw()
// area of for the items (without header and without scrollbars)
core::rect<s32> clientClip(tableRect);
clientClip.UpperLeftCorner.Y = headerBottom + 1;
core::rect<s32>* clipRect = 0;
if (Clip)
clipRect = &AbsoluteClippingRect;
clientClip.clipAgainst(AbsoluteClippingRect);
// draw background for whole element
skin->draw3DSunkenPane(this, skin->getColor(EGDC_3D_HIGH_LIGHT), true, DrawBack, AbsoluteRect, clipRect);
skin->draw3DSunkenPane(this, skin->getColor(EGDC_3D_HIGH_LIGHT), true, DrawBack, AbsoluteRect, &AbsoluteClippingRect);
// scrolledTableClient is the area where the table items would be if it could be drawn completely
core::rect<s32> scrolledTableClient(tableRect);
@ -973,6 +970,9 @@ void CGUITable::draw()
core::rect<s32> columnSeparator(clientClip);
pos = scrolledTableClient.UpperLeftCorner.X;
core::rect<s32> tableClip(tableRect);
tableClip.clipAgainst(AbsoluteClippingRect);
for (u32 i = 0 ; i < Columns.size() ; ++i )
{
const wchar_t* text = Columns[i].Name.c_str();
@ -983,19 +983,19 @@ void CGUITable::draw()
core::rect<s32> columnrect(pos, tableRect.UpperLeftCorner.Y, pos + colWidth, headerBottom);
// draw column background
skin->draw3DButtonPaneStandard(this, columnrect, &tableRect);
skin->draw3DButtonPaneStandard(this, columnrect, &tableClip);
// draw column seperator
if ( DrawFlags & EGTDF_COLUMNS )
{
columnSeparator.UpperLeftCorner.X = pos;
columnSeparator.LowerRightCorner.X = pos + 1;
driver->draw2DRectangle(skin->getColor(EGDC_3D_SHADOW), columnSeparator, &tableRect);
driver->draw2DRectangle(skin->getColor(EGDC_3D_SHADOW), columnSeparator, &tableClip);
}
// draw header column text
columnrect.UpperLeftCorner.X += CellWidthPadding;
font->draw(text, columnrect, skin->getColor( isEnabled() ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT), false, true, &tableRect);
font->draw(text, columnrect, skin->getColor( isEnabled() ? EGDC_BUTTON_TEXT : EGDC_GRAY_TEXT), false, true, &tableClip);
// draw icon for active column tab
if ( (s32)i == ActiveTab )
@ -1004,13 +1004,13 @@ void CGUITable::draw()
{
columnrect.UpperLeftCorner.X = columnrect.LowerRightCorner.X - CellWidthPadding - ARROW_PAD / 2 + 2;
columnrect.UpperLeftCorner.Y += 7;
skin->drawIcon(this,EGDI_CURSOR_UP,columnrect.UpperLeftCorner,0,0,false,&tableRect);
skin->drawIcon(this,EGDI_CURSOR_UP,columnrect.UpperLeftCorner,0,0,false,&tableClip);
}
else
{
columnrect.UpperLeftCorner.X = columnrect.LowerRightCorner.X - CellWidthPadding - ARROW_PAD / 2 + 2;
columnrect.UpperLeftCorner.Y += 7;
skin->drawIcon(this,EGDI_CURSOR_DOWN,columnrect.UpperLeftCorner,0,0,false,&tableRect);
skin->drawIcon(this,EGDI_CURSOR_DOWN,columnrect.UpperLeftCorner,0,0,false,&tableClip);
}
}
@ -1019,7 +1019,7 @@ void CGUITable::draw()
// fill up header background up to the right side
core::rect<s32> columnrect(pos, tableRect.UpperLeftCorner.Y, tableRect.LowerRightCorner.X , headerBottom);
skin->draw3DButtonPaneStandard(this, columnrect, &tableRect);
skin->draw3DButtonPaneStandard(this, columnrect, &tableClip);
IGUIElement::draw();
}

View File

@ -90,14 +90,14 @@ IImage* CImageLoaderPCX::loadImage(io::IReadFile* file) const
u8 *tempPalette = new u8[768];
paletteData = new s32[256];
memset(paletteData, 0xFF, 256*sizeof(s32));
file->read( tempPalette, 768 );
for( s32 i=0; i<256; i++ )
{
paletteData[i] = (tempPalette[i*3+0] << 16) |
(tempPalette[i*3+1] << 8) |
(tempPalette[i*3+2] );
paletteData[i] = (0xff000000 |
(tempPalette[i*3+0] << 16) |
(tempPalette[i*3+1] << 8) |
(tempPalette[i*3+2]));
}
delete [] tempPalette;
@ -107,12 +107,12 @@ IImage* CImageLoaderPCX::loadImage(io::IReadFile* file) const
else if( header.BitsPerPixel == 4 )
{
paletteData = new s32[16];
memset(paletteData, 0, 16*sizeof(s32));
for( s32 i=0; i<256; i++ )
for( s32 i=0; i<16; i++ )
{
paletteData[i] = (header.Palette[i*3+0] << 16) |
(header.Palette[i*3+1] << 8) |
(header.Palette[i*3+2]);
paletteData[i] = (0xff000000 |
(header.Palette[i*3+0] << 16) |
(header.Palette[i*3+1] << 8) |
(header.Palette[i*3+2]));
}
}

View File

@ -378,22 +378,18 @@ CIrrDeviceMacOSX::CIrrDeviceMacOSX(const SIrrlichtCreationParameters& param)
CursorControl = new CCursorControl(CreationParams.WindowSize, this);
createDriver();
if (IsSoftwareRenderer && CreationParams.DriverType != video::EDT_NULL)
{
// create context for rendering raw bitmap
}
createGUIAndScene();
}
CIrrDeviceMacOSX::~CIrrDeviceMacOSX()
{
[SoftwareDriverTarget release];
SetSystemUIMode(kUIModeNormal, 0);
closeDevice();
#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
for(u32 joystick = 0; joystick < ActiveJoysticks.size(); ++joystick)
for (u32 joystick = 0; joystick < ActiveJoysticks.size(); ++joystick)
{
if(ActiveJoysticks[joystick].interface)
if (ActiveJoysticks[joystick].interface)
closeJoystickDevice(&ActiveJoysticks[joystick]);
}
#endif
@ -450,7 +446,8 @@ bool CIrrDeviceMacOSX::createWindow()
CFDictionaryRef displaymode, olddisplaymode;
GLint numPixelFormats, newSwapInterval;
int alphaSize = CreationParams.WithAlphaChannel?4:0, depthSize = CreationParams.ZBufferBits;
int alphaSize = CreationParams.WithAlphaChannel?4:0;
int depthSize = CreationParams.ZBufferBits;
if (CreationParams.WithAlphaChannel && (CreationParams.Bits == 32))
alphaSize = 8;
@ -583,15 +580,12 @@ bool CIrrDeviceMacOSX::createWindow()
error = CGDisplaySwitchToMode(display,displaymode);
if (error == CGDisplayNoErr)
{
pixelFormat = NULL;
numPixelFormats = 0;
int index = 0;
CGLPixelFormatAttribute fullattribs[] =
{
kCGLPFAFullScreen,
kCGLPFADisplayMask, (CGLPixelFormatAttribute)CGDisplayIDToOpenGLDisplayMask(display),
kCGLPFADoubleBuffer,
kCGLPFANoRecovery,
kCGLPFAAccelerated,
kCGLPFADepthSize, (CGLPixelFormatAttribute)depthSize,
kCGLPFAColorSize, (CGLPixelFormatAttribute)CreationParams.Bits,
@ -602,6 +596,8 @@ bool CIrrDeviceMacOSX::createWindow()
(CGLPixelFormatAttribute)NULL
};
pixelFormat = NULL;
numPixelFormats = 0;
CGLChoosePixelFormat(fullattribs,&pixelFormat,&numPixelFormats);
if (pixelFormat != NULL)
@ -620,6 +616,8 @@ bool CIrrDeviceMacOSX::createWindow()
result = true;
}
}
if (!result)
CGReleaseAllDisplays();
}
}
}
@ -632,6 +630,11 @@ bool CIrrDeviceMacOSX::createWindow()
CGLSetCurrentContext(CGLContext);
newSwapInterval = (CreationParams.Vsync) ? 1 : 0;
CGLSetParameter(CGLContext,kCGLCPSwapInterval,&newSwapInterval);
if (IsSoftwareRenderer && CreationParams.DriverType != video::EDT_NULL)
{
long order = -1; // below window
CGLSetParameter(CGLContext, kCGLCPSurfaceOrder, &order);
}
}
return (result);
@ -658,6 +661,7 @@ void CIrrDeviceMacOSX::setResize(int width, int height)
[(NSOpenGLContext *)OGLContext update];
}
void CIrrDeviceMacOSX::createDriver()
{
switch (CreationParams.DriverType)
@ -720,7 +724,7 @@ bool CIrrDeviceMacOSX::run()
os::Timer::tick();
storeMouseLocation();
event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:nil inMode:NSDefaultRunLoopMode dequeue:YES];
event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES];
if (event != nil)
{
bzero(&ievent,sizeof(ievent));
@ -839,7 +843,6 @@ bool CIrrDeviceMacOSX::run()
break;
}
}
[event release];
pollJoysticks();
@ -850,7 +853,6 @@ bool CIrrDeviceMacOSX::run()
//! Pause the current process for the minimum time allowed only to allow other processes to execute
void CIrrDeviceMacOSX::yield()
{
// TODO: Does this work or maybe is there a better way?
struct timespec ts = {0,0};
nanosleep(&ts, NULL);
}
@ -859,8 +861,6 @@ void CIrrDeviceMacOSX::yield()
//! Pause execution and let other processes to run for a specified amount of time.
void CIrrDeviceMacOSX::sleep(u32 timeMs, bool pauseTimer=false)
{
// TODO: Does this work or maybe is there a better way?
bool wasStopped = Timer ? Timer->isStopped() : true;
struct timespec ts;
@ -1055,13 +1055,10 @@ void CIrrDeviceMacOSX::setMouseLocation(int x,int y)
void CIrrDeviceMacOSX::setCursorVisible(bool visible)
{
CGDirectDisplayID display;
display = CGMainDisplayID();
if (visible)
CGDisplayShowCursor(display);
CGDisplayShowCursor(CGMainDisplayID());
else
CGDisplayHideCursor(display);
CGDisplayHideCursor(CGMainDisplayID());
}
@ -1118,28 +1115,34 @@ void CIrrDeviceMacOSX::setResizable(bool resize)
#endif
}
bool CIrrDeviceMacOSX::isResizable() const
{
return IsResizable;
}
void CIrrDeviceMacOSX::minimizeWindow()
{
[Window miniaturize:[NSApp self]];
if (Window != NULL)
[Window miniaturize:[NSApp self]];
}
//! Maximizes the window if possible.
void CIrrDeviceMacOSX::maximizeWindow()
{
// todo: implement
}
//! Restore the window to normal size if possible.
void CIrrDeviceMacOSX::restoreWindow()
{
[Window deminiaturize:[NSApp self]];
}
bool CIrrDeviceMacOSX::present(video::IImage* surface, void* windowId, core::rect<s32>* src )
{
// todo: implement window ID and src rectangle
@ -1149,12 +1152,14 @@ bool CIrrDeviceMacOSX::present(video::IImage* surface, void* windowId, core::rec
if (IsSoftwareRenderer)
{
const u32 colorSamples=3;
// do we need to change the size?
bool updateSize = !SoftwareDriverTarget ||
s32([SoftwareDriverTarget size].width) != surface->getDimension().Width ||
s32([SoftwareDriverTarget size].height) != surface->getDimension().Height;
const bool updateSize = !SoftwareDriverTarget ||
s32([SoftwareDriverTarget size].width) != surface->getDimension().Width ||
s32([SoftwareDriverTarget size].height) != surface->getDimension().Height;
NSRect areaRect = NSMakeRect(0.0, 0.0, surface->getDimension().Width, surface->getDimension().Height);
const u32 destPitch = (colorSamples * areaRect.size.width);
// create / update the target
if (updateSize)
@ -1166,29 +1171,35 @@ bool CIrrDeviceMacOSX::present(video::IImage* surface, void* windowId, core::rec
pixelsWide: areaRect.size.width
pixelsHigh: areaRect.size.height
bitsPerSample: 8
samplesPerPixel: 3
samplesPerPixel: colorSamples
hasAlpha: NO
isPlanar: NO
colorSpaceName: NSCalibratedRGBColorSpace
bytesPerRow: (3 * areaRect.size.width)
bitsPerPixel: 24];
bytesPerRow: destPitch
bitsPerPixel: 8*colorSamples];
}
const u32 destwidth = areaRect.size.width;
const u32 minWidth = core::min_(surface->getDimension().Width, destwidth);
const u32 destPitch = (3 * areaRect.size.width);
if (SoftwareDriverTarget==nil)
return false;
// get pointer to image data
unsigned char* imgData = (unsigned char*)surface->lock();
u8* srcdata = reinterpret_cast<u8*>(imgData);
u8* destData = reinterpret_cast<u8*>([SoftwareDriverTarget bitmapData]);
const u32 destheight = areaRect.size.height;
const u32 srcheight = core::min_(surface->getDimension().Height, destheight);
const u32 srcheight = core::min_(surface->getDimension().Height, (u32)areaRect.size.height);
const u32 srcPitch = surface->getPitch();
const u32 minWidth = core::min_(surface->getDimension().Width, (u32)areaRect.size.width);
for (u32 y=0; y!=srcheight; ++y)
{
#if 0
if (surface->getColorFormat() == video::ECF_A8R8G8B8)
video::CColorConverter::convert_A8R8G8B8toB8G8R8(srcdata, minWidth, destData);
else
video::CColorConverter::convert_A1R5G5B5toB8G8R8(srcdata, minWidth, destData);
#else
video::CColorConverter::convert_viaFormat(srcdata, surface->getColorFormat(), minWidth, destData, video::ECF_R8G8B8);
#endif
srcdata += srcPitch;
destData += destPitch;
}
@ -1203,6 +1214,7 @@ bool CIrrDeviceMacOSX::present(video::IImage* surface, void* windowId, core::rec
return false;
}
#if defined (_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
static void joystickRemovalCallback(void * target,
IOReturn result, void * refcon, void * sender)

View File

@ -1062,6 +1062,13 @@
0E2E3D3C1103E3F4002DE8D7 /* ManagedLights.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = ManagedLights.app; sourceTree = BUILT_PRODUCTS_DIR; };
0E2E3D681103E6C6002DE8D7 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
0E2E3D791103E6E4002DE8D7 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
0E2E3E1B1103F773002DE8D7 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
0E2E3E1D1103F773002DE8D7 /* q3factory.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = q3factory.cpp; sourceTree = "<group>"; };
0E2E3E1E1103F773002DE8D7 /* q3factory.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = q3factory.h; sourceTree = "<group>"; };
0E2E3E261103F773002DE8D7 /* sound.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = sound.cpp; sourceTree = "<group>"; };
0E2E3E271103F773002DE8D7 /* sound.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = sound.h; sourceTree = "<group>"; };
0E2E3E291103F773002DE8D7 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
0E2E3E321103F773002DE8D7 /* main.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = main.cpp; sourceTree = "<group>"; };
3430E4D41022C391006271FD /* CTarReader.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = CTarReader.h; sourceTree = "<group>"; };
3430E4D51022C391006271FD /* CTarReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CTarReader.cpp; sourceTree = "<group>"; };
344FD4A41039E98C0045FD3F /* CMountPointReader.cpp */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.cpp; path = CMountPointReader.cpp; sourceTree = "<group>"; };
@ -2679,6 +2686,34 @@
path = 20.ManagedLights;
sourceTree = "<group>";
};
0E2E3E1A1103F773002DE8D7 /* 21.Quake3Explorer */ = {
isa = PBXGroup;
children = (
0E2E3E1B1103F773002DE8D7 /* main.cpp */,
0E2E3E1D1103F773002DE8D7 /* q3factory.cpp */,
0E2E3E1E1103F773002DE8D7 /* q3factory.h */,
0E2E3E261103F773002DE8D7 /* sound.cpp */,
0E2E3E271103F773002DE8D7 /* sound.h */,
);
path = 21.Quake3Explorer;
sourceTree = "<group>";
};
0E2E3E281103F773002DE8D7 /* 22.MaterialViewer */ = {
isa = PBXGroup;
children = (
0E2E3E291103F773002DE8D7 /* main.cpp */,
);
path = 22.MaterialViewer;
sourceTree = "<group>";
};
0E2E3E311103F773002DE8D7 /* 23.SMeshHandling */ = {
isa = PBXGroup;
children = (
0E2E3E321103F773002DE8D7 /* main.cpp */,
);
path = 23.SMeshHandling;
sourceTree = "<group>";
};
34EF91900F65F9AD000B5651 /* loader */ = {
isa = PBXGroup;
children = (
@ -2870,6 +2905,9 @@
0E2E3D671103E6C6002DE8D7 /* 18.SplitScreen */,
0946CC980EC99B8B00D945A5 /* 19.MouseAndJoystick */,
0E2E3D781103E6E4002DE8D7 /* 20.ManagedLights */,
0E2E3E1A1103F773002DE8D7 /* 21.Quake3Explorer */,
0E2E3E281103F773002DE8D7 /* 22.MaterialViewer */,
0E2E3E311103F773002DE8D7 /* 23.SMeshHandling */,
4C0054C40A48470500C844C2 /* Demo */,
);
name = examples;