From: <eli...@us...> - 2006-06-07 06:36:23
|
Revision: 2356 Author: elias_naur Date: 2006-06-06 23:35:52 -0700 (Tue, 06 Jun 2006) ViewCVS: http://svn.sourceforge.net/java-game-lib/?rev=2356&view=rev Log Message: ----------- Mac OS X: Fixed flickering caused by the new context handling in AWTGLCanvas Modified Paths: -------------- trunk/LWJGL/src/java/org/lwjgl/opengl/Context.java trunk/LWJGL/src/java/org/lwjgl/opengl/ContextImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxContextImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXContextImplementation.java trunk/LWJGL/src/java/org/lwjgl/opengl/Win32ContextImplementation.java Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Context.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Context.java 2006-06-06 20:37:11 UTC (rev 2355) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Context.java 2006-06-07 06:35:52 UTC (rev 2356) @@ -145,6 +145,18 @@ } /** + * Release the context from its drawable. This is necessary on some platforms, + * like Mac OS X, where binding the context to a drawable and binding the context + * for rendering are two distinct actions and where calling releaseDrawable + * on every releaseCurrentContext results in artifacts. + */ + public synchronized void releaseDrawable() throws LWJGLException { + if (destroyed) + throw new IllegalStateException("Context is destroyed"); + implementation.releaseDrawable(getHandle()); + } + + /** * Update the context. Should be called whenever it's drawable is moved or resized */ public synchronized void update() { @@ -198,6 +210,7 @@ private void checkDestroy() { if (!destroyed && destroy_requested) { try { + releaseDrawable(); implementation.destroy(peer_info, handle); destroyed = true; thread = null; Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/ContextImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/ContextImplementation.java 2006-06-06 20:37:11 UTC (rev 2355) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/ContextImplementation.java 2006-06-07 06:35:52 UTC (rev 2356) @@ -56,6 +56,11 @@ public void swapBuffers() throws LWJGLException; /** + * Release the context from its drawable, if any. + */ + public void releaseDrawable(ByteBuffer context_handle) throws LWJGLException; + + /** * Release the current context (if any). After this call, no context is current. */ public void releaseCurrentContext() throws LWJGLException; Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2006-06-06 20:37:11 UTC (rev 2355) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Display.java 2006-06-07 06:35:52 UTC (rev 2356) @@ -283,10 +283,11 @@ } try { if (context.isCurrent()) { + context.releaseDrawable(); Context.releaseCurrentContext(); } } catch (LWJGLException e) { - LWJGLUtil.log("Exception occurred while trying to release context"); + LWJGLUtil.log("Exception occurred while trying to release context: " + e); } // Automatically destroy keyboard & mouse Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxContextImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxContextImplementation.java 2006-06-06 20:37:11 UTC (rev 2355) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/LinuxContextImplementation.java 2006-06-07 06:35:52 UTC (rev 2356) @@ -57,6 +57,9 @@ } private static native ByteBuffer nCreate(ByteBuffer peer_handle, ByteBuffer shared_context_handle) throws LWJGLException; + + public void releaseDrawable(ByteBuffer context_handle) throws LWJGLException { + } public void swapBuffers() throws LWJGLException { Context current_context = Context.getCurrentContext(); Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXContextImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXContextImplementation.java 2006-06-06 20:37:11 UTC (rev 2355) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/MacOSXContextImplementation.java 2006-06-07 06:35:52 UTC (rev 2356) @@ -68,16 +68,13 @@ private static native void nUpdate(ByteBuffer context_handle); public void releaseCurrentContext() throws LWJGLException { - Context current_context = Context.getCurrentContext(); - if (current_context != null) { - synchronized (current_context) { - clearDrawable(current_context.getHandle()); - } - } nReleaseCurrentContext(); } private static native void nReleaseCurrentContext() throws LWJGLException; + public void releaseDrawable(ByteBuffer context_handle) throws LWJGLException { + clearDrawable(context_handle); + } private static native void clearDrawable(ByteBuffer handle) throws LWJGLException; static void resetView(PeerInfo peer_info, Context context) throws LWJGLException { Modified: trunk/LWJGL/src/java/org/lwjgl/opengl/Win32ContextImplementation.java =================================================================== --- trunk/LWJGL/src/java/org/lwjgl/opengl/Win32ContextImplementation.java 2006-06-06 20:37:11 UTC (rev 2355) +++ trunk/LWJGL/src/java/org/lwjgl/opengl/Win32ContextImplementation.java 2006-06-07 06:35:52 UTC (rev 2356) @@ -68,6 +68,9 @@ } private static native void nSwapBuffers(ByteBuffer peer_info_handle) throws LWJGLException; + public void releaseDrawable(ByteBuffer context_handle) throws LWJGLException { + } + public void update(ByteBuffer context_handle) { } This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site. |