|
From: Elias N. <eli...@us...> - 2005-03-29 11:31:32
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv18520/src/java/org/lwjgl/opengl Modified Files: LinuxDisplay.java LinuxDisplayPeerInfo.java LinuxPbufferPeerInfo.java Log Message: Linux: Moved display connection reference count to java. Linux: Load OpenGL library before opening display to work around a crash in NVIDIA drivers. Index: LinuxDisplayPeerInfo.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplayPeerInfo.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- LinuxDisplayPeerInfo.java 23 Feb 2005 11:11:07 -0000 1.3 +++ LinuxDisplayPeerInfo.java 29 Mar 2005 11:31:22 -0000 1.4 @@ -47,17 +47,17 @@ public LinuxDisplayPeerInfo(PixelFormat pixel_format) throws LWJGLException { LinuxDisplay.lockAWT(); try { - LinuxDisplay.incDisplay(); + GLContext.loadOpenGLLibrary(); try { - GLContext.loadOpenGLLibrary(); + LinuxDisplay.incDisplay(); try { initDefaultPeerInfo(getHandle(), pixel_format); } catch (LWJGLException e) { - GLContext.unloadOpenGLLibrary(); + LinuxDisplay.decDisplay(); throw e; } } catch (LWJGLException e) { - LinuxDisplay.decDisplay(); + GLContext.unloadOpenGLLibrary(); throw e; } } finally { Index: LinuxPbufferPeerInfo.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/LinuxPbufferPeerInfo.java,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- LinuxPbufferPeerInfo.java 23 Feb 2005 11:11:07 -0000 1.2 +++ LinuxPbufferPeerInfo.java 29 Mar 2005 11:31:22 -0000 1.3 @@ -47,17 +47,17 @@ public LinuxPbufferPeerInfo(int width, int height, PixelFormat pixel_format) throws LWJGLException { LinuxDisplay.lockAWT(); try { - LinuxDisplay.incDisplay(); + GLContext.loadOpenGLLibrary(); try { - GLContext.loadOpenGLLibrary(); + LinuxDisplay.incDisplay(); try { nInitHandle(getHandle(), width, height, pixel_format); } catch (LWJGLException e) { - GLContext.unloadOpenGLLibrary(); + LinuxDisplay.decDisplay(); throw e; } } catch (LWJGLException e) { - LinuxDisplay.decDisplay(); + GLContext.unloadOpenGLLibrary(); throw e; } } finally { Index: LinuxDisplay.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/LinuxDisplay.java,v retrieving revision 1.20 retrieving revision 1.21 diff -u -d -r1.20 -r1.21 --- LinuxDisplay.java 24 Feb 2005 10:44:33 -0000 1.20 +++ LinuxDisplay.java 29 Mar 2005 11:31:21 -0000 1.21 @@ -50,6 +50,8 @@ final class LinuxDisplay implements DisplayImplementation { private static final int NUM_BUTTONS = 3; + private static int display_connection_usage_count = 0; + private static PeerInfo peer_info; /* Since Xlib is not guaranteed to be thread safe, we need a way to synchronize LWJGL @@ -62,8 +64,24 @@ /** * increment and decrement display usage. */ - static native void incDisplay() throws LWJGLException; - static native void decDisplay(); + static void incDisplay() throws LWJGLException { + if (display_connection_usage_count == 0) { + openDisplay(); + } + display_connection_usage_count++; + } + + static void decDisplay() { + display_connection_usage_count--; + if (display_connection_usage_count < 0) + throw new InternalError("display_connection_usage_count < 0: " + display_connection_usage_count); + if (display_connection_usage_count == 0) { + closeDisplay(); + } + } + + private static native void openDisplay() throws LWJGLException; + private static native void closeDisplay(); public void createWindow(DisplayMode mode, boolean fullscreen, int x, int y) throws LWJGLException { lockAWT(); |