diff options
author | Sven Gothel <[email protected]> | 2012-07-20 15:44:00 +0200 |
---|---|---|
committer | Sven Gothel <[email protected]> | 2012-07-20 15:44:00 +0200 |
commit | 72785ac35aa7c95bc675f3d773c6a7764b5b0ddc (patch) | |
tree | 9b8138a7a6b1bf69002395822cdaeae3962d1bf0 /src/jogl/classes/jogamp/opengl/macosx | |
parent | 06b6a74f4915a539f6025112a82e517d8e8cb7af (diff) |
Fix OSX regression of commit 20bf031db719f7baa4c6e74734fc999061e08fe2 - handling w/ non NSView handles (pbuffer)
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/macosx')
3 files changed, 26 insertions, 1 deletions
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java index 4bf2a3c9d..cb79e1560 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLContext.java @@ -54,6 +54,7 @@ import javax.media.opengl.GLContext; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; +import jogamp.nativewindow.macosx.OSXUtil; import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableImpl; import jogamp.opengl.GLGraphicsConfigurationUtil; @@ -430,6 +431,19 @@ public abstract class MacOSXCGLContext extends GLContextImpl @Override public long create(long share, int ctp, int major, int minor) { long ctx = 0; + final long nsViewHandle; + if(drawable instanceof MacOSXCGLDrawable) { + // we allow null here! (special pbuffer case) + nsViewHandle = ((MacOSXCGLDrawable)MacOSXCGLContext.this.drawable).getNSViewHandle(); + } else { + // we only allow a valid NSView here + final long aHandle = drawable.getHandle(); + if( OSXUtil.isNSView(aHandle) ) { + nsViewHandle = aHandle; + } else { + throw new RuntimeException("Anonymous drawable instance's handle not of type NSView: "+drawable.getClass().getName()+", "+drawable); + } + } final NativeSurface surface = drawable.getNativeSurface(); final MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) surface.getGraphicsConfiguration(); final OffscreenLayerSurface backingLayerHost = NativeWindowFactory.getOffscreenLayerSurface(surface, true); @@ -456,6 +470,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl System.err.println("NS create chosenCaps: "+chosenCaps); System.err.println("NS create pixelFormat: "+toHexString(pixelFormat)); System.err.println("NS create drawable native-handle: "+toHexString(drawable.getHandle())); + System.err.println("NS create drawable NSView-handle: "+toHexString(nsViewHandle)); System.err.println("NS create screen refresh-rate: "+sRefreshRate+" hz, "+screenVSyncTimeout+" micros"); // Thread.dumpStack(); } @@ -463,7 +478,7 @@ public abstract class MacOSXCGLContext extends GLContextImpl int[] viewNotReady = new int[1]; // Try to allocate a context with this ctx = CGL.createContext(share, - drawable.getHandle(), allowIncompleteView, + nsViewHandle, allowIncompleteView, pixelFormat, chosenCaps.isBackgroundOpaque(), viewNotReady, 0); diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java index 841edb2b0..af767f0c3 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawable.java @@ -105,6 +105,10 @@ public abstract class MacOSXCGLDrawable extends GLDrawableImpl { @Override protected void setRealizedImpl() { } + + protected long getNSViewHandle() { + return GLBackendType.NSOPENGL == openGLMode ? getHandle() : 0; + } protected void registerContext(MacOSXCGLContext ctx) { // NOTE: we need to keep track of the created contexts in order to diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java index b144c020d..8f2f386af 100644 --- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java @@ -94,6 +94,12 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable { registerContext(ctx); return ctx; } + + @Override + protected long getNSViewHandle() { + // pbuffer handle is NSOpenGLPixelBuffer + return 0; + } @Override public long getHandle() { |