osx: Fixed bug with creating context twice.

We should assign context and pixel_format vars to null to avoid
multiple context creation.
This commit is contained in:
Roman Kudiyarov 2010-07-16 19:46:17 +07:00 committed by Robert Bragg
parent 50793eac51
commit 8c69a639cb

View File

@ -80,31 +80,32 @@ clutter_backend_osx_create_context (ClutterBackend *backend,
{ {
ClutterBackendOSX *backend_osx = CLUTTER_BACKEND_OSX (backend); ClutterBackendOSX *backend_osx = CLUTTER_BACKEND_OSX (backend);
CLUTTER_OSX_POOL_ALLOC(); CLUTTER_OSX_POOL_ALLOC();
if ( backend_osx->context == nil)
/* Allocate ourselves a GL context. Since we're supposed to have only one per {
* backend we can just as well create it now. /* Allocate ourselves a GL context. Since we're supposed to have only one per
*/ * backend we can just as well create it now.
NSOpenGLPixelFormatAttribute attrs[] = { */
NSOpenGLPFADoubleBuffer, NSOpenGLPixelFormatAttribute attrs[] = {
NSOpenGLPFADepthSize, 24, NSOpenGLPFADoubleBuffer,
NSOpenGLPFAStencilSize, 8, NSOpenGLPFADepthSize, 24,
0 NSOpenGLPFAStencilSize, 8,
}; 0
};
backend_osx->pixel_format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs];
backend_osx->context = [[NSOpenGLContext alloc] backend_osx->pixel_format = [[NSOpenGLPixelFormat alloc] initWithAttributes:attrs];
initWithFormat: backend_osx->pixel_format backend_osx->context = [[NSOpenGLContext alloc]
shareContext: nil]; initWithFormat: backend_osx->pixel_format
/* Enable vblank sync - http://developer.apple.com/qa/qa2007/qa1521.html */ shareContext: nil];
#ifdef MAC_OS_X_VERSION_10_5 /* Enable vblank sync - http://developer.apple.com/qa/qa2007/qa1521.html */
const int sw = 1; #ifdef MAC_OS_X_VERSION_10_5
#else const int sw = 1;
const long sw = 1; #else
#endif const long sw = 1;
[backend_osx->context setValues:&sw forParameter: NSOpenGLCPSwapInterval]; #endif
[backend_osx->context setValues:&sw forParameter: NSOpenGLCPSwapInterval];
}
[backend_osx->context makeCurrentContext]; [backend_osx->context makeCurrentContext];
CLUTTER_NOTE (BACKEND, "Context was created"); CLUTTER_NOTE (BACKEND, "Context was created");
CLUTTER_OSX_POOL_RELEASE(); CLUTTER_OSX_POOL_RELEASE();
return TRUE; return TRUE;
@ -156,8 +157,10 @@ clutter_backend_osx_redraw (ClutterBackend *backend, ClutterStage *wrapper)
/*************************************************************************/ /*************************************************************************/
static void static void
clutter_backend_osx_init (ClutterBackendOSX *self) clutter_backend_osx_init (ClutterBackendOSX *backend_osx)
{ {
backend_osx->context = nil;
backend_osx->pixel_format = nil;
} }
static void static void