From 060bbcf067ad14dad9a9bb75c27a3521ac97aa04 Mon Sep 17 00:00:00 2001 From: Sonicadvance1 Date: Fri, 12 Feb 2010 12:41:53 +0000 Subject: [PATCH] Compiling with rev 63470 of wxWidgets now works with OSX x86_64. There are a BUNCH of errors while running, none fatal from what I've seen. This also fixes Dolphin creating multiple NSWindows when running multiple games. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5041 8ced0084-cf51-0410-be5f-012b33b47a6e --- SConstruct | 5 +- Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp | 1 + Source/Plugins/Plugin_VideoOGL/Src/cocoaGL.h | 2 + Source/Plugins/Plugin_VideoOGL/Src/cocoaGL.m | 122 ++++++++++-------- 4 files changed, 69 insertions(+), 61 deletions(-) diff --git a/SConstruct b/SConstruct index f3d9046bf4..9ecd94e7ed 100644 --- a/SConstruct +++ b/SConstruct @@ -343,10 +343,7 @@ else: env['HAVE_COCOA'] = 0 # handling wx flags CCFLAGS should be created before -if sys.platform == 'darwin' and env['osx'] == '64cocoa': - wxmods = ['adv', 'core', 'base'] -else: - wxmods = ['aui', 'adv', 'core', 'base'] +wxmods = ['aui', 'adv', 'core', 'base'] env['USE_WX'] = 0 if env['wxgl']: diff --git a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp index 93489f863d..4508debee7 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp +++ b/Source/Plugins/Plugin_VideoOGL/Src/GLUtil.cpp @@ -621,6 +621,7 @@ void OpenGL_Shutdown() delete GLWin.glCanvas; delete GLWin.frame; #elif defined(HAVE_COCOA) && HAVE_COCOA + cocoaGLDeleteWindow(GLWin.cocoaWin); cocoaGLDelete(GLWin.cocoaCtx); #elif defined(_WIN32) diff --git a/Source/Plugins/Plugin_VideoOGL/Src/cocoaGL.h b/Source/Plugins/Plugin_VideoOGL/Src/cocoaGL.h index 8409de66c9..cdd2a70650 100644 --- a/Source/Plugins/Plugin_VideoOGL/Src/cocoaGL.h +++ b/Source/Plugins/Plugin_VideoOGL/Src/cocoaGL.h @@ -19,6 +19,8 @@ NSOpenGLContext* cocoaGLInit(int mode); void cocoaGLDelete(NSOpenGLContext *ctx); +void cocoaGLDeleteWindow(NSWindow *window); + void cocoaGLSwap(NSOpenGLContext *ctx,NSWindow *window); #ifdef __cplusplus diff --git a/Source/Plugins/Plugin_VideoOGL/Src/cocoaGL.m b/Source/Plugins/Plugin_VideoOGL/Src/cocoaGL.m index 4eb1d2f18d..852ada40b6 100755 --- a/Source/Plugins/Plugin_VideoOGL/Src/cocoaGL.m +++ b/Source/Plugins/Plugin_VideoOGL/Src/cocoaGL.m @@ -4,11 +4,12 @@ NSWindow *cocoaGLCreateWindow(int w,int h) { NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; - NSWindow *window; - window = [[NSWindow alloc] initWithContentRect:NSMakeRect(50,50,w,h) - styleMask:NSTitledWindowMask | NSResizableWindowMask - backing:NSBackingStoreBuffered - defer:FALSE]; + NSWindow *window; + window = [[NSWindow alloc] initWithContentRect:NSMakeRect(50,50,w,h) + styleMask:NSTitledWindowMask | NSResizableWindowMask + backing:NSBackingStoreBuffered + defer:FALSE]; + [window setReleasedWhenClosed: YES]; [window setTitle:@"Dolphin on OSX"]; //[window makeKeyAndOrderFront: nil]; @@ -29,24 +30,22 @@ void cocoaGLSetTitle(NSWindow *win, const char *title) void cocoaGLMakeCurrent(NSOpenGLContext *ctx, NSWindow *win) { - NSAutoreleasePool *pool; + NSAutoreleasePool *pool; pool = [[NSAutoreleasePool alloc] init]; int value = 0; - [ctx setValues:&value forParameter:NSOpenGLCPSwapInterval]; + [ctx setValues:&value forParameter:NSOpenGLCPSwapInterval]; - if (ctx) { - - [ctx setView:[win contentView]]; - [ctx update]; - [ctx makeCurrentContext]; - } else { - [NSOpenGLContext clearCurrentContext]; - } - - [pool release]; + if (ctx) { + [ctx setView:[win contentView]]; + [ctx update]; + [ctx makeCurrentContext]; + } + else + [NSOpenGLContext clearCurrentContext]; + [pool release]; } @@ -54,10 +53,11 @@ void cocoaGLMakeCurrent(NSOpenGLContext *ctx, NSWindow *win) NSOpenGLContext* cocoaGLInit(int mode) { NSAutoreleasePool *pool; - NSOpenGLPixelFormatAttribute attr[32]; - NSOpenGLPixelFormat *fmt; - NSOpenGLContext *context; - int i = 0; + + NSOpenGLPixelFormatAttribute attr[32]; + NSOpenGLPixelFormat *fmt; + NSOpenGLContext *context; + int i = 0; pool = [[NSAutoreleasePool alloc] init]; @@ -65,10 +65,11 @@ NSOpenGLContext* cocoaGLInit(int mode) attr[i++] = 24; attr[i++] = NSOpenGLPFADoubleBuffer; - attr[i++] = NSOpenGLPFASampleBuffers; - attr[i++] = mode; - attr[i++] = NSOpenGLPFASamples; - attr[i++] = 1; + attr[i++] = NSOpenGLPFASampleBuffers; + attr[i++] = mode; + attr[i++] = NSOpenGLPFASamples; + attr[i++] = 1; + attr[i++] = NSOpenGLPFANoRecovery; #ifdef GL_VERSION_1_3 @@ -80,62 +81,69 @@ NSOpenGLContext* cocoaGLInit(int mode) attr[i++] = kCGLRendererGenericFloatID; #endif #endif - attr[i++] = NSOpenGLPFAScreenMask; - attr[i++] = CGDisplayIDToOpenGLDisplayMask(CGMainDisplayID()); + attr[i++] = NSOpenGLPFAScreenMask; + attr[i++] = CGDisplayIDToOpenGLDisplayMask(CGMainDisplayID()); - attr[i] = 0; + attr[i] = 0; - fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr]; + fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr]; if (fmt == nil) { - printf("failed to create pixel format\n"); - [pool release]; - return NULL; - } + printf("failed to create pixel format\n"); + [pool release]; + return NULL; + } - context = [[NSOpenGLContext alloc] initWithFormat:fmt shareContext:nil]; + context = [[NSOpenGLContext alloc] initWithFormat:fmt shareContext:nil]; - [fmt release]; + [fmt release]; - if (context == nil) { - printf("failed to create context\n"); - [pool release]; - return NULL; - } + if (context == nil) { + printf("failed to create context\n"); + [pool release]; + return NULL; + } - [pool release]; + [pool release]; - return context; + return context; } void cocoaGLDelete(NSOpenGLContext *ctx) { - NSAutoreleasePool *pool; + NSAutoreleasePool *pool; - pool = [[NSAutoreleasePool alloc] init]; + pool = [[NSAutoreleasePool alloc] init]; - [ctx clearDrawable]; - [ctx release]; + [ctx clearDrawable]; + [ctx release]; - [pool release]; + [pool release]; } +void cocoaGLDeleteWindow(NSWindow *window) +{ + + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + [window close]; + [pool release]; + + return window; +} void cocoaGLSwap(NSOpenGLContext *ctx,NSWindow *window) { - NSAutoreleasePool *pool; + NSAutoreleasePool *pool; - pool = [[NSAutoreleasePool alloc] init]; + pool = [[NSAutoreleasePool alloc] init]; [window makeKeyAndOrderFront: nil]; - ctx = [NSOpenGLContext currentContext]; - if (ctx != nil) { - [ctx flushBuffer]; - } + ctx = [NSOpenGLContext currentContext]; + if (ctx != nil) + [ctx flushBuffer]; else - { printf("bad cocoa gl ctx\n"); - } - [pool release]; - + + [pool release]; }