|
From: Elias N. <eli...@us...> - 2004-03-27 12:06:17
|
Update of /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv6869/src/java/org/lwjgl/opengl Modified Files: ARBVertexBufferObject.java ARBVertexShader.java ATIDrawBuffers.java GL15.java Window.java Log Message: Replaced asserts with proper runtime exceptions Index: Window.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/Window.java,v retrieving revision 1.31 retrieving revision 1.32 diff -u -d -r1.31 -r1.32 --- Window.java 26 Mar 2004 11:09:39 -0000 1.31 +++ Window.java 27 Mar 2004 11:55:07 -0000 1.32 @@ -108,7 +108,8 @@ * @return the width of the window */ public static int getWidth() { - assert isCreated() : "Cannot get width on uncreated window"; + if (!isCreated()) + throw new IllegalStateException("Cannot get width on uncreated window"); return width; } @@ -116,7 +117,8 @@ * @return the height of the window */ public static int getHeight() { - assert isCreated() : "Cannot get height on uncreated window"; + if (!isCreated()) + throw new IllegalStateException("Cannot get height on uncreated window"); return height; } @@ -124,15 +126,17 @@ * @return the title of the window */ public static String getTitle() { - assert isCreated() : "Cannot get title on uncreated window"; + if (!isCreated()) + throw new IllegalStateException("Cannot get title on uncreated window"); return title; } - + /** * @return whether this window is in fullscreen mode */ public static boolean isFullscreen() { - assert isCreated() : "Cannot determine state of uncreated window"; + if (!isCreated()) + throw new IllegalStateException("Cannot determine fullscreen state of uncreated window"); return fullscreen; } @@ -141,7 +145,8 @@ * @param newTitle The new window title */ public static void setTitle(String newTitle) { - assert isCreated() : "Cannot set title of uncreated window"; + if (!isCreated()) + throw new IllegalStateException("Cannot set title on uncreated window"); title = newTitle; nSetTitle(title); } @@ -156,7 +161,8 @@ * @return true if the user or operating system has asked the window to close */ public static boolean isCloseRequested() { - assert isCreated() : "Cannot determine state of uncreated window"; + if (!isCreated()) + throw new IllegalStateException("Cannot determine close requested state of uncreated window"); return nIsCloseRequested(); } @@ -166,7 +172,8 @@ * @return true if the window is minimized or otherwise not visible */ public static boolean isMinimized() { - assert isCreated() : "Cannot determine state of uncreated window"; + if (!isCreated()) + throw new IllegalStateException("Cannot determine minimized state of uncreated window"); return nIsMinimized(); } @@ -176,7 +183,8 @@ * @return true if window is focused */ public static boolean isFocused() { - assert isCreated() : "Cannot determine state of uncreated window"; + if (!isCreated()) + throw new IllegalStateException("Cannot determine focused state of uncreated window"); return nIsFocused(); } @@ -210,7 +218,8 @@ * and needs to repaint itself */ public static boolean isDirty() { - assert isCreated() : "Cannot determine state of uncreated window"; + if (!isCreated()) + throw new IllegalStateException("Cannot determine dirty state of uncreated window"); return nIsDirty(); } @@ -222,7 +231,8 @@ * @throws OpenGLException if an OpenGL error has occured since the last call to GL11.glGetError() */ public static void update() { - assert isCreated() : "Cannot paint uncreated window"; + if (!isCreated()) + throw new IllegalStateException("Cannot determine update uncreated window"); nUpdate(); if ((isDirty() && !isMinimized()) || (isFocused() && !isMinimized())) { Util.checkGLError(); @@ -259,7 +269,8 @@ * Make the Window the current rendering context for GL calls. */ public static synchronized void makeCurrent() { - assert isCreated() : "No window has been created."; + if (!isCreated()) + throw new IllegalStateException("No window created to make current"); nMakeCurrent(); GLContext.useContext(context); } @@ -315,7 +326,7 @@ */ public static void create(String title, int bpp, int alpha, int depth, int stencil, int samples) throws Exception { if (isCreated()) - throw new Exception("Only one LWJGL window may be instantiated at any one time."); + throw new IllegalStateException("Only one LWJGL window may be instantiated at any one time."); Window.fullscreen = true; Window.x = 0; Window.y = 0; @@ -371,7 +382,7 @@ public static void create(String title, int x, int y, int width, int height, int bpp, int alpha, int depth, int stencil, int samples) throws Exception { if (isCreated()) - throw new Exception("Only one LWJGL window may be instantiated at any one time."); + throw new IllegalStateException("Only one LWJGL window may be instantiated at any one time."); Window.fullscreen = false; Window.x = x; Window.y = y; @@ -518,7 +529,8 @@ * @return boolean */ public static boolean isVSyncEnabled() { - assert isCreated() : "Cannot determine sync of uncreated window"; + if (isCreated()) + throw new IllegalStateException("Cannot determine vsync state of uncreated window"); return nIsVSyncEnabled(); } @@ -531,11 +543,10 @@ * @param sync true to synchronize; false to ignore synchronization */ public static void setVSyncEnabled(boolean sync) { - assert isCreated() : "Cannot set sync of uncreated window"; + if (isCreated()) + throw new IllegalStateException("Cannot set vsync state of uncreated window"); nSetVSyncEnabled(sync); } private static native void nSetVSyncEnabled(boolean sync); - - } Index: ARBVertexShader.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/ARBVertexShader.java,v retrieving revision 1.4 retrieving revision 1.5 diff -u -d -r1.4 -r1.5 --- ARBVertexShader.java 15 Mar 2004 16:31:09 -0000 1.4 +++ ARBVertexShader.java 27 Mar 2004 11:55:07 -0000 1.5 @@ -67,7 +67,7 @@ // --------------------------- public static void glBindAttribLocationARB(int programObj, int index, ByteBuffer name) { if ( name.get(name.limit() - 1) != 0 ) { - throw new RuntimeException("<name> must be a null-terminated string."); + throw new IllegalArgumentException("<name> must be a null-terminated string."); } nglBindAttribLocationARB(programObj, index, name, name.position()); } @@ -99,7 +99,7 @@ // --------------------------- public static int glGetAttribLocationARB(int programObj, ByteBuffer name) { if ( name.get(name.limit() - 1) != 0 ) { - throw new RuntimeException("<name> must be a null-terminated string."); + throw new IllegalArgumentException("<name> must be a null-terminated string."); } return nglGetAttribLocationARB(programObj, name, name.position()); } @@ -107,4 +107,4 @@ private static native int nglGetAttribLocationARB(int programObj, ByteBuffer name, int nameOffset); // --------------------------- -} \ No newline at end of file +} Index: ATIDrawBuffers.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/ATIDrawBuffers.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ATIDrawBuffers.java 18 Feb 2004 23:54:45 -0000 1.3 +++ ATIDrawBuffers.java 27 Mar 2004 11:55:07 -0000 1.4 @@ -68,7 +68,7 @@ // --------------------------- public static void glDrawBuffersATI(IntBuffer buffers) { if (buffers.remaining() == 0) { - throw new RuntimeException("<buffers> must have at least 1 integer available."); + throw new IllegalArgumentException("<buffers> must have at least 1 integer available."); } nglDrawBuffersATI(buffers.remaining(), buffers, buffers.position()); } @@ -76,4 +76,4 @@ private static native void nglDrawBuffersATI(int size, IntBuffer buffers, int buffersOffset); // --------------------------- -} \ No newline at end of file +} Index: GL15.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/GL15.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- GL15.java 18 Feb 2004 23:54:46 -0000 1.3 +++ GL15.java 27 Mar 2004 11:55:07 -0000 1.4 @@ -87,7 +87,7 @@ VBOTracker.getVBOArrayStack().setState(buffer); break; default: - assert false: "Unsupported VBO target " + target; + throw new IllegalArgumentException("Unsupported VBO target " + target); } nglBindBuffer(target, buffer); } @@ -296,4 +296,4 @@ int paramsOffset); // --------------------------- -} \ No newline at end of file +} Index: ARBVertexBufferObject.java =================================================================== RCS file: /cvsroot/java-game-lib/LWJGL/src/java/org/lwjgl/opengl/ARBVertexBufferObject.java,v retrieving revision 1.3 retrieving revision 1.4 diff -u -d -r1.3 -r1.4 --- ARBVertexBufferObject.java 18 Feb 2004 23:54:45 -0000 1.3 +++ ARBVertexBufferObject.java 27 Mar 2004 11:55:07 -0000 1.4 @@ -89,7 +89,7 @@ case GL_ARRAY_BUFFER_ARB: VBOTracker.getVBOArrayStack().setState(buffer); break; - default: assert false: "Unsupported VBO target " + target; + default: throw new IllegalArgumentException("Unsupported VBO target " + target); } nglBindBufferARB(target, buffer); } |