diff options
| author | tmator <tmator@gmail.com> | 2009-12-23 07:37:59 +0000 |
|---|---|---|
| committer | tmator <tmator@gmail.com> | 2009-12-23 07:37:59 +0000 |
| commit | ed84a87ed1ea22eced2adacf1152407c2d9b777b (patch) | |
| tree | efadb250bf1d1ae086dbddb140184685c69c0e23 /Source/Plugins/Plugin_VideoSoftware | |
| parent | 043681a37f8deb81ee04675b77170b471d9c6c44 (diff) | |
fix video software plugin build on osx
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@4719 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Plugins/Plugin_VideoSoftware')
| -rw-r--r-- | Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.cpp | 2 | ||||
| -rw-r--r-- | Source/Plugins/Plugin_VideoSoftware/Src/SConscript | 2 | ||||
| -rw-r--r-- | Source/Plugins/Plugin_VideoSoftware/Src/cocoaGL.h | 27 | ||||
| -rwxr-xr-x | Source/Plugins/Plugin_VideoSoftware/Src/cocoaGL.m | 141 |
4 files changed, 171 insertions, 1 deletions
diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.cpp b/Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.cpp index cdb87fdabd..2407bd8324 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.cpp +++ b/Source/Plugins/Plugin_VideoSoftware/Src/GLUtil.cpp @@ -167,7 +167,7 @@ bool OpenGL_Create(SVideoInitialize &_VideoInitialize, int _twidth, int _theight GLWin.width = s_backbuffer_width;
GLWin.height = s_backbuffer_height;
GLWin.cocoaWin = cocoaGLCreateWindow(GLWin.width, GLWin.height);
- GLWin.cocoaCtx = cocoaGLInit(g_Config.iMultisampleMode);
+ GLWin.cocoaCtx = cocoaGLInit(0);
#elif defined(_WIN32)
// ---------------------------------------------------------------------------------------
diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/SConscript b/Source/Plugins/Plugin_VideoSoftware/Src/SConscript index 221f7bec41..a5b9811e47 100644 --- a/Source/Plugins/Plugin_VideoSoftware/Src/SConscript +++ b/Source/Plugins/Plugin_VideoSoftware/Src/SConscript @@ -56,6 +56,8 @@ conf = gfxenv.Configure(custom_tests = tests, if sys.platform == 'darwin': gfxenv['FRAMEWORKS'] = ['CoreFoundation', 'System', 'OpenGL', 'Cocoa', 'Cg'] + compileFlags += ['-x','objective-c++',] + files += [ 'cocoaGL.m', ] conf.CheckPKG('OpenGL') diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/cocoaGL.h b/Source/Plugins/Plugin_VideoSoftware/Src/cocoaGL.h new file mode 100644 index 0000000000..8409de66c9 --- /dev/null +++ b/Source/Plugins/Plugin_VideoSoftware/Src/cocoaGL.h @@ -0,0 +1,27 @@ +#import <Cocoa/Cocoa.h> +#import <OpenGL/CGLRenderers.h> + +#ifdef __cplusplus +extern "C" +{ +#endif + + +void cocoaGLCreateApp(); + +NSWindow *cocoaGLCreateWindow(int w,int h); + +void cocoaGLSetTitle(NSWindow *win, const char *title); + +void cocoaGLMakeCurrent(NSOpenGLContext *ctx, NSWindow *win); + +NSOpenGLContext* cocoaGLInit(int mode); + +void cocoaGLDelete(NSOpenGLContext *ctx); + +void cocoaGLSwap(NSOpenGLContext *ctx,NSWindow *window); + +#ifdef __cplusplus +} +#endif + diff --git a/Source/Plugins/Plugin_VideoSoftware/Src/cocoaGL.m b/Source/Plugins/Plugin_VideoSoftware/Src/cocoaGL.m new file mode 100755 index 0000000000..4eb1d2f18d --- /dev/null +++ b/Source/Plugins/Plugin_VideoSoftware/Src/cocoaGL.m @@ -0,0 +1,141 @@ +#import "cocoaGL.h" + +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]; + + [window setTitle:@"Dolphin on OSX"]; + //[window makeKeyAndOrderFront: nil]; + + [pool release]; + + return window; +} + +void cocoaGLSetTitle(NSWindow *win, const char *title) +{ + NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init]; + + [win setTitle: [[[NSString alloc] initWithCString: title encoding: NSASCIIStringEncoding] autorelease]]; + + [pool release]; +} + +void cocoaGLMakeCurrent(NSOpenGLContext *ctx, NSWindow *win) +{ + NSAutoreleasePool *pool; + + pool = [[NSAutoreleasePool alloc] init]; + + int value = 0; + [ctx setValues:&value forParameter:NSOpenGLCPSwapInterval]; + + if (ctx) { + + [ctx setView:[win contentView]]; + [ctx update]; + [ctx makeCurrentContext]; + } else { + [NSOpenGLContext clearCurrentContext]; + } + + [pool release]; + +} + + + +NSOpenGLContext* cocoaGLInit(int mode) +{ + NSAutoreleasePool *pool; + NSOpenGLPixelFormatAttribute attr[32]; + NSOpenGLPixelFormat *fmt; + NSOpenGLContext *context; + int i = 0; + + pool = [[NSAutoreleasePool alloc] init]; + + attr[i++] = NSOpenGLPFADepthSize; + attr[i++] = 24; + attr[i++] = NSOpenGLPFADoubleBuffer; + + attr[i++] = NSOpenGLPFASampleBuffers; + attr[i++] = mode; + attr[i++] = NSOpenGLPFASamples; + attr[i++] = 1; + attr[i++] = NSOpenGLPFANoRecovery; +#ifdef GL_VERSION_1_3 + +#else +#ifdef GL_VERSION_1_2 +#warning "your card only supports ogl 1.2, dolphin will use software renderer" + //if opengl < 1.3 uncomment this twoo lines to use software renderer + attr[i++] = NSOpenGLPFARendererID; + attr[i++] = kCGLRendererGenericFloatID; +#endif +#endif + attr[i++] = NSOpenGLPFAScreenMask; + attr[i++] = CGDisplayIDToOpenGLDisplayMask(CGMainDisplayID()); + + attr[i] = 0; + + fmt = [[NSOpenGLPixelFormat alloc] initWithAttributes:attr]; + if (fmt == nil) { + printf("failed to create pixel format\n"); + [pool release]; + return NULL; + } + + context = [[NSOpenGLContext alloc] initWithFormat:fmt shareContext:nil]; + + [fmt release]; + + if (context == nil) { + printf("failed to create context\n"); + [pool release]; + return NULL; + } + + [pool release]; + + return context; + +} + +void cocoaGLDelete(NSOpenGLContext *ctx) +{ + NSAutoreleasePool *pool; + + pool = [[NSAutoreleasePool alloc] init]; + + [ctx clearDrawable]; + [ctx release]; + + [pool release]; + +} + +void cocoaGLSwap(NSOpenGLContext *ctx,NSWindow *window) +{ + NSAutoreleasePool *pool; + + pool = [[NSAutoreleasePool alloc] init]; + [window makeKeyAndOrderFront: nil]; + + ctx = [NSOpenGLContext currentContext]; + if (ctx != nil) { + [ctx flushBuffer]; + } + else + { + printf("bad cocoa gl ctx\n"); + } + [pool release]; + +} |
