Commit ca65ea3b authored by hybrid's avatar hybrid

Fix indentation

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4134 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 975e5673
...@@ -66,122 +66,122 @@ ...@@ -66,122 +66,122 @@
* keycode. * keycode.
*/ */
enum { enum {
kVK_ANSI_A = 0x00, kVK_ANSI_A = 0x00,
kVK_ANSI_S = 0x01, kVK_ANSI_S = 0x01,
kVK_ANSI_D = 0x02, kVK_ANSI_D = 0x02,
kVK_ANSI_F = 0x03, kVK_ANSI_F = 0x03,
kVK_ANSI_H = 0x04, kVK_ANSI_H = 0x04,
kVK_ANSI_G = 0x05, kVK_ANSI_G = 0x05,
kVK_ANSI_Z = 0x06, kVK_ANSI_Z = 0x06,
kVK_ANSI_X = 0x07, kVK_ANSI_X = 0x07,
kVK_ANSI_C = 0x08, kVK_ANSI_C = 0x08,
kVK_ANSI_V = 0x09, kVK_ANSI_V = 0x09,
kVK_ANSI_B = 0x0B, kVK_ANSI_B = 0x0B,
kVK_ANSI_Q = 0x0C, kVK_ANSI_Q = 0x0C,
kVK_ANSI_W = 0x0D, kVK_ANSI_W = 0x0D,
kVK_ANSI_E = 0x0E, kVK_ANSI_E = 0x0E,
kVK_ANSI_R = 0x0F, kVK_ANSI_R = 0x0F,
kVK_ANSI_Y = 0x10, kVK_ANSI_Y = 0x10,
kVK_ANSI_T = 0x11, kVK_ANSI_T = 0x11,
kVK_ANSI_1 = 0x12, kVK_ANSI_1 = 0x12,
kVK_ANSI_2 = 0x13, kVK_ANSI_2 = 0x13,
kVK_ANSI_3 = 0x14, kVK_ANSI_3 = 0x14,
kVK_ANSI_4 = 0x15, kVK_ANSI_4 = 0x15,
kVK_ANSI_6 = 0x16, kVK_ANSI_6 = 0x16,
kVK_ANSI_5 = 0x17, kVK_ANSI_5 = 0x17,
kVK_ANSI_Equal = 0x18, kVK_ANSI_Equal = 0x18,
kVK_ANSI_9 = 0x19, kVK_ANSI_9 = 0x19,
kVK_ANSI_7 = 0x1A, kVK_ANSI_7 = 0x1A,
kVK_ANSI_Minus = 0x1B, kVK_ANSI_Minus = 0x1B,
kVK_ANSI_8 = 0x1C, kVK_ANSI_8 = 0x1C,
kVK_ANSI_0 = 0x1D, kVK_ANSI_0 = 0x1D,
kVK_ANSI_RightBracket = 0x1E, kVK_ANSI_RightBracket = 0x1E,
kVK_ANSI_O = 0x1F, kVK_ANSI_O = 0x1F,
kVK_ANSI_U = 0x20, kVK_ANSI_U = 0x20,
kVK_ANSI_LeftBracket = 0x21, kVK_ANSI_LeftBracket = 0x21,
kVK_ANSI_I = 0x22, kVK_ANSI_I = 0x22,
kVK_ANSI_P = 0x23, kVK_ANSI_P = 0x23,
kVK_ANSI_L = 0x25, kVK_ANSI_L = 0x25,
kVK_ANSI_J = 0x26, kVK_ANSI_J = 0x26,
kVK_ANSI_Quote = 0x27, kVK_ANSI_Quote = 0x27,
kVK_ANSI_K = 0x28, kVK_ANSI_K = 0x28,
kVK_ANSI_Semicolon = 0x29, kVK_ANSI_Semicolon = 0x29,
kVK_ANSI_Backslash = 0x2A, kVK_ANSI_Backslash = 0x2A,
kVK_ANSI_Comma = 0x2B, kVK_ANSI_Comma = 0x2B,
kVK_ANSI_Slash = 0x2C, kVK_ANSI_Slash = 0x2C,
kVK_ANSI_N = 0x2D, kVK_ANSI_N = 0x2D,
kVK_ANSI_M = 0x2E, kVK_ANSI_M = 0x2E,
kVK_ANSI_Period = 0x2F, kVK_ANSI_Period = 0x2F,
kVK_ANSI_Grave = 0x32, kVK_ANSI_Grave = 0x32,
kVK_ANSI_KeypadDecimal = 0x41, kVK_ANSI_KeypadDecimal = 0x41,
kVK_ANSI_KeypadMultiply = 0x43, kVK_ANSI_KeypadMultiply = 0x43,
kVK_ANSI_KeypadPlus = 0x45, kVK_ANSI_KeypadPlus = 0x45,
kVK_ANSI_KeypadClear = 0x47, kVK_ANSI_KeypadClear = 0x47,
kVK_ANSI_KeypadDivide = 0x4B, kVK_ANSI_KeypadDivide = 0x4B,
kVK_ANSI_KeypadEnter = 0x4C, kVK_ANSI_KeypadEnter = 0x4C,
kVK_ANSI_KeypadMinus = 0x4E, kVK_ANSI_KeypadMinus = 0x4E,
kVK_ANSI_KeypadEquals = 0x51, kVK_ANSI_KeypadEquals = 0x51,
kVK_ANSI_Keypad0 = 0x52, kVK_ANSI_Keypad0 = 0x52,
kVK_ANSI_Keypad1 = 0x53, kVK_ANSI_Keypad1 = 0x53,
kVK_ANSI_Keypad2 = 0x54, kVK_ANSI_Keypad2 = 0x54,
kVK_ANSI_Keypad3 = 0x55, kVK_ANSI_Keypad3 = 0x55,
kVK_ANSI_Keypad4 = 0x56, kVK_ANSI_Keypad4 = 0x56,
kVK_ANSI_Keypad5 = 0x57, kVK_ANSI_Keypad5 = 0x57,
kVK_ANSI_Keypad6 = 0x58, kVK_ANSI_Keypad6 = 0x58,
kVK_ANSI_Keypad7 = 0x59, kVK_ANSI_Keypad7 = 0x59,
kVK_ANSI_Keypad8 = 0x5B, kVK_ANSI_Keypad8 = 0x5B,
kVK_ANSI_Keypad9 = 0x5C kVK_ANSI_Keypad9 = 0x5C
}; };
/* keycodes for keys that are independent of keyboard layout*/ /* keycodes for keys that are independent of keyboard layout*/
enum { enum {
kVK_Return = 0x24, kVK_Return = 0x24,
kVK_Tab = 0x30, kVK_Tab = 0x30,
kVK_Space = 0x31, kVK_Space = 0x31,
kVK_Delete = 0x33, kVK_Delete = 0x33,
kVK_Escape = 0x35, kVK_Escape = 0x35,
kVK_Command = 0x37, kVK_Command = 0x37,
kVK_Shift = 0x38, kVK_Shift = 0x38,
kVK_CapsLock = 0x39, kVK_CapsLock = 0x39,
kVK_Option = 0x3A, kVK_Option = 0x3A,
kVK_Control = 0x3B, kVK_Control = 0x3B,
kVK_RightShift = 0x3C, kVK_RightShift = 0x3C,
kVK_RightOption = 0x3D, kVK_RightOption = 0x3D,
kVK_RightControl = 0x3E, kVK_RightControl = 0x3E,
kVK_Function = 0x3F, kVK_Function = 0x3F,
kVK_F17 = 0x40, kVK_F17 = 0x40,
kVK_VolumeUp = 0x48, kVK_VolumeUp = 0x48,
kVK_VolumeDown = 0x49, kVK_VolumeDown = 0x49,
kVK_Mute = 0x4A, kVK_Mute = 0x4A,
kVK_F18 = 0x4F, kVK_F18 = 0x4F,
kVK_F19 = 0x50, kVK_F19 = 0x50,
kVK_F20 = 0x5A, kVK_F20 = 0x5A,
kVK_F5 = 0x60, kVK_F5 = 0x60,
kVK_F6 = 0x61, kVK_F6 = 0x61,
kVK_F7 = 0x62, kVK_F7 = 0x62,
kVK_F3 = 0x63, kVK_F3 = 0x63,
kVK_F8 = 0x64, kVK_F8 = 0x64,
kVK_F9 = 0x65, kVK_F9 = 0x65,
kVK_F11 = 0x67, kVK_F11 = 0x67,
kVK_F13 = 0x69, kVK_F13 = 0x69,
kVK_F16 = 0x6A, kVK_F16 = 0x6A,
kVK_F14 = 0x6B, kVK_F14 = 0x6B,
kVK_F10 = 0x6D, kVK_F10 = 0x6D,
kVK_F12 = 0x6F, kVK_F12 = 0x6F,
kVK_F15 = 0x71, kVK_F15 = 0x71,
kVK_Help = 0x72, kVK_Help = 0x72,
kVK_Home = 0x73, kVK_Home = 0x73,
kVK_PageUp = 0x74, kVK_PageUp = 0x74,
kVK_ForwardDelete = 0x75, kVK_ForwardDelete = 0x75,
kVK_F4 = 0x76, kVK_F4 = 0x76,
kVK_End = 0x77, kVK_End = 0x77,
kVK_F2 = 0x78, kVK_F2 = 0x78,
kVK_PageDown = 0x79, kVK_PageDown = 0x79,
kVK_F1 = 0x7A, kVK_F1 = 0x7A,
kVK_LeftArrow = 0x7B, kVK_LeftArrow = 0x7B,
kVK_RightArrow = 0x7C, kVK_RightArrow = 0x7C,
kVK_DownArrow = 0x7D, kVK_DownArrow = 0x7D,
kVK_UpArrow = 0x7E kVK_UpArrow = 0x7E
}; };
#endif #endif
...@@ -293,43 +293,43 @@ static void addJoystickComponent (CFTypeRef refElement, JoystickInfo* joyInfo) ...@@ -293,43 +293,43 @@ static void addJoystickComponent (CFTypeRef refElement, JoystickInfo* joyInfo)
switch (usagePage) /* only interested in kHIDPage_GenericDesktop and kHIDPage_Button */ switch (usagePage) /* only interested in kHIDPage_GenericDesktop and kHIDPage_Button */
{ {
case kHIDPage_GenericDesktop: case kHIDPage_GenericDesktop:
{
switch (usage) /* look at usage to determine function */
{ {
switch (usage) /* look at usage to determine function */ case kHIDUsage_GD_X:
case kHIDUsage_GD_Y:
case kHIDUsage_GD_Z:
case kHIDUsage_GD_Rx:
case kHIDUsage_GD_Ry:
case kHIDUsage_GD_Rz:
case kHIDUsage_GD_Slider:
case kHIDUsage_GD_Dial:
case kHIDUsage_GD_Wheel:
{ {
case kHIDUsage_GD_X: joyInfo->axes++;
case kHIDUsage_GD_Y: JoystickComponent newComponent;
case kHIDUsage_GD_Z: addComponentInfo(refElement, &newComponent, joyInfo->numActiveJoysticks);
case kHIDUsage_GD_Rx: joyInfo->axisComp.push_back(newComponent);
case kHIDUsage_GD_Ry:
case kHIDUsage_GD_Rz:
case kHIDUsage_GD_Slider:
case kHIDUsage_GD_Dial:
case kHIDUsage_GD_Wheel:
{
joyInfo->axes++;
JoystickComponent newComponent;
addComponentInfo(refElement, &newComponent, joyInfo->numActiveJoysticks);
joyInfo->axisComp.push_back(newComponent);
}
break;
case kHIDUsage_GD_Hatswitch:
{
joyInfo->hats++;
JoystickComponent newComponent;
addComponentInfo(refElement, &newComponent, joyInfo->numActiveJoysticks);
joyInfo->hatComp.push_back(newComponent);
}
break;
} }
break;
case kHIDUsage_GD_Hatswitch:
{
joyInfo->hats++;
JoystickComponent newComponent;
addComponentInfo(refElement, &newComponent, joyInfo->numActiveJoysticks);
joyInfo->hatComp.push_back(newComponent);
}
break;
} }
}
break; break;
case kHIDPage_Button: case kHIDPage_Button:
{ {
joyInfo->buttons++; joyInfo->buttons++;
JoystickComponent newComponent; JoystickComponent newComponent;
addComponentInfo(refElement, &newComponent, joyInfo->numActiveJoysticks); addComponentInfo(refElement, &newComponent, joyInfo->numActiveJoysticks);
joyInfo->buttonComp.push_back(newComponent); joyInfo->buttonComp.push_back(newComponent);
} }
break; break;
default: default:
break; break;
...@@ -511,12 +511,12 @@ CIrrDeviceMacOSX::CIrrDeviceMacOSX(const SIrrlichtCreationParameters& param) ...@@ -511,12 +511,12 @@ CIrrDeviceMacOSX::CIrrDeviceMacOSX(const SIrrlichtCreationParameters& param)
os::Printer::log(name.version,ELL_INFORMATION); os::Printer::log(name.version,ELL_INFORMATION);
initKeycodes(); initKeycodes();
VideoModeList.setDesktop(CreationParams.Bits, core::dimension2d<u32>([[NSScreen mainScreen] frame].size.width, [[NSScreen mainScreen] frame].size.height)); VideoModeList.setDesktop(CreationParams.Bits, core::dimension2d<u32>([[NSScreen mainScreen] frame].size.width, [[NSScreen mainScreen] frame].size.height));
bool success = true; bool success = true;
if (CreationParams.DriverType != video::EDT_NULL) if (CreationParams.DriverType != video::EDT_NULL)
success = createWindow(); success = createWindow();
// in case of failure, one can check VideoDriver for initialization // in case of failure, one can check VideoDriver for initialization
if (!success) if (!success)
...@@ -524,8 +524,8 @@ CIrrDeviceMacOSX::CIrrDeviceMacOSX(const SIrrlichtCreationParameters& param) ...@@ -524,8 +524,8 @@ CIrrDeviceMacOSX::CIrrDeviceMacOSX(const SIrrlichtCreationParameters& param)
setResizable(false); setResizable(false);
CursorControl = new CCursorControl(CreationParams.WindowSize, this); CursorControl = new CCursorControl(CreationParams.WindowSize, this);
createDriver(); createDriver();
createGUIAndScene(); createGUIAndScene();
} }
...@@ -533,9 +533,9 @@ CIrrDeviceMacOSX::~CIrrDeviceMacOSX() ...@@ -533,9 +533,9 @@ CIrrDeviceMacOSX::~CIrrDeviceMacOSX()
{ {
[SoftwareDriverTarget release]; [SoftwareDriverTarget release];
#ifdef __MAC_10_6 #ifdef __MAC_10_6
[NSApp setPresentationOptions:(NSApplicationPresentationDefault)]; [NSApp setPresentationOptions:(NSApplicationPresentationDefault)];
#else #else
SetSystemUIMode(kUIModeNormal, kUIOptionAutoShowMenuBar); SetSystemUIMode(kUIModeNormal, kUIOptionAutoShowMenuBar);
#endif #endif
closeDevice(); closeDevice();
#if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_) #if defined(_IRR_COMPILE_WITH_JOYSTICK_EVENTS_)
...@@ -563,9 +563,9 @@ void CIrrDeviceMacOSX::closeDevice() ...@@ -563,9 +563,9 @@ void CIrrDeviceMacOSX::closeDevice()
[Window setReleasedWhenClosed:TRUE]; [Window setReleasedWhenClosed:TRUE];
[Window release]; [Window release];
Window = NULL; Window = NULL;
if (IsFullscreen) if (IsFullscreen)
CGReleaseAllDisplays(); CGReleaseAllDisplays();
} }
else else
{ {
...@@ -587,306 +587,304 @@ void CIrrDeviceMacOSX::closeDevice() ...@@ -587,306 +587,304 @@ void CIrrDeviceMacOSX::closeDevice()
} }
} }
IsFullscreen = false; IsFullscreen = false;
IsActive = false; IsActive = false;
CGLContext = NULL; CGLContext = NULL;
} }
bool CIrrDeviceMacOSX::createWindow() bool CIrrDeviceMacOSX::createWindow()
{ {
CGDisplayErr error; CGDisplayErr error;
bool result=false; bool result=false;
CGDirectDisplayID display=CGMainDisplayID(); CGDirectDisplayID display=CGMainDisplayID();
CGLPixelFormatObj pixelFormat; CGLPixelFormatObj pixelFormat;
CGRect displayRect; CGRect displayRect;
#ifdef __MAC_10_6 #ifdef __MAC_10_6
CGDisplayModeRef displaymode, olddisplaymode; CGDisplayModeRef displaymode, olddisplaymode;
#else #else
CFDictionaryRef displaymode, olddisplaymode; CFDictionaryRef displaymode, olddisplaymode;
#endif #endif
GLint numPixelFormats, newSwapInterval;
GLint numPixelFormats, newSwapInterval;
int alphaSize = CreationParams.WithAlphaChannel?4:0;
int alphaSize = CreationParams.WithAlphaChannel?4:0; int depthSize = CreationParams.ZBufferBits;
int depthSize = CreationParams.ZBufferBits; if (CreationParams.WithAlphaChannel && (CreationParams.Bits == 32))
if (CreationParams.WithAlphaChannel && (CreationParams.Bits == 32)) alphaSize = 8;
alphaSize = 8;
ScreenWidth = (int) CGDisplayPixelsWide(display);
ScreenWidth = (int) CGDisplayPixelsWide(display); ScreenHeight = (int) CGDisplayPixelsHigh(display);
ScreenHeight = (int) CGDisplayPixelsHigh(display);
// we need to check where the exceptions may happen and work at them
// we need to check where the exceptions may happen and work at them // for now we will just catch them to be able to avoid an app exit
// for now we will just catch them to be able to avoid an app exit @try
@try {
{ if (!CreationParams.Fullscreen)
if (!CreationParams.Fullscreen) {
{ if(!CreationParams.WindowId) //create another window when WindowId is null
if(!CreationParams.WindowId) //create another window when WindowId is null {
{ NSBackingStoreType type = (CreationParams.DriverType == video::EDT_OPENGL) ? NSBackingStoreBuffered : NSBackingStoreNonretained;
NSBackingStoreType type = (CreationParams.DriverType == video::EDT_OPENGL) ? NSBackingStoreBuffered : NSBackingStoreNonretained;
Window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,CreationParams.WindowSize.Width,CreationParams.WindowSize.Height) styleMask:NSTitledWindowMask+NSClosableWindowMask+NSResizableWindowMask backing:type defer:FALSE];
Window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,CreationParams.WindowSize.Width,CreationParams.WindowSize.Height) styleMask:NSTitledWindowMask+NSClosableWindowMask+NSResizableWindowMask backing:type defer:FALSE]; }
}
if (Window != NULL || CreationParams.WindowId)
if (Window != NULL || CreationParams.WindowId) {
{ if (CreationParams.DriverType == video::EDT_OPENGL)
if (CreationParams.DriverType == video::EDT_OPENGL) {
{ NSOpenGLPixelFormatAttribute windowattribs[] =
NSOpenGLPixelFormatAttribute windowattribs[] = {
{ NSOpenGLPFANoRecovery,
NSOpenGLPFANoRecovery, NSOpenGLPFAAccelerated,
NSOpenGLPFAAccelerated, NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute)depthSize,
NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute)depthSize, NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute)CreationParams.Bits,
NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute)CreationParams.Bits, NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute)alphaSize,
NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute)alphaSize, NSOpenGLPFASampleBuffers, (NSOpenGLPixelFormatAttribute)1,
NSOpenGLPFASampleBuffers, (NSOpenGLPixelFormatAttribute)1, NSOpenGLPFASamples, (NSOpenGLPixelFormatAttribute)CreationParams.AntiAlias,
NSOpenGLPFASamples, (NSOpenGLPixelFormatAttribute)CreationParams.AntiAlias, NSOpenGLPFAStencilSize, (NSOpenGLPixelFormatAttribute)(CreationParams.Stencilbuffer?1:0),
NSOpenGLPFAStencilSize, (NSOpenGLPixelFormatAttribute)(CreationParams.Stencilbuffer?1:0), NSOpenGLPFADoubleBuffer,
NSOpenGLPFADoubleBuffer, (NSOpenGLPixelFormatAttribute)nil
(NSOpenGLPixelFormatAttribute)nil };
};
if (CreationParams.AntiAlias<2)
if (CreationParams.AntiAlias<2) {
{ windowattribs[ 9] = (NSOpenGLPixelFormatAttribute)0;
windowattribs[ 9] = (NSOpenGLPixelFormatAttribute)0; windowattribs[11] = (NSOpenGLPixelFormatAttribute)0;
windowattribs[11] = (NSOpenGLPixelFormatAttribute)0; }
}
NSOpenGLPixelFormat *format;
NSOpenGLPixelFormat *format; for (int i=0; i<3; ++i)
for (int i=0; i<3; ++i) {
{ if (1==i)
if (1==i) {
{ // Second try without stencilbuffer
// Second try without stencilbuffer if (CreationParams.Stencilbuffer)
if (CreationParams.Stencilbuffer) {
{ windowattribs[13]=(NSOpenGLPixelFormatAttribute)0;
windowattribs[13]=(NSOpenGLPixelFormatAttribute)0; }
} else
else continue;
continue; }
} else if (2==i)
else if (2==i) {
{ // Third try without Doublebuffer
// Third try without Doublebuffer os::Printer::log("No doublebuffering available.", ELL_WARNING);
os::Printer::log("No doublebuffering available.", ELL_WARNING); windowattribs[14]=(NSOpenGLPixelFormatAttribute)nil;
windowattribs[14]=(NSOpenGLPixelFormatAttribute)nil; }
}
format = [[NSOpenGLPixelFormat alloc] initWithAttributes:windowattribs];
format = [[NSOpenGLPixelFormat alloc] initWithAttributes:windowattribs]; if (format == NULL)
if (format == NULL) {
{ if (CreationParams.AntiAlias>1)
if (CreationParams.AntiAlias>1) {
{ while (!format && windowattribs[12]>1)
while (!format && windowattribs[12]>1) {
{ windowattribs[12] = (NSOpenGLPixelFormatAttribute)((int)windowattribs[12]-1);
windowattribs[12] = (NSOpenGLPixelFormatAttribute)((int)windowattribs[12]-1); format = [[NSOpenGLPixelFormat alloc] initWithAttributes:windowattribs];
format = [[NSOpenGLPixelFormat alloc] initWithAttributes:windowattribs]; }
}
if (!format)
if (!format) {
{ windowattribs[9] = (NSOpenGLPixelFormatAttribute)0;
windowattribs[9] = (NSOpenGLPixelFormatAttribute)0; windowattribs[11] = (NSOpenGLPixelFormatAttribute)0;
windowattribs[11] = (NSOpenGLPixelFormatAttribute)0; format = [[NSOpenGLPixelFormat alloc] initWithAttributes:windowattribs];
format = [[NSOpenGLPixelFormat alloc] initWithAttributes:windowattribs]; if (!format)
if (!format) {
{ // reset values for next try
// reset values for next try windowattribs[9] = (NSOpenGLPixelFormatAttribute)1;
windowattribs[9] = (NSOpenGLPixelFormatAttribute)1; windowattribs[11] = (NSOpenGLPixelFormatAttribute)CreationParams.AntiAlias;
windowattribs[11] = (NSOpenGLPixelFormatAttribute)CreationParams.AntiAlias; }
} else
else {
{ os::Printer::log("No FSAA available.", ELL_WARNING);
os::Printer::log("No FSAA available.", ELL_WARNING); }
} }
}
} }
} else
} break;
else }
break; CreationParams.AntiAlias = windowattribs[11];
} CreationParams.Stencilbuffer=(windowattribs[13]==1);
CreationParams.AntiAlias = windowattribs[11];
CreationParams.Stencilbuffer=(windowattribs[13]==1); if (format != NULL)
{
if (format != NULL) OGLContext = [[NSOpenGLContext alloc] initWithFormat:format shareContext:NULL];
{ [format release];
OGLContext = [[NSOpenGLContext alloc] initWithFormat:format shareContext:NULL]; }
[format release]; }
}
} if (OGLContext != NULL || CreationParams.DriverType != video::EDT_OPENGL)
{
if (OGLContext != NULL || CreationParams.DriverType != video::EDT_OPENGL) if (!CreationParams.WindowId)
{ {
if (!CreationParams.WindowId) [Window center];
{ [Window setDelegate:[NSApp delegate]];
[Window center];
[Window setDelegate:[NSApp delegate]]; if(CreationParams.DriverType == video::EDT_OPENGL)
[OGLContext setView:[Window contentView]];
if(CreationParams.DriverType == video::EDT_OPENGL)
[OGLContext setView:[Window contentView]]; [Window setAcceptsMouseMovedEvents:TRUE];
[Window setIsVisible:TRUE];
[Window setAcceptsMouseMovedEvents:TRUE]; [Window makeKeyAndOrderFront:nil];
[Window setIsVisible:TRUE]; }
[Window makeKeyAndOrderFront:nil]; else if(CreationParams.DriverType == video::EDT_OPENGL) //use another window for drawing
} [OGLContext setView:(NSView*)CreationParams.WindowId];
else if(CreationParams.DriverType == video::EDT_OPENGL) //use another window for drawing
[OGLContext setView:(NSView*)CreationParams.WindowId]; if (CreationParams.DriverType == video::EDT_OPENGL)
CGLContext = (CGLContextObj) [OGLContext CGLContextObj];
if (CreationParams.DriverType == video::EDT_OPENGL)
CGLContext = (CGLContextObj) [OGLContext CGLContextObj]; DeviceWidth = CreationParams.WindowSize.Width;
DeviceHeight = CreationParams.WindowSize.Height;
DeviceWidth = CreationParams.WindowSize.Width; result = true;
DeviceHeight = CreationParams.WindowSize.Height; }
result = true; }
} }
} else
} {
else IsFullscreen = true;
{
IsFullscreen = true;
#ifdef __MAC_10_6 #ifdef __MAC_10_6
displaymode = CGDisplayCopyDisplayMode(display); displaymode = CGDisplayCopyDisplayMode(display);
CFArrayRef Modes = CGDisplayCopyAllDisplayModes(display, NULL); CFArrayRef Modes = CGDisplayCopyAllDisplayModes(display, NULL);
for(int i = 0; i < CFArrayGetCount(Modes); ++i) for(int i = 0; i < CFArrayGetCount(Modes); ++i)
{ {
CGDisplayModeRef CurrentMode = (CGDisplayModeRef)CFArrayGetValueAtIndex(Modes, i); CGDisplayModeRef CurrentMode = (CGDisplayModeRef)CFArrayGetValueAtIndex(Modes, i);
u8 Depth = 0; u8 Depth = 0;
CFStringRef pixEnc = CGDisplayModeCopyPixelEncoding(CurrentMode); CFStringRef pixEnc = CGDisplayModeCopyPixelEncoding(CurrentMode);
if(CFStringCompare(pixEnc, CFSTR(IO32BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) if(CFStringCompare(pixEnc, CFSTR(IO32BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)
Depth = 32; Depth = 32;
else else
if(CFStringCompare(pixEnc, CFSTR(IO16BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) if(CFStringCompare(pixEnc, CFSTR(IO16BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)
Depth = 16; Depth = 16;
else else
if(CFStringCompare(pixEnc, CFSTR(IO8BitIndexedPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) if(CFStringCompare(pixEnc, CFSTR(IO8BitIndexedPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)
Depth = 8; Depth = 8;
if(Depth == CreationParams.Bits) if(Depth == CreationParams.Bits)
if((CGDisplayModeGetWidth(CurrentMode) == CreationParams.WindowSize.Width) && (CGDisplayModeGetHeight(CurrentMode) == CreationParams.WindowSize.Height)) if((CGDisplayModeGetWidth(CurrentMode) == CreationParams.WindowSize.Width) && (CGDisplayModeGetHeight(CurrentMode) == CreationParams.WindowSize.Height))
{ {
displaymode = CurrentMode; displaymode = CurrentMode;
break; break;
} }
} }
#else #else
displaymode = CGDisplayBestModeForParameters(display,CreationParams.Bits,CreationParams.WindowSize.Width,CreationParams.WindowSize.Height,NULL); displaymode = CGDisplayBestModeForParameters(display,CreationParams.Bits,CreationParams.WindowSize.Width,CreationParams.WindowSize.Height,NULL);
#endif #endif
if (displaymode != NULL) if (displaymode != NULL)
{ {
#ifdef __MAC_10_6 #ifdef __MAC_10_6
olddisplaymode = CGDisplayCopyDisplayMode(display); olddisplaymode = CGDisplayCopyDisplayMode(display);
#else #else
olddisplaymode = CGDisplayCurrentMode(display); olddisplaymode = CGDisplayCurrentMode(display);
#endif #endif
error = CGCaptureAllDisplays(); error = CGCaptureAllDisplays();
if (error == CGDisplayNoErr) if (error == CGDisplayNoErr)
{ {
#ifdef __MAC_10_6 #ifdef __MAC_10_6
error = CGDisplaySetDisplayMode(display, displaymode, NULL); error = CGDisplaySetDisplayMode(display, displaymode, NULL);
#else #else
error = CGDisplaySwitchToMode(display, displaymode); error = CGDisplaySwitchToMode(display, displaymode);
#endif #endif
if (error == CGDisplayNoErr) if (error == CGDisplayNoErr)
{ {
if (CreationParams.DriverType == video::EDT_OPENGL) if (CreationParams.DriverType == video::EDT_OPENGL)
{ {
CGLPixelFormatAttribute fullattribs[] = CGLPixelFormatAttribute fullattribs[] =
{ {
kCGLPFAFullScreen, kCGLPFAFullScreen,
kCGLPFADisplayMask, (CGLPixelFormatAttribute)CGDisplayIDToOpenGLDisplayMask(display), kCGLPFADisplayMask, (CGLPixelFormatAttribute)CGDisplayIDToOpenGLDisplayMask(display),
kCGLPFADoubleBuffer, kCGLPFADoubleBuffer,
kCGLPFANoRecovery, kCGLPFANoRecovery,
kCGLPFAAccelerated, kCGLPFAAccelerated,
kCGLPFADepthSize, (CGLPixelFormatAttribute)depthSize, kCGLPFADepthSize, (CGLPixelFormatAttribute)depthSize,
kCGLPFAColorSize, (CGLPixelFormatAttribute)CreationParams.Bits, kCGLPFAColorSize, (CGLPixelFormatAttribute)CreationParams.Bits,
kCGLPFAAlphaSize, (CGLPixelFormatAttribute)alphaSize, kCGLPFAAlphaSize, (CGLPixelFormatAttribute)alphaSize,
kCGLPFASampleBuffers, (CGLPixelFormatAttribute)(CreationParams.AntiAlias?1:0), kCGLPFASampleBuffers, (CGLPixelFormatAttribute)(CreationParams.AntiAlias?1:0),
kCGLPFASamples, (CGLPixelFormatAttribute)CreationParams.AntiAlias, kCGLPFASamples, (CGLPixelFormatAttribute)CreationParams.AntiAlias,
kCGLPFAStencilSize, (CGLPixelFormatAttribute)(CreationParams.Stencilbuffer?1:0), kCGLPFAStencilSize, (CGLPixelFormatAttribute)(CreationParams.Stencilbuffer?1:0),
(CGLPixelFormatAttribute)NULL (CGLPixelFormatAttribute)NULL
}; };
pixelFormat = NULL; pixelFormat = NULL;
numPixelFormats = 0; numPixelFormats = 0;
CGLChoosePixelFormat(fullattribs,&pixelFormat,&numPixelFormats); CGLChoosePixelFormat(fullattribs,&pixelFormat,&numPixelFormats);
if (pixelFormat != NULL) if (pixelFormat != NULL)
{ {
CGLCreateContext(pixelFormat,NULL,&CGLContext); CGLCreateContext(pixelFormat,NULL,&CGLContext);
CGLDestroyPixelFormat(pixelFormat); CGLDestroyPixelFormat(pixelFormat);
} }
if (CGLContext != NULL) if (CGLContext != NULL)
{ {
#ifdef __MAC_10_6 #ifdef __MAC_10_6
CGLSetFullScreenOnDisplay(CGLContext, CGDisplayIDToOpenGLDisplayMask(display)); CGLSetFullScreenOnDisplay(CGLContext, CGDisplayIDToOpenGLDisplayMask(display));
#else #else
CGLSetFullScreen(CGLContext); CGLSetFullScreen(CGLContext);
#endif #endif
displayRect = CGDisplayBounds(display); displayRect = CGDisplayBounds(display);
ScreenWidth = DeviceWidth = (int)displayRect.size.width; ScreenWidth = DeviceWidth = (int)displayRect.size.width;
ScreenHeight = DeviceHeight = (int)displayRect.size.height; ScreenHeight = DeviceHeight = (int)displayRect.size.height;
CreationParams.WindowSize.set(ScreenWidth, ScreenHeight); CreationParams.WindowSize.set(ScreenWidth, ScreenHeight);
result = true; result = true;
} }
} }
else else
{ {
Window = [[NSWindow alloc] initWithContentRect:[[NSScreen mainScreen] frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreNonretained defer:NO screen:[NSScreen mainScreen]]; Window = [[NSWindow alloc] initWithContentRect:[[NSScreen mainScreen] frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreNonretained defer:NO screen:[NSScreen mainScreen]];
[Window setLevel: CGShieldingWindowLevel()]; [Window setLevel: CGShieldingWindowLevel()];
[Window setAcceptsMouseMovedEvents:TRUE]; [Window setAcceptsMouseMovedEvents:TRUE];
[Window setIsVisible:TRUE]; [Window setIsVisible:TRUE];
[Window makeKeyAndOrderFront:nil]; [Window makeKeyAndOrderFront:nil];
displayRect = CGDisplayBounds(display); displayRect = CGDisplayBounds(display);
ScreenWidth = DeviceWidth = (int)displayRect.size.width; ScreenWidth = DeviceWidth = (int)displayRect.size.width;
ScreenHeight = DeviceHeight = (int)displayRect.size.height; ScreenHeight = DeviceHeight = (int)displayRect.size.height;
CreationParams.WindowSize.set(ScreenWidth, ScreenHeight); CreationParams.WindowSize.set(ScreenWidth, ScreenHeight);
result = true; result = true;
} }
} }
if (!result) if (!result)
CGReleaseAllDisplays(); CGReleaseAllDisplays();
} }
} }
} }
} }
@catch (NSException *exception) @catch (NSException *exception)
{ {
closeDevice(); closeDevice();
result = false; result = false;
} }
if (result) if (result)
{ {
// fullscreen? // fullscreen?
if (Window == NULL && !CreationParams.WindowId) //hide menus in fullscreen mode only if (Window == NULL && !CreationParams.WindowId) //hide menus in fullscreen mode only
#ifdef __MAC_10_6 #ifdef __MAC_10_6
[NSApp setPresentationOptions:(NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)]; [NSApp setPresentationOptions:(NSApplicationPresentationAutoHideDock | NSApplicationPresentationAutoHideMenuBar)];
#else #else
SetSystemUIMode(kUIModeAllHidden, kUIOptionAutoShowMenuBar); SetSystemUIMode(kUIModeAllHidden, kUIOptionAutoShowMenuBar);
#endif #endif
if(CreationParams.DriverType == video::EDT_OPENGL) if(CreationParams.DriverType == video::EDT_OPENGL)
{ {
CGLSetCurrentContext(CGLContext); CGLSetCurrentContext(CGLContext);
newSwapInterval = (CreationParams.Vsync) ? 1 : 0; newSwapInterval = (CreationParams.Vsync) ? 1 : 0;
CGLSetParameter(CGLContext,kCGLCPSwapInterval,&newSwapInterval); CGLSetParameter(CGLContext,kCGLCPSwapInterval,&newSwapInterval);
} }
} }
return (result); return (result);
} }
void CIrrDeviceMacOSX::setResize(int width, int height) void CIrrDeviceMacOSX::setResize(int width, int height)
{ {
...@@ -895,8 +893,8 @@ void CIrrDeviceMacOSX::setResize(int width, int height) ...@@ -895,8 +893,8 @@ void CIrrDeviceMacOSX::setResize(int width, int height)
DeviceHeight = height; DeviceHeight = height;
// update the size of the opengl rendering context // update the size of the opengl rendering context
if(OGLContext); if(OGLContext);
[OGLContext update]; [OGLContext update];
// resize the driver to the inner pane size // resize the driver to the inner pane size
if (Window) if (Window)
...@@ -906,7 +904,7 @@ void CIrrDeviceMacOSX::setResize(int width, int height) ...@@ -906,7 +904,7 @@ void CIrrDeviceMacOSX::setResize(int width, int height)
} }
else else
getVideoDriver()->OnResize(core::dimension2d<u32>( (s32)width, (s32)height)); getVideoDriver()->OnResize(core::dimension2d<u32>( (s32)width, (s32)height));
if (CreationParams.WindowId && OGLContext) if (CreationParams.WindowId && OGLContext)
[(NSOpenGLContext *)OGLContext update]; [(NSOpenGLContext *)OGLContext update];
} }
...@@ -968,8 +966,8 @@ void CIrrDeviceMacOSX::flush() ...@@ -968,8 +966,8 @@ void CIrrDeviceMacOSX::flush()
bool CIrrDeviceMacOSX::run() bool CIrrDeviceMacOSX::run()
{ {
NSAutoreleasePool* Pool = [[NSAutoreleasePool alloc] init]; NSAutoreleasePool* Pool = [[NSAutoreleasePool alloc] init];
NSEvent *event; NSEvent *event;
irr::SEvent ievent; irr::SEvent ievent;
...@@ -1097,8 +1095,8 @@ bool CIrrDeviceMacOSX::run() ...@@ -1097,8 +1095,8 @@ bool CIrrDeviceMacOSX::run()
} }
pollJoysticks(); pollJoysticks();
[Pool release]; [Pool release];
return (![[NSApp delegate] isQuit] && IsActive); return (![[NSApp delegate] isQuit] && IsActive);
} }
...@@ -1141,9 +1139,9 @@ void CIrrDeviceMacOSX::setWindowCaption(const wchar_t* text) ...@@ -1141,9 +1139,9 @@ void CIrrDeviceMacOSX::setWindowCaption(const wchar_t* text)
size = wcstombs(title,text,1024); size = wcstombs(title,text,1024);
title[1023] = 0; title[1023] = 0;
#ifdef __MAC_10_6 #ifdef __MAC_10_6
NSString* name = [NSString stringWithCString:title encoding:NSUTF8StringEncoding]; NSString* name = [NSString stringWithCString:title encoding:NSUTF8StringEncoding];
#else #else
NSString* name = [NSString stringWithCString:title length:size]; NSString* name = [NSString stringWithCString:title length:size];
#endif #endif
[Window setTitle:name]; [Window setTitle:name];
[name release]; [name release];
...@@ -1254,7 +1252,7 @@ void CIrrDeviceMacOSX::postMouseEvent(void *event,irr::SEvent &ievent) ...@@ -1254,7 +1252,7 @@ void CIrrDeviceMacOSX::postMouseEvent(void *event,irr::SEvent &ievent)
{ {
CGEventRef ourEvent = CGEventCreate(NULL); CGEventRef ourEvent = CGEventCreate(NULL);
CGPoint point = CGEventGetLocation(ourEvent); CGPoint point = CGEventGetLocation(ourEvent);
CFRelease(ourEvent); CFRelease(ourEvent);
ievent.MouseInput.X = (int)point.x; ievent.MouseInput.X = (int)point.x;
ievent.MouseInput.Y = (int)point.y; ievent.MouseInput.Y = (int)point.y;
...@@ -1286,7 +1284,7 @@ void CIrrDeviceMacOSX::storeMouseLocation() ...@@ -1286,7 +1284,7 @@ void CIrrDeviceMacOSX::storeMouseLocation()
{ {
CGEventRef ourEvent = CGEventCreate(NULL); CGEventRef ourEvent = CGEventCreate(NULL);
CGPoint point = CGEventGetLocation(ourEvent); CGPoint point = CGEventGetLocation(ourEvent);
CFRelease(ourEvent); CFRelease(ourEvent);
x = (int)point.x; x = (int)point.x;
y = (int)point.y; y = (int)point.y;
...@@ -1329,14 +1327,14 @@ void CIrrDeviceMacOSX::setMouseLocation(int x,int y) ...@@ -1329,14 +1327,14 @@ void CIrrDeviceMacOSX::setMouseLocation(int x,int y)
c.x = p.x; c.x = p.x;
c.y = p.y; c.y = p.y;
#ifdef __MAC_10_6 #ifdef __MAC_10_6
/*CGEventSourceRef SourceRef = CGEventSourceCreate(0); /*CGEventSourceRef SourceRef = CGEventSourceCreate(0);
CGEventSourceSetLocalEventsSuppressionInterval(SourceRef, 0); CGEventSourceSetLocalEventsSuppressionInterval(SourceRef, 0);
CFRelease(SourceRef);*/ CFRelease(SourceRef);*/
CGSetLocalEventsSuppressionInterval(0); CGSetLocalEventsSuppressionInterval(0);
#else #else
CGSetLocalEventsSuppressionInterval(0); CGSetLocalEventsSuppressionInterval(0);
#endif #endif
CGWarpMouseCursorPosition(c); CGWarpMouseCursorPosition(c);
} }
...@@ -1353,51 +1351,51 @@ void CIrrDeviceMacOSX::setCursorVisible(bool visible) ...@@ -1353,51 +1351,51 @@ void CIrrDeviceMacOSX::setCursorVisible(bool visible)
void CIrrDeviceMacOSX::initKeycodes() void CIrrDeviceMacOSX::initKeycodes()
{ {
KeyCodes[kVK_UpArrow] = irr::KEY_UP; KeyCodes[kVK_UpArrow] = irr::KEY_UP;
KeyCodes[kVK_DownArrow] = irr::KEY_DOWN; KeyCodes[kVK_DownArrow] = irr::KEY_DOWN;
KeyCodes[kVK_LeftArrow] = irr::KEY_LEFT; KeyCodes[kVK_LeftArrow] = irr::KEY_LEFT;
KeyCodes[kVK_RightArrow] = irr::KEY_RIGHT; KeyCodes[kVK_RightArrow] = irr::KEY_RIGHT;
KeyCodes[kVK_F1] = irr::KEY_F1; KeyCodes[kVK_F1] = irr::KEY_F1;
KeyCodes[kVK_F2] = irr::KEY_F2; KeyCodes[kVK_F2] = irr::KEY_F2;
KeyCodes[kVK_F3] = irr::KEY_F3; KeyCodes[kVK_F3] = irr::KEY_F3;
KeyCodes[kVK_F4] = irr::KEY_F4; KeyCodes[kVK_F4] = irr::KEY_F4;
KeyCodes[kVK_F5] = irr::KEY_F5; KeyCodes[kVK_F5] = irr::KEY_F5;
KeyCodes[kVK_F6] = irr::KEY_F6; KeyCodes[kVK_F6] = irr::KEY_F6;
KeyCodes[kVK_F7] = irr::KEY_F7; KeyCodes[kVK_F7] = irr::KEY_F7;
KeyCodes[kVK_F8] = irr::KEY_F8; KeyCodes[kVK_F8] = irr::KEY_F8;
KeyCodes[kVK_F9] = irr::KEY_F9; KeyCodes[kVK_F9] = irr::KEY_F9;
KeyCodes[kVK_F10] = irr::KEY_F10; KeyCodes[kVK_F10] = irr::KEY_F10;
KeyCodes[kVK_F11] = irr::KEY_F11; KeyCodes[kVK_F11] = irr::KEY_F11;
KeyCodes[kVK_F12] = irr::KEY_F12; KeyCodes[kVK_F12] = irr::KEY_F12;
KeyCodes[kVK_F13] = irr::KEY_F13; KeyCodes[kVK_F13] = irr::KEY_F13;
KeyCodes[kVK_F14] = irr::KEY_F14; KeyCodes[kVK_F14] = irr::KEY_F14;
KeyCodes[kVK_F15] = irr::KEY_F15; KeyCodes[kVK_F15] = irr::KEY_F15;
KeyCodes[kVK_F16] = irr::KEY_F16; KeyCodes[kVK_F16] = irr::KEY_F16;
KeyCodes[kVK_F17] = irr::KEY_F17; KeyCodes[kVK_F17] = irr::KEY_F17;
KeyCodes[kVK_F18] = irr::KEY_F18; KeyCodes[kVK_F18] = irr::KEY_F18;
KeyCodes[kVK_F19] = irr::KEY_F19; KeyCodes[kVK_F19] = irr::KEY_F19;
KeyCodes[kVK_F20] = irr::KEY_F20; KeyCodes[kVK_F20] = irr::KEY_F20;
KeyCodes[kVK_Home] = irr::KEY_HOME; KeyCodes[kVK_Home] = irr::KEY_HOME;
KeyCodes[kVK_End] = irr::KEY_END; KeyCodes[kVK_End] = irr::KEY_END;
KeyCodes[NSInsertFunctionKey] = irr::KEY_INSERT; KeyCodes[NSInsertFunctionKey] = irr::KEY_INSERT;
KeyCodes[kVK_ForwardDelete] = irr::KEY_DELETE; KeyCodes[kVK_ForwardDelete] = irr::KEY_DELETE;
KeyCodes[kVK_Help] = irr::KEY_HELP; KeyCodes[kVK_Help] = irr::KEY_HELP;
KeyCodes[NSSelectFunctionKey] = irr::KEY_SELECT; KeyCodes[NSSelectFunctionKey] = irr::KEY_SELECT;
KeyCodes[NSPrintFunctionKey] = irr::KEY_PRINT; KeyCodes[NSPrintFunctionKey] = irr::KEY_PRINT;
KeyCodes[NSExecuteFunctionKey] = irr::KEY_EXECUT; KeyCodes[NSExecuteFunctionKey] = irr::KEY_EXECUT;
KeyCodes[NSPrintScreenFunctionKey] = irr::KEY_SNAPSHOT; KeyCodes[NSPrintScreenFunctionKey] = irr::KEY_SNAPSHOT;
KeyCodes[NSPauseFunctionKey] = irr::KEY_PAUSE; KeyCodes[NSPauseFunctionKey] = irr::KEY_PAUSE;
KeyCodes[NSScrollLockFunctionKey] = irr::KEY_SCROLL; KeyCodes[NSScrollLockFunctionKey] = irr::KEY_SCROLL;
KeyCodes[kVK_Delete] = irr::KEY_BACK; KeyCodes[kVK_Delete] = irr::KEY_BACK;
KeyCodes[kVK_Tab] = irr::KEY_TAB; KeyCodes[kVK_Tab] = irr::KEY_TAB;
KeyCodes[kVK_Return] = irr::KEY_RETURN; KeyCodes[kVK_Return] = irr::KEY_RETURN;
KeyCodes[kVK_Escape] = irr::KEY_ESCAPE; KeyCodes[kVK_Escape] = irr::KEY_ESCAPE;
KeyCodes[kVK_Control] = irr::KEY_CONTROL; KeyCodes[kVK_Control] = irr::KEY_CONTROL;
KeyCodes[kVK_RightControl] = irr::KEY_RCONTROL; KeyCodes[kVK_RightControl] = irr::KEY_RCONTROL;
KeyCodes[kVK_Command] = irr::KEY_MENU; KeyCodes[kVK_Command] = irr::KEY_MENU;
KeyCodes[kVK_Shift] = irr::KEY_SHIFT; KeyCodes[kVK_Shift] = irr::KEY_SHIFT;
KeyCodes[kVK_RightShift] = irr::KEY_RSHIFT; KeyCodes[kVK_RightShift] = irr::KEY_RSHIFT;
KeyCodes[kVK_Space] = irr::KEY_SPACE; KeyCodes[kVK_Space] = irr::KEY_SPACE;
KeyCodes[kVK_ANSI_A] = irr::KEY_KEY_A; KeyCodes[kVK_ANSI_A] = irr::KEY_KEY_A;
KeyCodes[kVK_ANSI_B] = irr::KEY_KEY_B; KeyCodes[kVK_ANSI_B] = irr::KEY_KEY_B;
...@@ -1554,24 +1552,24 @@ bool CIrrDeviceMacOSX::present(video::IImage* surface, void* windowId, core::rec ...@@ -1554,24 +1552,24 @@ bool CIrrDeviceMacOSX::present(video::IImage* surface, void* windowId, core::rec
const u32 minWidth = core::min_(surface->getDimension().Width, (u32)areaRect.size.width); const u32 minWidth = core::min_(surface->getDimension().Width, (u32)areaRect.size.width);
for (u32 y=0; y!=srcheight; ++y) for (u32 y=0; y!=srcheight; ++y)
{ {
if(SoftwareRendererType == 2) if(SoftwareRendererType == 2)
{ {
if (surface->getColorFormat() == video::ECF_A8R8G8B8) if (surface->getColorFormat() == video::ECF_A8R8G8B8)
video::CColorConverter::convert_A8R8G8B8toB8G8R8(srcdata, minWidth, destData); video::CColorConverter::convert_A8R8G8B8toB8G8R8(srcdata, minWidth, destData);
else if (surface->getColorFormat() == video::ECF_A1R5G5B5) else if (surface->getColorFormat() == video::ECF_A1R5G5B5)
video::CColorConverter::convert_A1R5G5B5toB8G8R8(srcdata, minWidth, destData); video::CColorConverter::convert_A1R5G5B5toB8G8R8(srcdata, minWidth, destData);
else else
video::CColorConverter::convert_viaFormat(srcdata, surface->getColorFormat(), minWidth, destData, video::ECF_R8G8B8); video::CColorConverter::convert_viaFormat(srcdata, surface->getColorFormat(), minWidth, destData, video::ECF_R8G8B8);
} }
else else
{ {
if (surface->getColorFormat() == video::ECF_A8R8G8B8) if (surface->getColorFormat() == video::ECF_A8R8G8B8)
video::CColorConverter::convert_A8R8G8B8toR8G8B8(srcdata, minWidth, destData); video::CColorConverter::convert_A8R8G8B8toR8G8B8(srcdata, minWidth, destData);
else if (surface->getColorFormat() == video::ECF_A1R5G5B5) else if (surface->getColorFormat() == video::ECF_A1R5G5B5)
video::CColorConverter::convert_A1R5G5B5toR8G8B8(srcdata, minWidth, destData); video::CColorConverter::convert_A1R5G5B5toR8G8B8(srcdata, minWidth, destData);
else else
video::CColorConverter::convert_viaFormat(srcdata, surface->getColorFormat(), minWidth, destData, video::ECF_R8G8B8); video::CColorConverter::convert_viaFormat(srcdata, surface->getColorFormat(), minWidth, destData, video::ECF_R8G8B8);
} }
srcdata += srcPitch; srcdata += srcPitch;
destData += destPitch; destData += destPitch;
...@@ -1836,35 +1834,35 @@ video::IVideoModeList* CIrrDeviceMacOSX::getVideoModeList() ...@@ -1836,35 +1834,35 @@ video::IVideoModeList* CIrrDeviceMacOSX::getVideoModeList()
display = CGMainDisplayID(); display = CGMainDisplayID();
#ifdef __MAC_10_6 #ifdef __MAC_10_6
CFArrayRef Modes = CGDisplayCopyAllDisplayModes(display, NULL); CFArrayRef Modes = CGDisplayCopyAllDisplayModes(display, NULL);
for(int i = 0; i < CFArrayGetCount(Modes); ++i) for(int i = 0; i < CFArrayGetCount(Modes); ++i)
{ {
CGDisplayModeRef CurrentMode = (CGDisplayModeRef)CFArrayGetValueAtIndex(Modes, i); CGDisplayModeRef CurrentMode = (CGDisplayModeRef)CFArrayGetValueAtIndex(Modes, i);
u8 Depth = 0; u8 Depth = 0;
CFStringRef pixEnc = CGDisplayModeCopyPixelEncoding(CurrentMode); CFStringRef pixEnc = CGDisplayModeCopyPixelEncoding(CurrentMode);
if(CFStringCompare(pixEnc, CFSTR(IO32BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) if(CFStringCompare(pixEnc, CFSTR(IO32BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)
Depth = 32; Depth = 32;
else else
if(CFStringCompare(pixEnc, CFSTR(IO16BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) if(CFStringCompare(pixEnc, CFSTR(IO16BitDirectPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)
Depth = 16; Depth = 16;
else else
if(CFStringCompare(pixEnc, CFSTR(IO8BitIndexedPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo) if(CFStringCompare(pixEnc, CFSTR(IO8BitIndexedPixels), kCFCompareCaseInsensitive) == kCFCompareEqualTo)
Depth = 8; Depth = 8;
if(Depth) if(Depth)
{ {
unsigned int Width = CGDisplayModeGetWidth(CurrentMode); unsigned int Width = CGDisplayModeGetWidth(CurrentMode);
unsigned int Height = CGDisplayModeGetHeight(CurrentMode); unsigned int Height = CGDisplayModeGetHeight(CurrentMode);
VideoModeList.addMode(core::dimension2d<u32>(Width, Height), Depth); VideoModeList.addMode(core::dimension2d<u32>(Width, Height), Depth);
} }
} }
#else #else
CFArrayRef availableModes = CGDisplayAvailableModes(display); CFArrayRef availableModes = CGDisplayAvailableModes(display);
unsigned int numberOfAvailableModes = CFArrayGetCount(availableModes); unsigned int numberOfAvailableModes = CFArrayGetCount(availableModes);
for (u32 i= 0; i<numberOfAvailableModes; ++i) for (u32 i= 0; i<numberOfAvailableModes; ++i)
{ {
...@@ -1891,3 +1889,4 @@ video::IVideoModeList* CIrrDeviceMacOSX::getVideoModeList() ...@@ -1891,3 +1889,4 @@ video::IVideoModeList* CIrrDeviceMacOSX::getVideoModeList()
} // end namespace } // end namespace
#endif // _IRR_COMPILE_WITH_OSX_DEVICE_ #endif // _IRR_COMPILE_WITH_OSX_DEVICE_
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment