diff options
Diffstat (limited to 'src/jogl/classes/jogamp/opengl/windows/wgl')
3 files changed, 27 insertions, 92 deletions
diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsDummyWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsDummyWGLDrawable.java index 27d7b342e..3d0cce725 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsDummyWGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsDummyWGLDrawable.java @@ -45,29 +45,21 @@ import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLProfile; import javax.media.nativewindow.AbstractGraphicsScreen; -import jogamp.nativewindow.ProxySurface; import jogamp.nativewindow.windows.GDI; -import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.NativeSurface; import javax.media.opengl.GLCapabilities; -import javax.media.opengl.GLCapabilitiesImmutable; import javax.media.opengl.GLException; +import jogamp.nativewindow.windows.GDISurface; public class WindowsDummyWGLDrawable extends WindowsWGLDrawable { - private static final int f_dim = 64; - private long hwnd, hdc; + private long hwnd; + private boolean handleHwndLifecycle; - protected WindowsDummyWGLDrawable(GLDrawableFactory factory, GLCapabilitiesImmutable caps, AbstractGraphicsScreen absScreen) { - super(factory, new ProxySurface(WindowsWGLGraphicsConfigurationFactory.createDefaultGraphicsConfiguration(caps, absScreen)), true); - hwnd = GDI.CreateDummyWindow(0, 0, f_dim, f_dim); - if(0 == hwnd) { - throw new GLException("Error hwnd 0, werr: "+GDI.GetLastError()); - } - // manual debug only - GDI.ShowWindow(hwnd, GDI.SW_SHOW); - ProxySurface ns = (ProxySurface) getNativeSurface(); - ns.setSize(f_dim, f_dim); + private WindowsDummyWGLDrawable(GLDrawableFactory factory, GDISurface ns, boolean handleHwndLifecycle) { + super(factory, ns, true); + this.handleHwndLifecycle = handleHwndLifecycle; - if(NativeSurface.LOCK_SURFACE_NOT_READY >= lockSurface()) { + if(NativeSurface.LOCK_SURFACE_NOT_READY >= ns.lockSurface()) { throw new GLException("WindowsDummyWGLDrawable: surface not ready (lockSurface)"); } try { @@ -84,70 +76,16 @@ public class WindowsDummyWGLDrawable extends WindowsWGLDrawable { } } - public static WindowsDummyWGLDrawable create(GLDrawableFactory factory, GLProfile glp, AbstractGraphicsScreen absScreen) { - GLCapabilities caps = new GLCapabilities(glp); - caps.setDepthBits(16); - caps.setDoubleBuffered(true); - caps.setOnscreen (true); - 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(); - } + public static WindowsDummyWGLDrawable create(GLDrawableFactory factory, GLProfile glp, AbstractGraphicsScreen absScreen, + long windowHandle, int width, int height, boolean handleWindowLifecycle) { + if(0 == windowHandle) { + throw new GLException("Error windowHandle 0, werr: "+GDI.GetLastError()); } - 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) { - } - - public int getWidth() { - return 1; - } - - public int getHeight() { - return 1; + GLCapabilities caps = new GLCapabilities(glp); + WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfigurationFactory.createDefaultGraphicsConfiguration(caps, absScreen); + GDISurface ns = new GDISurface(cfg, windowHandle); + ns.setSize(width, height); + return new WindowsDummyWGLDrawable(factory, ns, handleWindowLifecycle); } public GLContext createContext(GLContext shareWith) { @@ -156,13 +94,7 @@ public class WindowsDummyWGLDrawable extends WindowsWGLDrawable { } protected void destroyImpl() { - if (hdc != 0) { - GDI.ReleaseDC(hwnd, hdc); - hdc = 0; - ProxySurface ns = (ProxySurface) getNativeSurface(); - ns.setSurfaceHandle(hdc); - } - if (hwnd != 0) { + if (handleHwndLifecycle && hwnd != 0) { GDI.ShowWindow(hwnd, GDI.SW_HIDE); GDI.DestroyDummyWindow(hwnd); hwnd = 0; diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java index 742a42709..7666ae350 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsExternalWGLDrawable.java @@ -49,7 +49,7 @@ import javax.media.opengl.GLDrawableFactory; import javax.media.opengl.GLException; import javax.media.opengl.GLProfile; -import jogamp.nativewindow.ProxySurface; +import jogamp.nativewindow.WrappedSurface; import jogamp.nativewindow.windows.GDI; public class WindowsExternalWGLDrawable extends WindowsWGLDrawable { @@ -70,7 +70,7 @@ public class WindowsExternalWGLDrawable extends WindowsWGLDrawable { AbstractGraphicsScreen aScreen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_WINDOWS); WindowsWGLGraphicsConfiguration cfg = WindowsWGLGraphicsConfiguration.createFromCurrent(factory, hdc, pfdID, glp, aScreen, true); - return new WindowsExternalWGLDrawable(factory, new ProxySurface(cfg, hdc)); + return new WindowsExternalWGLDrawable(factory, new WrappedSurface(cfg, hdc)); } diff --git a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java index 2c078dd98..5afbb9218 100644 --- a/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java +++ b/src/jogl/classes/jogamp/opengl/windows/wgl/WindowsWGLDrawableFactory.java @@ -51,6 +51,7 @@ import javax.media.nativewindow.AbstractGraphicsDevice; import javax.media.nativewindow.AbstractGraphicsScreen; import javax.media.nativewindow.DefaultGraphicsScreen; import javax.media.nativewindow.NativeSurface; +import javax.media.nativewindow.ProxySurface; import javax.media.nativewindow.NativeWindowFactory; import javax.media.nativewindow.windows.WindowsGraphicsDevice; import javax.media.nativewindow.AbstractGraphicsConfiguration; @@ -64,11 +65,11 @@ import javax.media.opengl.GLProfile; import com.jogamp.common.JogampRuntimeException; import com.jogamp.common.nio.PointerBuffer; import com.jogamp.common.util.ReflectionUtil; -import jogamp.nativewindow.ProxySurface; +import jogamp.nativewindow.WrappedSurface; import jogamp.nativewindow.windows.GDI; +import jogamp.nativewindow.windows.GDISurface; import jogamp.nativewindow.windows.RegisteredClassFactory; import jogamp.opengl.DesktopGLDynamicLookupHelper; -import jogamp.opengl.GLContextImpl; import jogamp.opengl.GLDrawableFactoryImpl; import jogamp.opengl.GLDrawableImpl; import jogamp.opengl.GLDynamicLookupHelper; @@ -228,7 +229,9 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { if (null == glp) { throw new GLException("Couldn't get default GLProfile for device: "+sharedDevice); } - WindowsDummyWGLDrawable sharedDrawable = WindowsDummyWGLDrawable.create(WindowsWGLDrawableFactory.this, glp, absScreen); + final int f_dim = 64; + long hwnd = GDI.CreateDummyWindow(0, 0, f_dim, f_dim); + WindowsDummyWGLDrawable sharedDrawable = WindowsDummyWGLDrawable.create(WindowsWGLDrawableFactory.this, glp, absScreen, hwnd, f_dim, f_dim, true); if (null == sharedDrawable) { throw new GLException("Couldn't create shared drawable for screen: "+absScreen+", "+glp); } @@ -434,9 +437,9 @@ public class WindowsWGLDrawableFactory extends GLDrawableFactoryImpl { return false; } - protected final NativeSurface createOffscreenSurfaceImpl(AbstractGraphicsDevice device,GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, int width, int height) { + protected final NativeSurface createOffscreenSurfaceImpl(AbstractGraphicsDevice device, GLCapabilitiesImmutable capsChosen, GLCapabilitiesImmutable capsRequested, GLCapabilitiesChooser chooser, int width, int height) { AbstractGraphicsScreen screen = DefaultGraphicsScreen.createDefault(NativeWindowFactory.TYPE_WINDOWS); - ProxySurface ns = new ProxySurface(WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic( + WrappedSurface ns = new WrappedSurface(WindowsWGLGraphicsConfigurationFactory.chooseGraphicsConfigurationStatic( capsChosen, capsRequested, chooser, screen) ); ns.setSize(width, height); return ns; |