You need to sign in or sign up before continuing.
Commit f126da63 authored by nadro's avatar nadro

- Added support for Burning's Video and Software Drivers in MacOSX.

git-svn-id: svn://svn.code.sf.net/p/irrlicht/code/trunk@4111 dfc29bdd-3216-0410-991c-e03cc46cb475
parent 65e3d8b4
...@@ -235,8 +235,9 @@ namespace irr ...@@ -235,8 +235,9 @@ namespace irr
int ScreenWidth; int ScreenWidth;
int ScreenHeight; int ScreenHeight;
u32 MouseButtonStates; u32 MouseButtonStates;
u32 SoftwareRendererType;
bool IsFullscreen;
bool IsActive; bool IsActive;
bool IsSoftwareRenderer;
bool IsShiftDown; bool IsShiftDown;
bool IsControlDown; bool IsControlDown;
bool IsResizable; bool IsResizable;
......
...@@ -478,9 +478,8 @@ namespace irr ...@@ -478,9 +478,8 @@ namespace irr
CIrrDeviceMacOSX::CIrrDeviceMacOSX(const SIrrlichtCreationParameters& param) CIrrDeviceMacOSX::CIrrDeviceMacOSX(const SIrrlichtCreationParameters& param)
: CIrrDeviceStub(param), Window(NULL), CGLContext(NULL), OGLContext(NULL), : CIrrDeviceStub(param), Window(NULL), CGLContext(NULL), OGLContext(NULL),
SoftwareDriverTarget(0), DeviceWidth(0), DeviceHeight(0), SoftwareDriverTarget(0), DeviceWidth(0), DeviceHeight(0),
ScreenWidth(0), ScreenHeight(0), MouseButtonStates(0), ScreenWidth(0), ScreenHeight(0), MouseButtonStates(0), SoftwareRendererType(0),
IsActive(true), IsSoftwareRenderer(false), IsActive(true), IsFullscreen(false), IsShiftDown(false), IsControlDown(false), IsResizable(false)
IsShiftDown(false), IsControlDown(false), IsResizable(false)
{ {
struct utsname name; struct utsname name;
NSString *path; NSString *path;
...@@ -517,14 +516,16 @@ CIrrDeviceMacOSX::CIrrDeviceMacOSX(const SIrrlichtCreationParameters& param) ...@@ -517,14 +516,16 @@ CIrrDeviceMacOSX::CIrrDeviceMacOSX(const SIrrlichtCreationParameters& param)
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)
return; return;
setResizable(false); setResizable(false);
CursorControl = new CCursorControl(CreationParams.WindowSize, this); CursorControl = new CCursorControl(CreationParams.WindowSize, this);
createDriver();
createDriver();
createGUIAndScene(); createGUIAndScene();
} }
...@@ -562,6 +563,9 @@ void CIrrDeviceMacOSX::closeDevice() ...@@ -562,6 +563,9 @@ void CIrrDeviceMacOSX::closeDevice()
[Window setReleasedWhenClosed:TRUE]; [Window setReleasedWhenClosed:TRUE];
[Window release]; [Window release];
Window = NULL; Window = NULL;
if (IsFullscreen)
CGReleaseAllDisplays();
} }
else else
{ {
...@@ -583,173 +587,186 @@ void CIrrDeviceMacOSX::closeDevice() ...@@ -583,173 +587,186 @@ void CIrrDeviceMacOSX::closeDevice()
} }
} }
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
{ {
Window = [[NSWindow alloc] initWithContentRect:NSMakeRect(0,0,CreationParams.WindowSize.Width,CreationParams.WindowSize.Height) styleMask:NSTitledWindowMask+NSClosableWindowMask+NSResizableWindowMask backing:NSBackingStoreBuffered defer:FALSE]; 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];
if (Window != NULL || CreationParams.WindowId) }
{
NSOpenGLPixelFormatAttribute windowattribs[] = if (Window != NULL || CreationParams.WindowId)
{ {
NSOpenGLPFANoRecovery, if (CreationParams.DriverType == video::EDT_OPENGL)
NSOpenGLPFAAccelerated, {
NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute)depthSize, NSOpenGLPixelFormatAttribute windowattribs[] =
NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute)CreationParams.Bits, {
NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute)alphaSize, NSOpenGLPFANoRecovery,
NSOpenGLPFASampleBuffers, (NSOpenGLPixelFormatAttribute)1, NSOpenGLPFAAccelerated,
NSOpenGLPFASamples, (NSOpenGLPixelFormatAttribute)CreationParams.AntiAlias, NSOpenGLPFADepthSize, (NSOpenGLPixelFormatAttribute)depthSize,
NSOpenGLPFAStencilSize, (NSOpenGLPixelFormatAttribute)(CreationParams.Stencilbuffer?1:0), NSOpenGLPFAColorSize, (NSOpenGLPixelFormatAttribute)CreationParams.Bits,
NSOpenGLPFADoubleBuffer, NSOpenGLPFAAlphaSize, (NSOpenGLPixelFormatAttribute)alphaSize,
(NSOpenGLPixelFormatAttribute)nil NSOpenGLPFASampleBuffers, (NSOpenGLPixelFormatAttribute)1,
}; NSOpenGLPFASamples, (NSOpenGLPixelFormatAttribute)CreationParams.AntiAlias,
NSOpenGLPFAStencilSize, (NSOpenGLPixelFormatAttribute)(CreationParams.Stencilbuffer?1:0),
if (CreationParams.AntiAlias<2) NSOpenGLPFADoubleBuffer,
{ (NSOpenGLPixelFormatAttribute)nil
windowattribs[ 9] = (NSOpenGLPixelFormatAttribute)0; };
windowattribs[11] = (NSOpenGLPixelFormatAttribute)0;
} if (CreationParams.AntiAlias<2)
{
NSOpenGLPixelFormat *format; windowattribs[ 9] = (NSOpenGLPixelFormatAttribute)0;
for (int i=0; i<3; ++i) windowattribs[11] = (NSOpenGLPixelFormatAttribute)0;
{ }
if (1==i)
{ NSOpenGLPixelFormat *format;
// Second try without stencilbuffer for (int i=0; i<3; ++i)
if (CreationParams.Stencilbuffer) {
{ if (1==i)
windowattribs[13]=(NSOpenGLPixelFormatAttribute)0; {
} // Second try without stencilbuffer
else if (CreationParams.Stencilbuffer)
continue; {
} windowattribs[13]=(NSOpenGLPixelFormatAttribute)0;
else if (2==i) }
{ else
// Third try without Doublebuffer continue;
os::Printer::log("No doublebuffering available.", ELL_WARNING); }
windowattribs[14]=(NSOpenGLPixelFormatAttribute)nil; else if (2==i)
} {
// Third try without Doublebuffer
format = [[NSOpenGLPixelFormat alloc] initWithAttributes:windowattribs]; os::Printer::log("No doublebuffering available.", ELL_WARNING);
if (format == NULL) windowattribs[14]=(NSOpenGLPixelFormatAttribute)nil;
{ }
if (CreationParams.AntiAlias>1)
{ format = [[NSOpenGLPixelFormat alloc] initWithAttributes:windowattribs];
while (!format && windowattribs[12]>1) if (format == NULL)
{ {
windowattribs[12] = (NSOpenGLPixelFormatAttribute)((int)windowattribs[12]-1); if (CreationParams.AntiAlias>1)
format = [[NSOpenGLPixelFormat alloc] initWithAttributes:windowattribs]; {
} while (!format && windowattribs[12]>1)
{
if (!format) windowattribs[12] = (NSOpenGLPixelFormatAttribute)((int)windowattribs[12]-1);
{ format = [[NSOpenGLPixelFormat alloc] initWithAttributes:windowattribs];
windowattribs[9] = (NSOpenGLPixelFormatAttribute)0; }
windowattribs[11] = (NSOpenGLPixelFormatAttribute)0;
format = [[NSOpenGLPixelFormat alloc] initWithAttributes:windowattribs]; if (!format)
if (!format) {
{ windowattribs[9] = (NSOpenGLPixelFormatAttribute)0;
// reset values for next try windowattribs[11] = (NSOpenGLPixelFormatAttribute)0;
windowattribs[9] = (NSOpenGLPixelFormatAttribute)1; format = [[NSOpenGLPixelFormat alloc] initWithAttributes:windowattribs];
windowattribs[11] = (NSOpenGLPixelFormatAttribute)CreationParams.AntiAlias; if (!format)
} {
else // reset values for next try
{ windowattribs[9] = (NSOpenGLPixelFormatAttribute)1;
os::Printer::log("No FSAA available.", ELL_WARNING); windowattribs[11] = (NSOpenGLPixelFormatAttribute)CreationParams.AntiAlias;
} }
else
} {
} os::Printer::log("No FSAA available.", ELL_WARNING);
} }
else
break; }
} }
CreationParams.AntiAlias = windowattribs[11]; }
CreationParams.Stencilbuffer=(windowattribs[13]==1); else
break;
if (format != NULL) }
{ CreationParams.AntiAlias = windowattribs[11];
OGLContext = [[NSOpenGLContext alloc] initWithFormat:format shareContext:NULL]; CreationParams.Stencilbuffer=(windowattribs[13]==1);
[format release];
} if (format != NULL)
{
if (OGLContext != NULL) OGLContext = [[NSOpenGLContext alloc] initWithFormat:format shareContext:NULL];
{ [format release];
if (!CreationParams.WindowId) }
{ }
[Window center];
[Window setDelegate:[NSApp delegate]];
[OGLContext setView:[Window contentView]];
[Window setAcceptsMouseMovedEvents:TRUE];
[Window setIsVisible:TRUE];
[Window makeKeyAndOrderFront:nil];
}
else //use another window for drawing
[OGLContext setView:(NSView*)CreationParams.WindowId];
CGLContext = (CGLContextObj) [OGLContext CGLContextObj]; if (OGLContext != NULL || CreationParams.DriverType != video::EDT_OPENGL)
DeviceWidth = CreationParams.WindowSize.Width; {
DeviceHeight = CreationParams.WindowSize.Height; if (!CreationParams.WindowId)
result = true; {
} [Window center];
} [Window setDelegate:[NSApp delegate]];
}
else if(CreationParams.DriverType == video::EDT_OPENGL)
{ [OGLContext setView:[Window contentView]];
[Window setAcceptsMouseMovedEvents:TRUE];
[Window setIsVisible:TRUE];
[Window makeKeyAndOrderFront:nil];
}
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];
DeviceWidth = CreationParams.WindowSize.Width;
DeviceHeight = CreationParams.WindowSize.Height;
result = true;
}
}
}
else
{
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))
{ {
...@@ -761,99 +778,115 @@ bool CIrrDeviceMacOSX::createWindow() ...@@ -761,99 +778,115 @@ bool CIrrDeviceMacOSX::createWindow()
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)
{ {
CGLPixelFormatAttribute fullattribs[] = if (CreationParams.DriverType == video::EDT_OPENGL)
{ {
kCGLPFAFullScreen, CGLPixelFormatAttribute fullattribs[] =
kCGLPFADisplayMask, (CGLPixelFormatAttribute)CGDisplayIDToOpenGLDisplayMask(display), {
kCGLPFADoubleBuffer, kCGLPFAFullScreen,
kCGLPFANoRecovery, kCGLPFADisplayMask, (CGLPixelFormatAttribute)CGDisplayIDToOpenGLDisplayMask(display),
kCGLPFAAccelerated, kCGLPFADoubleBuffer,
kCGLPFADepthSize, (CGLPixelFormatAttribute)depthSize, kCGLPFANoRecovery,
kCGLPFAColorSize, (CGLPixelFormatAttribute)CreationParams.Bits, kCGLPFAAccelerated,
kCGLPFAAlphaSize, (CGLPixelFormatAttribute)alphaSize, kCGLPFADepthSize, (CGLPixelFormatAttribute)depthSize,
kCGLPFASampleBuffers, (CGLPixelFormatAttribute)(CreationParams.AntiAlias?1:0), kCGLPFAColorSize, (CGLPixelFormatAttribute)CreationParams.Bits,
kCGLPFASamples, (CGLPixelFormatAttribute)CreationParams.AntiAlias, kCGLPFAAlphaSize, (CGLPixelFormatAttribute)alphaSize,
kCGLPFAStencilSize, (CGLPixelFormatAttribute)(CreationParams.Stencilbuffer?1:0), kCGLPFASampleBuffers, (CGLPixelFormatAttribute)(CreationParams.AntiAlias?1:0),
(CGLPixelFormatAttribute)NULL kCGLPFASamples, (CGLPixelFormatAttribute)CreationParams.AntiAlias,
}; kCGLPFAStencilSize, (CGLPixelFormatAttribute)(CreationParams.Stencilbuffer?1:0),
(CGLPixelFormatAttribute)NULL
pixelFormat = NULL; };
numPixelFormats = 0;
CGLChoosePixelFormat(fullattribs,&pixelFormat,&numPixelFormats); pixelFormat = NULL;
numPixelFormats = 0;
if (pixelFormat != NULL) CGLChoosePixelFormat(fullattribs,&pixelFormat,&numPixelFormats);
{
CGLCreateContext(pixelFormat,NULL,&CGLContext); if (pixelFormat != NULL)
CGLDestroyPixelFormat(pixelFormat); {
} CGLCreateContext(pixelFormat,NULL,&CGLContext);
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;
} }
} }
if (!result) else
CGReleaseAllDisplays(); {
} Window = [[NSWindow alloc] initWithContentRect:[[NSScreen mainScreen] frame] styleMask:NSBorderlessWindowMask backing:NSBackingStoreNonretained defer:NO screen:[NSScreen mainScreen]];
}
} [Window setLevel: CGShieldingWindowLevel()];
} [Window setAcceptsMouseMovedEvents:TRUE];
@catch (NSException *exception) [Window setIsVisible:TRUE];
{ [Window makeKeyAndOrderFront:nil];
closeDevice();
result = false; displayRect = CGDisplayBounds(display);
} ScreenWidth = DeviceWidth = (int)displayRect.size.width;
ScreenHeight = DeviceHeight = (int)displayRect.size.height;
if (result) CreationParams.WindowSize.set(ScreenWidth, ScreenHeight);
{ result = true;
// fullscreen? }
if (Window == NULL && !CreationParams.WindowId) //hide menus in fullscreen mode only }
if (!result)
CGReleaseAllDisplays();
}
}
}
}
@catch (NSException *exception)
{
closeDevice();
result = false;
}
if (result)
{
// fullscreen?
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
CGLSetCurrentContext(CGLContext); if(CreationParams.DriverType == video::EDT_OPENGL)
newSwapInterval = (CreationParams.Vsync) ? 1 : 0; {
CGLSetParameter(CGLContext,kCGLCPSwapInterval,&newSwapInterval); CGLSetCurrentContext(CGLContext);
if (IsSoftwareRenderer && CreationParams.DriverType != video::EDT_NULL) newSwapInterval = (CreationParams.Vsync) ? 1 : 0;
{ CGLSetParameter(CGLContext,kCGLCPSwapInterval,&newSwapInterval);
GLint order = -1; // below window }
CGLSetParameter(CGLContext, kCGLCPSurfaceOrder, &order); }
}
} return (result);
}
return (result);
}
void CIrrDeviceMacOSX::setResize(int width, int height) void CIrrDeviceMacOSX::setResize(int width, int height)
{ {
...@@ -862,7 +895,8 @@ void CIrrDeviceMacOSX::setResize(int width, int height) ...@@ -862,7 +895,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
[OGLContext update]; if(OGLContext);
[OGLContext update];
// resize the driver to the inner pane size // resize the driver to the inner pane size
if (Window) if (Window)
...@@ -872,6 +906,7 @@ void CIrrDeviceMacOSX::setResize(int width, int height) ...@@ -872,6 +906,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];
} }
...@@ -884,7 +919,7 @@ void CIrrDeviceMacOSX::createDriver() ...@@ -884,7 +919,7 @@ void CIrrDeviceMacOSX::createDriver()
case video::EDT_SOFTWARE: case video::EDT_SOFTWARE:
#ifdef _IRR_COMPILE_WITH_SOFTWARE_ #ifdef _IRR_COMPILE_WITH_SOFTWARE_
VideoDriver = video::createSoftwareDriver(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this); VideoDriver = video::createSoftwareDriver(CreationParams.WindowSize, CreationParams.Fullscreen, FileSystem, this);
IsSoftwareRenderer = true; SoftwareRendererType = 2;
#else #else
os::Printer::log("No Software driver support compiled in.", ELL_ERROR); os::Printer::log("No Software driver support compiled in.", ELL_ERROR);
#endif #endif
...@@ -893,7 +928,7 @@ void CIrrDeviceMacOSX::createDriver() ...@@ -893,7 +928,7 @@ void CIrrDeviceMacOSX::createDriver()
case video::EDT_BURNINGSVIDEO: case video::EDT_BURNINGSVIDEO:
#ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_ #ifdef _IRR_COMPILE_WITH_BURNINGSVIDEO_
VideoDriver = video::createBurningVideoDriver(CreationParams, FileSystem, this); VideoDriver = video::createBurningVideoDriver(CreationParams, FileSystem, this);
IsSoftwareRenderer = true; SoftwareRendererType = 1;
#else #else
os::Printer::log("Burning's video driver was not compiled in.", ELL_ERROR); os::Printer::log("Burning's video driver was not compiled in.", ELL_ERROR);
#endif #endif
...@@ -933,13 +968,13 @@ void CIrrDeviceMacOSX::flush() ...@@ -933,13 +968,13 @@ void CIrrDeviceMacOSX::flush()
bool CIrrDeviceMacOSX::run() bool CIrrDeviceMacOSX::run()
{ {
NSAutoreleasePool* Pool = [[NSAutoreleasePool alloc] init];
NSEvent *event; NSEvent *event;
irr::SEvent ievent; irr::SEvent ievent;
os::Timer::tick(); os::Timer::tick();
storeMouseLocation(); storeMouseLocation();
NSAutoreleasePool* Pool = [[NSAutoreleasePool alloc] init];
event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES]; event = [NSApp nextEventMatchingMask:NSAnyEventMask untilDate:[NSDate distantPast] inMode:NSDefaultRunLoopMode dequeue:YES];
if (event != nil) if (event != nil)
...@@ -1478,7 +1513,7 @@ bool CIrrDeviceMacOSX::present(video::IImage* surface, void* windowId, core::rec ...@@ -1478,7 +1513,7 @@ bool CIrrDeviceMacOSX::present(video::IImage* surface, void* windowId, core::rec
if (!surface) if (!surface)
return false; return false;
if (IsSoftwareRenderer) if (SoftwareRendererType > 0)
{ {
const u32 colorSamples=3; const u32 colorSamples=3;
// do we need to change the size? // do we need to change the size?
...@@ -1520,14 +1555,25 @@ bool CIrrDeviceMacOSX::present(video::IImage* surface, void* windowId, core::rec ...@@ -1520,14 +1555,25 @@ 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 0 if(SoftwareRendererType == 2)
if (surface->getColorFormat() == video::ECF_A8R8G8B8) {
video::CColorConverter::convert_A8R8G8B8toB8G8R8(srcdata, minWidth, destData); if (surface->getColorFormat() == video::ECF_A8R8G8B8)
else video::CColorConverter::convert_A8R8G8B8toB8G8R8(srcdata, minWidth, destData);
video::CColorConverter::convert_A1R5G5B5toB8G8R8(srcdata, minWidth, destData); else if (surface->getColorFormat() == video::ECF_A1R5G5B5)
#else video::CColorConverter::convert_A1R5G5B5toB8G8R8(srcdata, minWidth, destData);
video::CColorConverter::convert_viaFormat(srcdata, surface->getColorFormat(), minWidth, destData, video::ECF_R8G8B8); else
#endif video::CColorConverter::convert_viaFormat(srcdata, surface->getColorFormat(), minWidth, destData, video::ECF_R8G8B8);
}
else
{
if (surface->getColorFormat() == video::ECF_A8R8G8B8)
video::CColorConverter::convert_A8R8G8B8toR8G8B8(srcdata, minWidth, destData);
else if (surface->getColorFormat() == video::ECF_A1R5G5B5)
video::CColorConverter::convert_A1R5G5B5toR8G8B8(srcdata, minWidth, destData);
else
video::CColorConverter::convert_viaFormat(srcdata, surface->getColorFormat(), minWidth, destData, video::ECF_R8G8B8);
}
srcdata += srcPitch; srcdata += srcPitch;
destData += destPitch; destData += destPitch;
} }
......
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