diff options
author | Sven Gothel <[email protected]> | 2011-11-06 07:36:35 +0100 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2011-11-06 07:36:35 +0100 |
commit | 0038e2d41825c22bdd18a7b86a8229a3fab674a3 (patch) | |
tree | b36bf1f7a16c234596a8d5abc7ac58b8c5e2d1ba /src/jogl/classes/jogamp/opengl/macosx/cgl | |
parent | 7dff8e2e043bb5e7606b041f8d4b4ae7c1579085 (diff) |
JOGL *Drawable swapBufferImpl() cleanup: Don't force swap-buffer off for offscreen/pbuffer, but respect GLDrawableImpl's decision (double-buffer)
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/macosx/cgl')
3 files changed, 6 insertions, 47 deletions
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java index 08a531200..ba384fc71 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXExternalCGLContext.java @@ -48,7 +48,6 @@ import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; -import javax.media.opengl.GLProfile; import jogamp.nativewindow.WrappedSurface; import jogamp.opengl.GLContextShareSet; @@ -61,7 +60,7 @@ public class MacOSXExternalCGLContext extends MacOSXCGLContext { private MacOSXExternalCGLContext(Drawable drawable, boolean isNSContext, long handle) { super(drawable, null); setOpenGLMode(isNSContext ? GLBackendType.NSOPENGL : GLBackendType.CGL ); - drawable.setExternalCGLContext(this); + drawable.registerContext(this); this.contextHandle = handle; GLContextShareSet.contextCreated(this); setGLFunctionAvailability(false, true, 0, 0, CTX_PROFILE_COMPAT|CTX_OPTION_ANY); @@ -150,16 +149,10 @@ public class MacOSXExternalCGLContext extends MacOSXCGLContext { // Need to provide the display connection to extension querying APIs static class Drawable extends MacOSXCGLDrawable { - MacOSXExternalCGLContext extCtx; - Drawable(GLDrawableFactory factory, NativeSurface comp) { super(factory, comp, true); } - void setExternalCGLContext(MacOSXExternalCGLContext externalContext) { - extCtx = externalContext; - } - public GLContext createContext(GLContext shareWith) { throw new GLException("Should not call this"); } @@ -175,11 +168,5 @@ public class MacOSXExternalCGLContext extends MacOSXCGLContext { public void setSize(int width, int height) { throw new GLException("Should not call this"); } - - protected void swapBuffersImpl() { - if (extCtx != null) { - extCtx.swapBuffers(); - } - } } } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLDrawable.java index 2e1c24d91..c1f793c0b 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOnscreenCGLDrawable.java @@ -40,45 +40,21 @@ package jogamp.opengl.macosx.cgl; -import java.lang.ref.WeakReference; -import java.util.ArrayList; -import java.util.Iterator; -import java.util.List; - import javax.media.nativewindow.NativeSurface; import javax.media.opengl.GLContext; import javax.media.opengl.GLDrawableFactory; public class MacOSXOnscreenCGLDrawable extends MacOSXCGLDrawable { - private List<WeakReference<MacOSXCGLContext>> createdContexts = new ArrayList<WeakReference<MacOSXCGLContext>>(); protected MacOSXOnscreenCGLDrawable(GLDrawableFactory factory, NativeSurface component) { super(factory, component, false); } public GLContext createContext(GLContext shareWith) { - MacOSXOnscreenCGLContext ctx= new MacOSXOnscreenCGLContext(this, shareWith); - // NOTE: we need to keep track of the created contexts in order to - // implement swapBuffers() because of how Mac OS X implements its - // OpenGL window interface - synchronized (createdContexts) { - createdContexts.add(new WeakReference<MacOSXCGLContext>(ctx)); - } + final MacOSXOnscreenCGLContext ctx= new MacOSXOnscreenCGLContext(this, shareWith); + registerContext(ctx); return ctx; } - protected void swapBuffersImpl() { - synchronized (createdContexts) { - for (Iterator<WeakReference<MacOSXCGLContext>> iter = createdContexts.iterator(); iter.hasNext(); ) { - WeakReference<MacOSXCGLContext> ref = iter.next(); - MacOSXCGLContext ctx = ref.get(); - if (ctx != null) { - ctx.swapBuffers(); - } else { - iter.remove(); - } - } - } - } } diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java index dd41be930..525134f1e 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java @@ -106,7 +106,9 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { } public GLContext createContext(GLContext shareWith) { - return new MacOSXPbufferCGLContext(this, shareWith); + final MacOSXPbufferCGLContext ctx = new MacOSXPbufferCGLContext(this, shareWith); + registerContext(ctx); + return ctx; } @Override @@ -120,12 +122,6 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { return pBuffer; } - protected void swapBuffersImpl() { - if(DEBUG) { - System.err.println("unhandled swapBuffersImpl() called for: "+this); - } - } - protected void destroyPbuffer() { if (this.pBuffer != 0) { NativeSurface ns = getNativeSurface(); |