diff options
author | egladil <egladil@openttd.org> | 2007-11-23 02:44:05 +0000 |
---|---|---|
committer | egladil <egladil@openttd.org> | 2007-11-23 02:44:05 +0000 |
commit | 2ebf50e421c75eedf240b235871b2bb9534d6cf8 (patch) | |
tree | 3b1ce956335dc5ebbf0984361217fe6f5f42c13f /src/video/cocoa/wnd_quickdraw.mm | |
parent | 9d3cc5b2718c43e6960733b334682be9e663ba9a (diff) | |
download | openttd-2ebf50e421c75eedf240b235871b2bb9534d6cf8.tar.xz |
(svn r11498) -Add [FS#1411]: [OSX] Added support for using Quartz instead of Quickdraw in windowed mode on OS X 10.4 and higher. Based on a patch by blackis.
Diffstat (limited to 'src/video/cocoa/wnd_quickdraw.mm')
-rw-r--r-- | src/video/cocoa/wnd_quickdraw.mm | 21 |
1 files changed, 13 insertions, 8 deletions
diff --git a/src/video/cocoa/wnd_quickdraw.mm b/src/video/cocoa/wnd_quickdraw.mm index 592c41d6e..4c125ae38 100644 --- a/src/video/cocoa/wnd_quickdraw.mm +++ b/src/video/cocoa/wnd_quickdraw.mm @@ -54,7 +54,7 @@ class WindowQuickdrawSubdriver; /* Subclass of NSWindow to fix genie effect and support resize events */ -@interface OTTD_QuartzWindow : NSWindow { +@interface OTTD_QuickdrawWindow : NSWindow { WindowQuickdrawSubdriver *driver; } @@ -70,7 +70,7 @@ class WindowQuickdrawSubdriver; @end /* Delegate for our NSWindow to send ask for quit on close */ -@interface OTTD_QuartzWindowDelegate : NSObject{ +@interface OTTD_QuickdrawWindowDelegate : NSObject{ WindowQuickdrawSubdriver *driver; } @@ -93,7 +93,7 @@ class WindowQuickdrawSubdriver: public CocoaSubdriver { void *pixel_buffer; void *window_buffer; - OTTD_QuartzWindow *window; + OTTD_QuickdrawWindow *window; #define MAX_DIRTY_RECTS 100 Rect dirty_rects[MAX_DIRTY_RECTS]; @@ -179,7 +179,7 @@ public: }; -@implementation OTTD_QuartzWindow +@implementation OTTD_QuickdrawWindow - (void)setDriver:(WindowQuickdrawSubdriver*)drv { @@ -275,7 +275,7 @@ public: @end -@implementation OTTD_QuartzWindowDelegate +@implementation OTTD_QuickdrawWindowDelegate - (void)setDriver:(WindowQuickdrawSubdriver*)drv { driver = drv; @@ -390,7 +390,7 @@ bool WindowQuickdrawSubdriver::SetVideoMode(int width, int height) /* Check if we should recreate the window */ if (window == nil) { - OTTD_QuartzWindowDelegate *delegate; + OTTD_QuickdrawWindowDelegate *delegate; /* Set the window style */ style = NSTitledWindowMask; @@ -398,7 +398,7 @@ bool WindowQuickdrawSubdriver::SetVideoMode(int width, int height) style |= NSResizableWindowMask; /* Manually create a window, avoids having a nib file resource */ - window = [ [ OTTD_QuartzWindow alloc ] + window = [ [ OTTD_QuickdrawWindow alloc ] initWithContentRect:contentRect styleMask:style backing:NSBackingStoreBuffered @@ -421,7 +421,7 @@ bool WindowQuickdrawSubdriver::SetVideoMode(int width, int height) [ window setAcceptsMouseMovedEvents:YES ]; [ window setViewsNeedDisplay:NO ]; - delegate = [ [ OTTD_QuartzWindowDelegate alloc ] init ]; + delegate = [ [ OTTD_QuickdrawWindowDelegate alloc ] init ]; [ delegate setDriver:this ]; [ window setDelegate: [ delegate autorelease ] ]; } else { @@ -803,6 +803,11 @@ CocoaSubdriver *QZ_CreateWindowQuickdrawSubdriver(int width, int height, int bpp { WindowQuickdrawSubdriver *ret; + if (bpp != 8 && bpp != 32) { + DEBUG(driver, 0, "The cocoa quickdraw subdriver only supports 8 and 32 bpp."); + return NULL; + } + ret = new WindowQuickdrawSubdriver(bpp); if (!ret->ChangeResolution(width, height)) { |