|
From: Elias N. <eli...@us...> - 2005-05-27 11:50:25
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv31116/src/java/org/lwjgl/opengl Modified Files: LinuxAWTGLCanvasPeerInfo.java LinuxCanvasImplementation.java Win32CanvasImplementation.java Log Message: Linux AWT: in case we're not on a SUN jdk, try to determine values instead of bombing out. This should help us compile and run on gcj Index: LinuxCanvasImplementation.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/LinuxCanvasImplementation.java,v retrieving revision 1.6 retrieving revision 1.7 diff -u -d -r1.6 -r1.7 --- LinuxCanvasImplementation.java 4 May 2005 20:59:33 -0000 1.6 +++ LinuxCanvasImplementation.java 27 May 2005 11:50:12 -0000 1.7 @@ -36,6 +36,7 @@ import java.lang.reflect.Method; import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; /** * $Id$ @@ -74,15 +75,19 @@ * @return The GraphicsConfiguration corresponding to a visual that matches the pixel format. */ public GraphicsConfiguration findConfiguration(GraphicsDevice device, PixelFormat pixel_format) throws LWJGLException { - int screen = getScreenFromDevice(device); - int visual_id_matching_format = findVisualIDFromFormat(screen, pixel_format); - GraphicsConfiguration[] configurations = device.getConfigurations(); - for (int i = 0; i < configurations.length; i++) { - int visual_id = getVisualIDFromConfiguration(configurations[i]); - if (visual_id == visual_id_matching_format) - return configurations[i]; + try { + int screen = getScreenFromDevice(device); + int visual_id_matching_format = findVisualIDFromFormat(screen, pixel_format); + GraphicsConfiguration[] configurations = device.getConfigurations(); + for (int i = 0; i < configurations.length; i++) { + int visual_id = getVisualIDFromConfiguration(configurations[i]); + if (visual_id == visual_id_matching_format) + return configurations[i]; + } + } catch (LWJGLException e) { + LWJGLUtil.log("Got exception while trying to determine configuration: " + e); } - throw new LWJGLException("Could not find the matching GraphicsConfiguration to visual id"); + return null; // In case we failed to locate the visual, or if we're not on a SUN JDK } private static int findVisualIDFromFormat(int screen, PixelFormat pixel_format) throws LWJGLException { Index: Win32CanvasImplementation.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/Win32CanvasImplementation.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- Win32CanvasImplementation.java 4 May 2005 20:59:36 -0000 1.3 +++ Win32CanvasImplementation.java 27 May 2005 11:50:12 -0000 1.4 @@ -58,7 +58,7 @@ */ public GraphicsConfiguration findConfiguration(GraphicsDevice device, PixelFormat pixel_format) throws LWJGLException { /* - * It seems like the best way is to simply return null and let + * It seems like the best way is to simply return null and * use SetPixelFormat in JNI later. */ return null; Index: LinuxAWTGLCanvasPeerInfo.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/LinuxAWTGLCanvasPeerInfo.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- LinuxAWTGLCanvasPeerInfo.java 4 May 2005 20:59:36 -0000 1.3 +++ LinuxAWTGLCanvasPeerInfo.java 27 May 2005 11:50:12 -0000 1.4 @@ -34,6 +34,7 @@ import java.nio.ByteBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.LWJGLUtil; /** * $Id$ @@ -50,7 +51,12 @@ } protected void doLockAndInitHandle() throws LWJGLException { - int screen = LinuxCanvasImplementation.getScreenFromDevice(canvas.getGraphicsConfiguration().getDevice()); + int screen = -1; + try { + screen = LinuxCanvasImplementation.getScreenFromDevice(canvas.getGraphicsConfiguration().getDevice()); + } catch (LWJGLException e) { + LWJGLUtil.log("Got exception while trying to determine screen: " + e); + } nInitHandle(screen, awt_surface.lockAndGetHandle(canvas), getHandle()); } private static native void nInitHandle(int screen, ByteBuffer surface_buffer, ByteBuffer peer_info_handle) throws LWJGLException; |