aboutsummaryrefslogtreecommitdiffstats
path: root/src/jogl/classes
diff options
context:
space:
mode:
Diffstat (limited to 'src/jogl/classes')
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOnscreenWGLDrawable.java56
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java82
-rw-r--r--src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java8
3 files changed, 82 insertions, 64 deletions
diff --git a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOnscreenWGLDrawable.java b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOnscreenWGLDrawable.java
index 32e786a2b..a5ccec377 100644
--- a/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOnscreenWGLDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/windows/wgl/WindowsOnscreenWGLDrawable.java
@@ -72,36 +72,38 @@ public class WindowsOnscreenWGLDrawable extends WindowsWGLDrawable {
public void swapBuffers() throws GLException {
boolean didLock = false;
- if (getNativeWindow().getSurfaceHandle() == 0) {
- if (lockSurface() == NativeWindow.LOCK_SURFACE_NOT_READY) {
- return;
- }
- didLock = true;
- }
+ try {
+ if (getNativeWindow().getSurfaceHandle() == 0) {
+ if (lockSurface() == NativeWindow.LOCK_SURFACE_NOT_READY) {
+ return;
+ }
+ didLock = true;
+ }
- long startTime = 0;
- if (PROFILING) {
- startTime = System.currentTimeMillis();
- }
+ long startTime = 0;
+ if (PROFILING) {
+ startTime = System.currentTimeMillis();
+ }
- if (!WGL.SwapBuffers(getNativeWindow().getSurfaceHandle()) && (WGL.GetLastError() != 0)) {
- throw new GLException("Error swapping buffers");
- }
-
- if (PROFILING) {
- long endTime = System.currentTimeMillis();
- profilingSwapBuffersTime += (endTime - startTime);
- int ticks = PROFILING_TICKS;
- if (++profilingSwapBuffersTicks == ticks) {
- System.err.println("SwapBuffers calls: " + profilingSwapBuffersTime + " ms / " + ticks + " calls (" +
- ((float) profilingSwapBuffersTime / (float) ticks) + " ms/call)");
- profilingSwapBuffersTime = 0;
- profilingSwapBuffersTicks = 0;
- }
- }
+ if (!WGL.SwapBuffers(getNativeWindow().getSurfaceHandle()) && (WGL.GetLastError() != 0)) {
+ throw new GLException("Error swapping buffers");
+ }
- if (didLock) {
- unlockSurface();
+ if (PROFILING) {
+ long endTime = System.currentTimeMillis();
+ profilingSwapBuffersTime += (endTime - startTime);
+ int ticks = PROFILING_TICKS;
+ if (++profilingSwapBuffersTicks == ticks) {
+ System.err.println("SwapBuffers calls: " + profilingSwapBuffersTime + " ms / " + ticks + " calls (" +
+ ((float) profilingSwapBuffersTime / (float) ticks) + " ms/call)");
+ profilingSwapBuffersTime = 0;
+ profilingSwapBuffersTicks = 0;
+ }
+ }
+ } finally {
+ if (didLock) {
+ unlockSurface();
+ }
}
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
index bb284d60f..661fa9fcb 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11GLXDrawableFactory.java
@@ -212,13 +212,17 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
int[] size = new int[1];
lockToolkit();
- long display = X11Util.getDisplayConnection();
- boolean res = X11Lib.XF86VidModeGetGammaRampSize(display,
- X11Lib.DefaultScreen(display),
- size, 0);
- unlockToolkit();
- if (!res)
- return 0;
+ try {
+ long display = X11Util.getDisplayConnection();
+ boolean res = X11Lib.XF86VidModeGetGammaRampSize(display,
+ X11Lib.DefaultScreen(display),
+ size, 0);
+ if (!res) {
+ return 0;
+ }
+ } finally {
+ unlockToolkit();
+ }
gotGammaRampLength = true;
gammaRampLength = size[0];
return gammaRampLength;
@@ -232,15 +236,18 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
}
lockToolkit();
- long display = X11Util.getDisplayConnection();
- boolean res = X11Lib.XF86VidModeSetGammaRamp(display,
- X11Lib.DefaultScreen(display),
- rampData.length,
- rampData, 0,
- rampData, 0,
- rampData, 0);
- unlockToolkit();
- return res;
+ try {
+ long display = X11Util.getDisplayConnection();
+ boolean res = X11Lib.XF86VidModeSetGammaRamp(display,
+ X11Lib.DefaultScreen(display),
+ rampData.length,
+ rampData, 0,
+ rampData, 0,
+ rampData, 0);
+ return res;
+ } finally {
+ unlockToolkit();
+ }
}
protected Buffer getGammaRamp() {
@@ -256,16 +263,20 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
rampData.limit(3 * size);
ShortBuffer blueRampData = rampData.slice();
lockToolkit();
- long display = X11Util.getDisplayConnection();
- boolean res = X11Lib.XF86VidModeGetGammaRamp(display,
- X11Lib.DefaultScreen(display),
- size,
- redRampData,
- greenRampData,
- blueRampData);
- unlockToolkit();
- if (!res)
- return null;
+ try {
+ long display = X11Util.getDisplayConnection();
+ boolean res = X11Lib.XF86VidModeGetGammaRamp(display,
+ X11Lib.DefaultScreen(display),
+ size,
+ redRampData,
+ greenRampData,
+ blueRampData);
+ if (!res) {
+ return null;
+ }
+ } finally {
+ unlockToolkit();
+ }
return rampData;
}
@@ -288,13 +299,16 @@ public class X11GLXDrawableFactory extends GLDrawableFactoryImpl {
rampData.limit(3 * size);
ShortBuffer blueRampData = rampData.slice();
lockToolkit();
- long display = X11Util.getDisplayConnection();
- X11Lib.XF86VidModeSetGammaRamp(display,
- X11Lib.DefaultScreen(display),
- size,
- redRampData,
- greenRampData,
- blueRampData);
- unlockToolkit();
+ try {
+ long display = X11Util.getDisplayConnection();
+ X11Lib.XF86VidModeSetGammaRamp(display,
+ X11Lib.DefaultScreen(display),
+ size,
+ redRampData,
+ greenRampData,
+ blueRampData);
+ } finally {
+ unlockToolkit();
+ }
}
}
diff --git a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java
index 6a42a53c4..b8f6cc7ef 100644
--- a/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java
+++ b/src/jogl/classes/com/sun/opengl/impl/x11/glx/X11OnscreenGLXDrawable.java
@@ -62,19 +62,21 @@ public class X11OnscreenGLXDrawable extends X11GLXDrawable {
}
public void swapBuffers() throws GLException {
- getFactoryImpl().lockToolkit();
+ boolean didLock = false;
try {
if (component.getSurfaceHandle() == 0) {
if (lockSurface() == NativeWindow.LOCK_SURFACE_NOT_READY) {
return;
}
+ didLock=true;
}
GLX.glXSwapBuffers(component.getDisplayHandle(), component.getSurfaceHandle());
} finally {
- unlockSurface();
- getFactoryImpl().unlockToolkit();
+ if(didLock) {
+ unlockSurface();
+ }
}
}
}