summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/jogamp/opengl/macosx/cgl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2011-11-06 04:47:08 +0100
committerSven Gothel <[email protected]>2011-11-06 04:47:08 +0100
commit7dff8e2e043bb5e7606b041f8d4b4ae7c1579085 (patch)
tree48d52d06b49912a7cd3643d73d34f31205f2bd49 /src/jogl/classes/jogamp/opengl/macosx/cgl
parentccb7213cdcef177eabf7538b7c0d1c3e34915640 (diff)
JOGL/Offscreen-Drawable: Use setRealized(boolean) protocol for offscreen/pbuffer
This allows allowing updateHandle()/destroyHandle() to be called.
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/macosx/cgl')
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java11
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOffscreenCGLDrawable.java2
-rw-r--r--src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java32
3 files changed, 30 insertions, 15 deletions
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
index 14af0a544..cbdff144f 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXCGLDrawableFactory.java
@@ -67,6 +67,7 @@ import jogamp.opengl.DesktopGLDynamicLookupHelper;
import jogamp.opengl.GLDrawableFactoryImpl;
import jogamp.opengl.GLDrawableImpl;
import jogamp.opengl.GLDynamicLookupHelper;
+import jogamp.opengl.GLGraphicsConfigurationUtil;
import com.jogamp.common.JogampRuntimeException;
import com.jogamp.common.util.ReflectionUtil;
@@ -244,6 +245,14 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
if (target == null) {
throw new IllegalArgumentException("Null target");
}
+ final MacOSXJAWTWindow lsh = MacOSXCGLDrawableFactory.getLayeredSurfaceHost(target);
+ if(null != lsh) {
+ // layered surface -> PBuffer
+ final MacOSXCGLGraphicsConfiguration config = (MacOSXCGLGraphicsConfiguration) target.getGraphicsConfiguration().getNativeGraphicsConfiguration();
+ final GLCapabilitiesImmutable chosenCaps = GLGraphicsConfigurationUtil.fixGLPBufferGLCapabilities((GLCapabilitiesImmutable) config.getChosenCapabilities());
+ config.setChosenCapabilities(chosenCaps);
+ return new MacOSXPbufferCGLDrawable(this, target, false);
+ }
return new MacOSXOnscreenCGLDrawable(this, target);
}
@@ -268,7 +277,7 @@ public class MacOSXCGLDrawableFactory extends GLDrawableFactoryImpl {
maybeDoSingleThreadedWorkaround(r);
return (GLDrawableImpl) returnList.get(0);
*/
- return new MacOSXPbufferCGLDrawable(this, target);
+ return new MacOSXPbufferCGLDrawable(this, target, true);
}
public boolean canCreateGLPbuffer(AbstractGraphicsDevice device) {
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOffscreenCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOffscreenCGLDrawable.java
index bec4cf32a..29a448980 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOffscreenCGLDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXOffscreenCGLDrawable.java
@@ -48,7 +48,7 @@ public class MacOSXOffscreenCGLDrawable extends MacOSXPbufferCGLDrawable {
public MacOSXOffscreenCGLDrawable(GLDrawableFactory factory,
NativeSurface target) {
- super(factory, target);
+ super(factory, target, true);
}
public GLContext createContext(GLContext shareWith) {
diff --git a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java
index ac76cfe6c..dd41be930 100644
--- a/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/macosx/cgl/MacOSXPbufferCGLDrawable.java
@@ -77,25 +77,31 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable {
// semantic is that contains an NSView
protected long pBuffer;
- public MacOSXPbufferCGLDrawable(GLDrawableFactory factory, NativeSurface target) {
- super(factory, target, true);
+ public MacOSXPbufferCGLDrawable(GLDrawableFactory factory, NativeSurface target, boolean realizeNow) {
+ super(factory, target, false);
if (DEBUG) {
System.out.println("Pbuffer config: " + getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration());
}
- createPbuffer();
+ if(realizeNow) {
+ setRealized(true);
+ }
if (DEBUG) {
System.err.println("Created pbuffer " + this);
}
}
+ protected void destroyImpl() {
+ setRealized(false);
+ }
+
protected void setRealizedImpl() {
if(realized) {
createPbuffer();
} else {
- destroyImpl();
+ destroyPbuffer();
}
}
@@ -103,15 +109,6 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable {
return new MacOSXPbufferCGLContext(this, shareWith);
}
- protected void destroyImpl() {
- if (this.pBuffer != 0) {
- NativeSurface ns = getNativeSurface();
- impl.destroy(pBuffer);
- this.pBuffer = 0;
- ((SurfaceChangeable)ns).setSurfaceHandle(0);
- }
- }
-
@Override
protected long getNSViewHandle() {
// pbuffer handle is NSOpenGLPixelBuffer
@@ -129,6 +126,15 @@ public class MacOSXPbufferCGLDrawable extends MacOSXCGLDrawable {
}
}
+ protected void destroyPbuffer() {
+ if (this.pBuffer != 0) {
+ NativeSurface ns = getNativeSurface();
+ impl.destroy(pBuffer);
+ this.pBuffer = 0;
+ ((SurfaceChangeable)ns).setSurfaceHandle(0);
+ }
+ }
+
private void createPbuffer() {
NativeSurface ns = getNativeSurface();
DefaultGraphicsConfiguration config = (DefaultGraphicsConfiguration) ns.getGraphicsConfiguration().getNativeGraphicsConfiguration();