diff options
-rw-r--r-- | src/net/java/games/jogl/impl/windows/WindowsOnscreenGLDrawable.java | 15 |
1 files changed, 13 insertions, 2 deletions
diff --git a/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLDrawable.java b/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLDrawable.java index 479e8586d..7c385d4b2 100644 --- a/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLDrawable.java +++ b/src/net/java/games/jogl/impl/windows/WindowsOnscreenGLDrawable.java @@ -94,11 +94,22 @@ public class WindowsOnscreenGLDrawable extends WindowsGLDrawable { } public void swapBuffers() throws GLException { - // FIXME: currently must do this while the surface is locked - // (i.e., a context is current); fix and/or specify this? + boolean didLock = false; + + if (hdc == 0) { + if (lockSurface() == LOCK_SURFACE_NOT_READY) { + return; + } + didLock = true; + } + if (!WGL.SwapBuffers(hdc) && (WGL.GetLastError() != 0)) { throw new GLException("Error swapping buffers"); } + + if (didLock) { + unlockSurface(); + } } public int lockSurface() throws GLException { |