summaryrefslogtreecommitdiffstats
path: root/src/jogl/classes/com/jogamp/opengl/impl
diff options
context:
space:
mode:
authorSven Gothel <[email protected]>2010-12-10 05:26:01 +0100
committerSven Gothel <[email protected]>2010-12-10 05:26:01 +0100
commit653c3e06812f49da8e9223af1f17ea34eac60805 (patch)
treea5b02ef575f154926ec44cdf0158335341ebad50 /src/jogl/classes/com/jogamp/opengl/impl
parent0a6a592c04a85d8124aa9d38b67f0caa1d739b75 (diff)
WGL/DummyWindow: Roll back GetDC/ReleaseDC via lock/unlock surface, redundant, since it's static DC
Diffstat (limited to 'src/jogl/classes/com/jogamp/opengl/impl')
-rw-r--r--src/jogl/classes/com/jogamp/opengl/impl/windows/wgl/WindowsDummyWGLDrawable.java80
1 files changed, 26 insertions, 54 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 3cbdcd021..920000bf1 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
@@ -60,23 +60,37 @@ public class WindowsDummyWGLDrawable extends WindowsWGLDrawable {
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());
+ }
ProxySurface ns = (ProxySurface) getNativeSurface();
ns.setSize(f_dim, f_dim);
-
- if(NativeSurface.LOCK_SURFACE_NOT_READY >= lockSurface()) {
- throw new GLException("WindowsDummyWGLDrawable: surface not ready (lockSurface)");
- }
+
+ WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)ns.getGraphicsConfiguration().getNativeGraphicsConfiguration();
+ AbstractGraphicsDevice adevice = config.getScreen().getDevice();
+ adevice.lock();
try {
- WindowsWGLGraphicsConfiguration config = (WindowsWGLGraphicsConfiguration)ns.getGraphicsConfiguration().getNativeGraphicsConfiguration();
- config.updateGraphicsConfiguration(factory, ns, null);
- if (DEBUG) {
- System.err.println("!!! WindowsDummyWGLDrawable: "+config);
+ 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();
}
- } catch (Throwable t) {
- destroyImpl();
- throw new GLException(t);
} finally {
- unlockSurface();
+ adevice.unlock();
}
}
@@ -89,48 +103,6 @@ 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 && 0 != hwnd && 0 == hdc) {
- hdc = GDI.GetDC(hwnd);
- ns.setSurfaceHandle(hdc);
- if(0 == hdc) {
- throw new GLException("Error hdc 0, werr: "+GDI.GetLastError());
- }
- } 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) {
}