diff options
Diffstat (limited to 'src/jogl')
3 files changed, 72 insertions, 32 deletions
diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java index 920000bf1..9a93f6b33 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java @@ -65,32 +65,21 @@ public class WindowsDummyWGLDrawable extends WindowsWGLDrawable { } ProxySurface ns = (ProxySurface) getNativeSurface(); ns.setSize(f_dim, f_dim); - - WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)ns.getGraphicsConfiguration().getNativeGraphicsConfiguration(); - AbstractGraphicsDevice adevice = config.getScreen().getDevice(); - adevice.lock(); + + if(NativeSurface.LOCK_SURFACE_NOT_READY >= lockSurface()) { + throw new GLException("WindowsDummyWGLDrawable: surface not ready (lockSurface)"); + } try { - if(NativeSurface.LOCK_SURFACE_NOT_READY >= ns.lockSurface()) { - throw new GLException("WindowsDummyWGLDrawable: surface not ready (lockSurface)"); - } - try { - hdc = GDI.GetDC(hwnd); - if(0 == hdc) { - throw new GLException("Error hdc 0, werr: "+GDI.GetLastError()); - } - ns.setSurfaceHandle(hdc); - config.updateGraphicsConfiguration(factory, ns, null); - if (DEBUG) { - System.err.println("!!! WindowsDummyWGLDrawable: hdc "+toHexString(hdc)+", "+config); - } - } catch (Throwable t) { - destroyImpl(); - throw new GLException(t); - } finally { - ns.unlockSurface(); + WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)ns.getGraphicsConfiguration().getNativeGraphicsConfiguration(); + config.updateGraphicsConfiguration(factory, ns, null); + if (DEBUG) { + System.err.println("!!! WindowsDummyWGLDrawable: "+config); } + } catch (Throwable t) { + destroyImpl(); + throw new GLException(t); } finally { - adevice.unlock(); + unlockSurface(); } } @@ -103,6 +92,53 @@ public class WindowsDummyWGLDrawable extends WindowsWGLDrawable { return new WindowsDummyWGLDrawable(factory, caps, absScreen); } + public int lockSurface() throws GLException { + int res = NativeSurface.LOCK_SURFACE_NOT_READY; + ProxySurface ns = (ProxySurface) getNativeSurface(); + AbstractGraphicsDevice adevice = ns.getGraphicsConfiguration().getNativeGraphicsConfiguration().getScreen().getDevice(); + adevice.lock(); + try { + res = ns.lockSurface(); + if(NativeSurface.LOCK_SUCCESS == res) { + if(0 == hdc) { + hdc = GDI.GetDC(hwnd); + ns.setSurfaceHandle(hdc); + if(0 == hdc) { + res = NativeSurface.LOCK_SURFACE_NOT_READY; + ns.unlockSurface(); + throw new GLException("Error hdc 0, werr: "+GDI.GetLastError()); + // finally will unlock adevice + } + } + } else { + Throwable t = new Throwable("Error lock failed - res "+res+", hwnd "+toHexString(hwnd)+", hdc "+toHexString(hdc)); + t.printStackTrace(); + } + } finally { + if( NativeSurface.LOCK_SURFACE_NOT_READY == res ) { + adevice.unlock(); + } + } + return res; + } + + public void unlockSurface() { + ProxySurface ns = (ProxySurface) getNativeSurface(); + ns.validateSurfaceLocked(); + AbstractGraphicsDevice adevice = ns.getGraphicsConfiguration().getNativeGraphicsConfiguration().getScreen().getDevice(); + + try { + if ( 0 != hdc && 0 != hwnd && ns.getSurfaceRecursionCount() == 0) { + GDI.ReleaseDC(hwnd, hdc); + hdc=0; + ns.setSurfaceHandle(hdc); + } + surface.unlockSurface(); + } finally { + adevice.unlock(); + } + } + public void setSize(int width, int height) { } @@ -128,7 +164,7 @@ public class WindowsDummyWGLDrawable extends WindowsWGLDrawable { } if (hwnd != 0) { GDI.ShowWindow(hwnd, GDI.SW_HIDE); - GDI.DestroyWindow(hwnd); + GDI.DestroyDummyWindow(hwnd); hwnd = 0; } } diff --git a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java index 4d687a00c..eb6db0a50 100644 --- a/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java +++ b/src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsWGLDrawableFactory.java @@ -45,8 +45,6 @@ import java.nio.ShortBuffer; import java.util.ArrayList; import java.util.Collection; import java.util.HashMap; -import java.util.HashSet; -import java.util.Iterator; import java.util.List; import javax.media.nativewindow.AbstractGraphicsDevice; @@ -72,6 +70,7 @@ import com.jogamp.opengl.impl.GLDrawableImpl; import com.jogamp.opengl.impl.GLDynamicLookupHelper; import com.jogamp.opengl.impl.SharedResourceRunner; import javax.media.nativewindow.AbstractGraphicsConfiguration; +import javax.media.nativewindow.windows.RegisteredClassFactory; import javax.media.opengl.GLCapabilitiesImmutable; public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { @@ -195,11 +194,16 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { throw new GLException("Couldn't create shared context for drawable: "+sharedDrawable); } sharedContext.setSynchronized(true); + boolean canCreateGLPbuffer; + boolean readDrawableAvailable; sharedContext.makeCurrent(); - boolean canCreateGLPbuffer = sharedContext.getGL().isExtensionAvailable(GL_ARB_pbuffer); - boolean readDrawableAvailable = sharedContext.isExtensionAvailable(WGL_ARB_make_current_read) && - sharedContext.isFunctionAvailable(wglMakeContextCurrent); - sharedContext.release(); + try { + canCreateGLPbuffer = sharedContext.getGL().isExtensionAvailable(GL_ARB_pbuffer); + readDrawableAvailable = sharedContext.isExtensionAvailable(WGL_ARB_make_current_read) && + sharedContext.isFunctionAvailable(wglMakeContextCurrent); + } finally { + sharedContext.release(); + } if (DEBUG) { System.err.println("!!! SharedDevice: " + sharedDevice); System.err.println("!!! SharedScreen: " + absScreen); @@ -231,7 +235,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { } if (null != sr.drawable) { - // may cause JVM SIGSEGV: sharedDrawable.destroy(); + sr.drawable.destroy(); sr.drawable = null; } @@ -287,6 +291,7 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { protected final void shutdownInstance() { sharedResourceRunner.releaseAndWait(); + RegisteredClassFactory.shutdownSharedClasses(); } protected final GLDrawableImpl createOnscreenDrawableImpl(NativeSurface target) { diff --git a/src/jogl/classes/javax/media/opengl/awt/AWTGLAutoDrawable.java b/src/jogl/classes/javax/media/opengl/awt/AWTGLAutoDrawable.java index d92cec389..d1e725b00 100644 --- a/src/jogl/classes/javax/media/opengl/awt/AWTGLAutoDrawable.java +++ b/src/jogl/classes/javax/media/opengl/awt/AWTGLAutoDrawable.java @@ -40,7 +40,6 @@ package javax.media.opengl.awt; import javax.media.opengl.*; -import javax.media.opengl.glu.*; public interface AWTGLAutoDrawable extends GLAutoDrawable, ComponentEvents { /** Requests a new width and height for this AWTGLAutoDrawable. */ |