aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes
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
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')
-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
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java16
-rw-r--r--src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java27
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java12
-rw-r--r--src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXDrawable.java16
7 files changed, 74 insertions, 42 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();
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java
index b2c95de39..afa4da2f8 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsBitmapWGLDrawable.java
@@ -57,15 +57,19 @@ public class WindowsBitmapWGLDrawable extends WindowsWGLDrawable {
private long hbitmap;
protected WindowsBitmapWGLDrawable(GLDrawableFactory factory, NativeSurface target) {
- super(factory, target, true);
- create();
+ super(factory, target, false);
+ setRealized(true);
}
+ protected void destroyImpl() {
+ setRealized(false);
+ }
+
protected void setRealizedImpl() {
if(realized) {
- create();
+ createBitmap();
} else {
- destroyImpl();
+ destroyBitmap();
}
}
@@ -73,7 +77,7 @@ public class WindowsBitmapWGLDrawable extends WindowsWGLDrawable {
return new WindowsBitmapWGLContext(this, shareWith);
}
- private void create() {
+ private void createBitmap() {
int werr;
NativeSurface ns = getNativeSurface();
if(DEBUG) {
@@ -153,7 +157,7 @@ public class WindowsBitmapWGLDrawable extends WindowsWGLDrawable {
config.updateGraphicsConfiguration(getFactory(), ns, null);
}
- protected void destroyImpl() {
+ protected void destroyBitmap() {
NativeSurface ns = getNativeSurface();
if (ns.getSurfaceHandle() != 0) {
// Must destroy bitmap and device context
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java
index 7be2c1ac7..74aa57a94 100644
--- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java
@@ -51,6 +51,7 @@ import javax.media.opengl.GLProfile;
import jogamp.nativewindow.windows.GDI;
import jogamp.opengl.GLDrawableImpl;
+import jogamp.opengl.windows.wgl.WindowsWGLDrawableFactory.SharedResource;
import javax.media.opengl.GLCapabilitiesImmutable;
@@ -60,27 +61,30 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
private long buffer; // pbuffer handle
private int floatMode;
-
- protected WindowsPbufferWGLDrawable(GLDrawableFactory factory, NativeSurface target,
- WindowsWGLDrawableFactory.SharedResource sharedResource) {
- super(factory, target, true);
-
+
+ protected WindowsPbufferWGLDrawable(GLDrawableFactory factory, NativeSurface target) {
+ super(factory, target, false);
+
if (DEBUG) {
System.out.println("Pbuffer config: " + getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration());
}
- createPbuffer(sharedResource);
+ setRealized(true);
if (DEBUG) {
System.err.println("Created pbuffer " + this);
}
}
+ protected void destroyImpl() {
+ setRealized(false);
+ }
+
protected void setRealizedImpl() {
if(realized) {
- throw new GLException("Recreation via setRealized not supported.");
+ createPbuffer();
} else {
- destroyImpl();
+ destroyPbuffer();
}
}
@@ -88,7 +92,7 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
return new WindowsPbufferWGLContext(this, shareWith);
}
- protected void destroyImpl() {
+ protected void destroyPbuffer() {
NativeSurface ns = getNativeSurface();
if(0!=buffer) {
WGLExt wglExt = cachedWGLExt;
@@ -126,7 +130,9 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
}
}
- private void createPbuffer(WindowsWGLDrawableFactory.SharedResource sharedResource) {
+ private void createPbuffer() {
+ WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration) getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
+ SharedResource sharedResource = ((WindowsWGLDrawableFactory)factory).getOrCreateSharedResource(config.getScreen().getDevice());
long parentHdc = sharedResource.getDrawable().getNativeSurface().getSurfaceHandle();
WGLExt wglExt = sharedResource.getContext().getWGLExt();
@@ -136,7 +142,6 @@ public class WindowsPbufferWGLDrawable extends WindowsWGLDrawable {
int niattribs = 0;
int width, height;
- WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration) getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration();
GLCapabilitiesImmutable chosenCaps = (GLCapabilitiesImmutable)config.getChosenCapabilities();
GLProfile glProfile = chosenCaps.getGLProfile();
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java
index 8ea989267..8c276c097 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11PbufferGLXDrawable.java
@@ -48,24 +48,28 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
/* GLCapabilities caps,
GLCapabilitiesChooser chooser,
int width, int height */
- super(factory, target, true);
+ super(factory, target, false);
if (DEBUG) {
System.out.println("Pbuffer config: " + getNativeSurface().getGraphicsConfiguration().getNativeGraphicsConfiguration());
}
- createPbuffer();
+ setRealized(true);
if (DEBUG) {
System.err.println("Created pbuffer " + this);
}
}
+ protected void destroyImpl() {
+ setRealized(false);
+ }
+
protected void setRealizedImpl() {
if(realized) {
createPbuffer();
} else {
- destroyImpl();
+ destroyPbuffer();
}
}
@@ -73,7 +77,7 @@ public class X11PbufferGLXDrawable extends X11GLXDrawable {
return new X11PbufferGLXContext(this, shareWith);
}
- protected void destroyImpl() {
+ protected void destroyPbuffer() {
NativeSurface ns = getNativeSurface();
if (ns.getSurfaceHandle() != 0) {
GLX.glXDestroyPbuffer(ns.getDisplayHandle(), ns.getSurfaceHandle());
diff --git a/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXDrawable.java b/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXDrawable.java
index f5d321561..486196856 100644
--- a/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXDrawable.java
+++ b/src/jogl/classes/jogamp/opengl/x11/glx/X11PixmapGLXDrawable.java
@@ -48,15 +48,19 @@ public class X11PixmapGLXDrawable extends X11GLXDrawable {
private long pixmap;
protected X11PixmapGLXDrawable(GLDrawableFactory factory, NativeSurface target) {
- super(factory, target, true);
- create();
+ super(factory, target, false);
+ setRealized(true);
}
+ protected void destroyImpl() {
+ setRealized(false);
+ }
+
protected void setRealizedImpl() {
if(realized) {
- create();
+ createPixmap();
} else {
- destroyImpl();
+ destroyPixmap();
}
}
@@ -64,7 +68,7 @@ public class X11PixmapGLXDrawable extends X11GLXDrawable {
return new X11PixmapGLXContext(this, shareWith);
}
- private void create() {
+ private void createPixmap() {
NativeSurface ns = getNativeSurface();
X11GLXGraphicsConfiguration config = (X11GLXGraphicsConfiguration) ns.getGraphicsConfiguration().getNativeGraphicsConfiguration();
XVisualInfo vis = config.getXVisualInfo();
@@ -93,7 +97,7 @@ public class X11PixmapGLXDrawable extends X11GLXDrawable {
}
}
- protected void destroyImpl() {
+ protected void destroyPixmap() {
if (pixmap == 0) return;
NativeSurface ns = getNativeSurface();