From 6b3fae9aebdafd8ed605543272d7d9cbf2f8c5dd Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Tue, 29 Nov 2011 12:38:05 +0100 Subject: GLContextImpl*: createImpl() / makeCurrentImpl() refinement / robostness createImpl(): If successful must leave context current. makeCurrentImpl(): Is only called if context is not just created, hence the boolean parameter 'boolean newCreatedContext' is removed. This clearifies and actually cleans up the native makeContextCurrent/releaseContext call pairs. MacOSXCGLContext: CGL and NS impl. of native makeContextCurrent/releaseContext uses CGL locking to provide a thread safety. This is recommended in OS X OpenGL documentation on [shared context] multithreaded use cases. Post creation code, as seen in some pbuffer cases is moved to overriden createImpl() methods. --- src/jogl/native/macosx/MacOSXWindowSystemInterface.m | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'src/jogl/native') diff --git a/src/jogl/native/macosx/MacOSXWindowSystemInterface.m b/src/jogl/native/macosx/MacOSXWindowSystemInterface.m index af269a4b5..8c04f1774 100644 --- a/src/jogl/native/macosx/MacOSXWindowSystemInterface.m +++ b/src/jogl/native/macosx/MacOSXWindowSystemInterface.m @@ -567,10 +567,21 @@ NSOpenGLContext* createContext(NSOpenGLContext* share, } Bool makeCurrentContext(NSOpenGLContext* ctx) { +#if 0 + // we issue the CGL Lock from Java upfront! + NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; + CGLError cglError = CGLLockContext([ctx CGLContextObj]); + if(0 == cglError) { + [ctx makeCurrentContext]; + } + [pool release]; + return 0 == cglError; +#else NSAutoreleasePool* pool = [[NSAutoreleasePool alloc] init]; [ctx makeCurrentContext]; [pool release]; return true; +#endif } Bool clearCurrentContext(NSOpenGLContext* ctx) { @@ -580,6 +591,10 @@ Bool clearCurrentContext(NSOpenGLContext* ctx) { [ctx makeCurrentContext]; } [NSOpenGLContext clearCurrentContext]; +#if 0 + // we issue the CGL Lock from Java upfront! + CGLUnlockContext([ctx CGLContextObj]); +#endif [pool release]; return true; } -- cgit v1.2.3