From 7dff8e2e043bb5e7606b041f8d4b4ae7c1579085 Mon Sep 17 00:00:00 2001 From: Sven Gothel Date: Sun, 6 Nov 2011 04:47:08 +0100 Subject: JOGL/Offscreen-Drawable: Use setRealized(boolean) protocol for offscreen/pbuffer This allows allowing updateHandle()/destroyHandle() to be called. --- .../windows/wgl/WindowsPbufferWGLDrawable.java | 27 +++++++++++++--------- 1 file changed, 16 insertions(+), 11 deletions(-) (limited to 'src/jogl/classes/jogamp/opengl/windows/wgl/WindowsPbufferWGLDrawable.java') 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(); -- cgit v1.2.3