From 44120bea6928fded325a8100c9f4117b385964b6 Mon Sep 17 00:00:00 2001 From: Kenneth Russel Date: Mon, 15 Aug 2005 00:17:23 +0000 Subject: Added dual-context test. Changed WindowsOnscreenGLDrawable.swapBuffers() to lock the surface if necessary. Need to test this on other platforms and make similar change if necessary. git-svn-id: file:///usr/local/projects/SUN/JOGL/git-svn/svn-server-sync/jogl/branches/JSR-231@346 232f8b59-042b-4e1e-8c03-345bb8c30851 --- .../jogl/impl/windows/WindowsOnscreenGLDrawable.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) (limited to 'src/net/java/games/jogl/impl/windows') 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 { -- cgit v1.2.3