From 6b3fae9aebdafd8ed605543272d7d9cbf2f8c5dd Mon Sep 17 00:00:00 2001
From: Sven Gothel <sgothel@jausoft.com>
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.
---
 .../jogamp/opengl/macosx/cgl/MacOSXPbufferCGLContext.java      | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

(limited to 'src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLContext.java')

diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLContext.java
index f4b71d37d..7ba7d2d5a 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLContext.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLContext.java
@@ -38,6 +38,8 @@ import javax.media.opengl.GLContext;
 import javax.media.opengl.GLException;
 import javax.media.opengl.GLPbuffer;
 
+import jogamp.opengl.GLContextImpl;
+
 public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
 
   // State for render-to-texture and render-to-texture-rectangle support
@@ -60,10 +62,9 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
   public void releasePbufferFromTexture() {
   }
 
-  protected void makeCurrentImpl(boolean newCreated) throws GLException {
-    super.makeCurrentImpl(newCreated);
-    
-    if (newCreated) {
+  protected boolean createImpl(GLContextImpl shareWith) {
+    boolean res = super.createImpl(shareWith);
+    if(res) {  
       // Initialize render-to-texture support if requested
       final GL gl = getGL();
       final MacOSXPbufferCGLDrawable osxPDrawable = (MacOSXPbufferCGLDrawable)drawable;
@@ -81,6 +82,7 @@ public class MacOSXPbufferCGLContext extends MacOSXCGLContext {
                       0, GL.GL_RGB, GL.GL_UNSIGNED_BYTE, null);
       gl.glCopyTexSubImage2D(textureTarget, 0, 0, 0, 0, 0, drawable.getWidth(), drawable.getHeight());
     }
+    return res;
   }
 
   public int getFloatingPointMode() {
-- 
cgit v1.2.3