From ad1ff19437a4464884816bea9ad19029071d13d9 Mon Sep 17 00:00:00 2001 From: Elias Naur Date: Thu, 29 Jul 2004 11:20:43 +0000 Subject: [PATCH] Split general buffer checks into org.lwjgl.BufferChecks and the gl specific buffer checks into org.lwjgl.opengl.GLBufferChecks --- src/java/org/lwjgl/BufferChecks.java | 212 ++++++++++++++++++ src/java/org/lwjgl/input/Cursor.java | 4 +- .../org/lwjgl/opengl/ARBBufferObject.java | 1 + src/java/org/lwjgl/opengl/ARBImaging.java | 15 +- .../org/lwjgl/opengl/ARBMatrixPalette.java | 9 +- .../org/lwjgl/opengl/ARBOcclusionQuery.java | 1 + .../org/lwjgl/opengl/ARBPointParameters.java | 1 + src/java/org/lwjgl/opengl/ARBProgram.java | 1 + .../org/lwjgl/opengl/ARBShaderObjects.java | 1 + .../lwjgl/opengl/ARBTextureCompression.java | 1 + .../org/lwjgl/opengl/ARBTransposeMatrix.java | 1 + src/java/org/lwjgl/opengl/ARBVertexBlend.java | 11 +- .../org/lwjgl/opengl/ARBVertexProgram.java | 11 +- .../org/lwjgl/opengl/ARBVertexShader.java | 1 + src/java/org/lwjgl/opengl/ATIDrawBuffers.java | 1 + .../org/lwjgl/opengl/ATIElementArray.java | 9 +- .../org/lwjgl/opengl/ATIEnvmapBumpmap.java | 1 + .../org/lwjgl/opengl/ATIFragmentShader.java | 1 + .../lwjgl/opengl/ATIVertexArrayObject.java | 1 + .../opengl/ATIVertexAttribArrayObject.java | 1 + .../lwjgl/opengl/EXTDrawRangeElements.java | 9 +- src/java/org/lwjgl/opengl/EXTFogCoord.java | 5 +- .../org/lwjgl/opengl/EXTMultiDrawArrays.java | 1 + .../org/lwjgl/opengl/EXTPointParameters.java | 1 + .../org/lwjgl/opengl/EXTSecondaryColor.java | 7 +- .../org/lwjgl/opengl/EXTVertexShader.java | 11 +- .../org/lwjgl/opengl/EXTVertexWeighting.java | 5 +- src/java/org/lwjgl/opengl/GL11.java | 94 ++++---- src/java/org/lwjgl/opengl/GL12.java | 25 ++- src/java/org/lwjgl/opengl/GL13.java | 1 + src/java/org/lwjgl/opengl/GL14.java | 11 +- src/java/org/lwjgl/opengl/GL15.java | 1 + ...{BufferChecks.java => GLBufferChecks.java} | 161 +------------ src/java/org/lwjgl/opengl/NVEvaluators.java | 1 + src/java/org/lwjgl/opengl/NVFence.java | 1 + .../org/lwjgl/opengl/NVFragmentProgram.java | 1 + src/java/org/lwjgl/opengl/NVHalfFloat.java | 1 + .../org/lwjgl/opengl/NVOcclusionQuery.java | 1 + .../org/lwjgl/opengl/NVPixelDataRange.java | 1 + src/java/org/lwjgl/opengl/NVPointSprite.java | 1 + src/java/org/lwjgl/opengl/NVProgram.java | 1 + .../org/lwjgl/opengl/NVRegisterCombiners.java | 1 + .../lwjgl/opengl/NVRegisterCombiners2.java | 1 + .../org/lwjgl/opengl/NVVertexArrayRange.java | 1 + .../org/lwjgl/opengl/NVVertexProgram.java | 11 +- 45 files changed, 369 insertions(+), 269 deletions(-) create mode 100644 src/java/org/lwjgl/BufferChecks.java rename src/java/org/lwjgl/opengl/{BufferChecks.java => GLBufferChecks.java} (58%) diff --git a/src/java/org/lwjgl/BufferChecks.java b/src/java/org/lwjgl/BufferChecks.java new file mode 100644 index 00000000..18daf52c --- /dev/null +++ b/src/java/org/lwjgl/BufferChecks.java @@ -0,0 +1,212 @@ +/* + * Copyright (c) 2002-2004 LWJGL Project + * All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions are + * met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in the + * documentation and/or other materials provided with the distribution. + * + * * Neither the name of 'LWJGL' nor the names of + * its contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED + * TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR + * PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR + * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, + * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, + * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR + * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF + * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING + * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS + * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +package org.lwjgl; + +import java.nio.Buffer; +import java.nio.ByteBuffer; +import java.nio.ShortBuffer; +import java.nio.FloatBuffer; +import java.nio.IntBuffer; +import java.nio.DoubleBuffer; + +/** + * $Id$ A class to + * check buffer boundaries in general. If there is unsufficient space + * in the buffer when the call is made then a buffer overflow would otherwise + * occur and cause unexpected behaviour, a crash, or worse, a security risk. + * + * @author cix_foo + * @author elias_naur + * @version $Revision$ + */ +public class BufferChecks { + /** Static methods only! */ + private BufferChecks() { + } + + /** + * Default buffer size for most buffer checks. + */ + private static final int DEFAULT_BUFFER_SIZE = 4; + + /** + * Helper methods to ensure a buffer is direct or null. + */ + public static void checkDirectOrNull(ByteBuffer buf) { + if (buf != null) { + checkDirect(buf); + } + } + + public static void checkDirectOrNull(FloatBuffer buf) { + if (buf != null) { + checkDirect(buf); + } + } + + public static void checkDirectOrNull(ShortBuffer buf) { + if (buf != null) { + checkDirect(buf); + } + } + + public static void checkDirectOrNull(IntBuffer buf) { + if (buf != null) { + checkDirect(buf); + } + } + + public static void checkDirectOrNull(DoubleBuffer buf) { + if (buf != null) { + checkDirect(buf); + } + } + + /** + * Helper methods to ensure a buffer is direct (and, implicitly, non-null). + */ + public static void checkDirectBuffer(Buffer buf) { + if (buf instanceof ByteBuffer) + checkDirect((ByteBuffer)buf); + else if (buf instanceof ShortBuffer) + checkDirect((ShortBuffer)buf); + else if (buf instanceof IntBuffer) + checkDirect((IntBuffer)buf); + else if (buf instanceof FloatBuffer) + checkDirect((FloatBuffer)buf); + else if (buf instanceof DoubleBuffer) + checkDirect((DoubleBuffer)buf); + else + throw new IllegalStateException("Unsupported buffer type"); + } + + public static void checkDirect(ByteBuffer buf) { + if (!buf.isDirect()) { + throw new IllegalArgumentException("ByteBuffer is not direct"); + } + } + + public static void checkDirect(FloatBuffer buf) { + if (!buf.isDirect()) { + throw new IllegalArgumentException("FloatBuffer is not direct"); + } + } + + public static void checkDirect(ShortBuffer buf) { + if (!buf.isDirect()) { + throw new IllegalArgumentException("ShortBuffer is not direct"); + } + } + + public static void checkDirect(IntBuffer buf) { + if (!buf.isDirect()) { + throw new IllegalArgumentException("IntBuffer is not direct"); + } + } + + public static void checkDirect(DoubleBuffer buf) { + if (!buf.isDirect()) { + throw new IllegalArgumentException("IntBuffer is not direct"); + } + } + + /** + * Helper method to ensure a buffer is big enough to receive data from a + * glGet* operation. + * + * @param buf + * The buffer to check + * @param size + * The minimum buffer size + * @throws BufferOverflowException + */ + private static void checkBufferSize(Buffer buf, int size) { + if (buf.remaining() < size) { + throw new IllegalArgumentException("Number of remaining buffer elements is " + buf.remaining() + ", must be at least " + size); + } + } + + public static void checkBuffer(ByteBuffer buf, int size) { + checkBufferSize(buf, size); + checkDirect(buf); + } + + public static void checkBuffer(IntBuffer buf, int size) { + checkBufferSize(buf, size); + checkDirect(buf); + } + + public static void checkBuffer(ShortBuffer buf, int size) { + checkBufferSize(buf, size); + checkDirect(buf); + } + + public static void checkBuffer(FloatBuffer buf, int size) { + checkBufferSize(buf, size); + checkDirect(buf); + } + + public static void checkBuffer(DoubleBuffer buf, int size) { + checkBufferSize(buf, size); + checkDirect(buf); + } + + /** + * Helper methods to ensure a buffer is big enough to receive data from a + * glGet* operation. To avoid unnecessarily complex buffer size checking + * we've just set the bar artificially high and insist that any receiving + * buffer has at least 4 remaining(). + * + * @param buf + * The buffer to check + * @throws BufferOverflowException + */ + public static void checkBuffer(ByteBuffer buf) { + checkBuffer(buf, DEFAULT_BUFFER_SIZE); + } + + public static void checkBuffer(ShortBuffer buf) { + checkBuffer(buf, DEFAULT_BUFFER_SIZE); + } + + public static void checkBuffer(FloatBuffer buf) { + checkBuffer(buf, DEFAULT_BUFFER_SIZE); + } + + public static void checkBuffer(IntBuffer buf) { + checkBuffer(buf, DEFAULT_BUFFER_SIZE); + } + + public static void checkBuffer(DoubleBuffer buf) { + checkBuffer(buf, DEFAULT_BUFFER_SIZE); + } +} diff --git a/src/java/org/lwjgl/input/Cursor.java b/src/java/org/lwjgl/input/Cursor.java index 16cf524d..73e59790 100644 --- a/src/java/org/lwjgl/input/Cursor.java +++ b/src/java/org/lwjgl/input/Cursor.java @@ -36,6 +36,7 @@ import java.nio.IntBuffer; import org.lwjgl.LWJGLException; import org.lwjgl.BufferUtils; +import org.lwjgl.BufferChecks; import org.lwjgl.Sys; /** @@ -72,12 +73,13 @@ public class Cursor { * @throws LWJGLException if the cursor could not be created for any reason */ public Cursor(int width, int height, int xHotspot, int yHotspot, int numImages, IntBuffer images, IntBuffer delays) throws LWJGLException { + BufferChecks.checkBuffer(images, width*height*numImages); if (!Mouse.isCreated()) throw new IllegalStateException("Mouse must be created before creating cursor objects"); if (width*height*numImages > images.remaining()) throw new IllegalArgumentException("width*height*numImages > images.remaining()"); if (delays != null && numImages > delays.remaining()) - throw new IllegalArgumentException("delays != null && numImages > delays.remaining()"); + BufferChecks.checkBuffer(delays, numImages); if (xHotspot >= width || xHotspot < 0) throw new IllegalArgumentException("xHotspot > width || xHotspot < 0"); if (yHotspot >= height || yHotspot < 0) diff --git a/src/java/org/lwjgl/opengl/ARBBufferObject.java b/src/java/org/lwjgl/opengl/ARBBufferObject.java index daa54341..46efc601 100644 --- a/src/java/org/lwjgl/opengl/ARBBufferObject.java +++ b/src/java/org/lwjgl/opengl/ARBBufferObject.java @@ -38,6 +38,7 @@ import java.nio.IntBuffer; import java.nio.ShortBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class ARBBufferObject { diff --git a/src/java/org/lwjgl/opengl/ARBImaging.java b/src/java/org/lwjgl/opengl/ARBImaging.java index 19bae7ea..43b49c84 100644 --- a/src/java/org/lwjgl/opengl/ARBImaging.java +++ b/src/java/org/lwjgl/opengl/ARBImaging.java @@ -40,6 +40,7 @@ import java.nio.ShortBuffer; import org.lwjgl.BufferUtils; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; /** * $Id$ @@ -239,32 +240,32 @@ public final class ARBImaging { } private static native void nglGetMinmaxParameteriv(int target, int pname, IntBuffer params, int params_offset); public static void glConvolutionFilter1D(int target, int internalformat, int width, int format, int type, ByteBuffer image) { - BufferChecks.checkBuffer(image, BufferChecks.calculateImageStorage(format, type, width, 1, 1)); + BufferChecks.checkBuffer(image, GLBufferChecks.calculateImageStorage(format, type, width, 1, 1)); nglConvolutionFilter1D(target, internalformat, width, format, type, image, image.position()); } public static void glConvolutionFilter1D(int target, int internalformat, int width, int format, int type, ShortBuffer image) { - BufferChecks.checkBuffer(image, BufferChecks.calculateImageStorage(format, type, width, 1, 1)>>1); + BufferChecks.checkBuffer(image, GLBufferChecks.calculateImageStorage(format, type, width, 1, 1)>>1); nglConvolutionFilter1D(target, internalformat, width, format, type, image, image.position()); } public static void glConvolutionFilter1D(int target, int internalformat, int width, int format, int type, IntBuffer image) { - BufferChecks.checkBuffer(image, BufferChecks.calculateImageStorage(format, type, width, 1, 1)>>2); + BufferChecks.checkBuffer(image, GLBufferChecks.calculateImageStorage(format, type, width, 1, 1)>>2); nglConvolutionFilter1D(target, internalformat, width, format, type, image, image.position()); } public static void glConvolutionFilter1D(int target, int internalformat, int width, int format, int type, FloatBuffer image) { - BufferChecks.checkBuffer(image, BufferChecks.calculateImageStorage(format, type, width, 1, 1)>>2); + BufferChecks.checkBuffer(image, GLBufferChecks.calculateImageStorage(format, type, width, 1, 1)>>2); nglConvolutionFilter1D(target, internalformat, width, format, type, image, image.position()); } private static native void nglConvolutionFilter1D(int target, int internalformat, int width, int format, int type, Buffer image, int image_offset); public static void glConvolutionFilter2D(int target, int internalformat, int width, int height, int format, int type, ByteBuffer image) { - BufferChecks.checkBuffer(image, BufferChecks.calculateImageStorage(format, type, width, height, 1)); + BufferChecks.checkBuffer(image, GLBufferChecks.calculateImageStorage(format, type, width, height, 1)); nglConvolutionFilter2D(target, internalformat, width, height, format, type, image, image.position()); } public static void glConvolutionFilter2D(int target, int internalformat, int width, int height, int format, int type, ShortBuffer image) { - BufferChecks.checkBuffer(image, BufferChecks.calculateImageStorage(format, type, width, height, 1)>>1); + BufferChecks.checkBuffer(image, GLBufferChecks.calculateImageStorage(format, type, width, height, 1)>>1); nglConvolutionFilter2D(target, internalformat, width, height, format, type, image, image.position() <<1); } public static void glConvolutionFilter2D(int target, int internalformat, int width, int height, int format, int type, IntBuffer image) { - BufferChecks.checkBuffer(image, BufferChecks.calculateImageStorage(format, type, width, height, 1)>>2); + BufferChecks.checkBuffer(image, GLBufferChecks.calculateImageStorage(format, type, width, height, 1)>>2); nglConvolutionFilter2D(target, internalformat, width, height, format, type, image, image.position() << 2); } private static native void nglConvolutionFilter2D(int target, int internalformat, int width, int height, int format, int type, Buffer image, int image_offset); diff --git a/src/java/org/lwjgl/opengl/ARBMatrixPalette.java b/src/java/org/lwjgl/opengl/ARBMatrixPalette.java index 76ff4da3..e3be6b59 100644 --- a/src/java/org/lwjgl/opengl/ARBMatrixPalette.java +++ b/src/java/org/lwjgl/opengl/ARBMatrixPalette.java @@ -37,6 +37,7 @@ import java.nio.IntBuffer; import java.nio.ShortBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class ARBMatrixPalette { public static final int GL_MATRIX_PALETTE_ARB = 0x8840; @@ -55,22 +56,22 @@ public final class ARBMatrixPalette { public static native void glCurrentPaletteMatrixARB(int index); public static void glMatrixIndexPointerARB(int size, int stride, ByteBuffer pPointer) { BufferChecks.checkDirect(pPointer); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglMatrixIndexPointerARB(size, GL11.GL_UNSIGNED_BYTE, stride, pPointer, pPointer.position()); } public static void glMatrixIndexPointerARB(int size, int stride, ShortBuffer pPointer) { BufferChecks.checkDirect(pPointer); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglMatrixIndexPointerARB(size, GL11.GL_UNSIGNED_SHORT, stride, pPointer, pPointer.position()<<1); } public static void glMatrixIndexPointerARB(int size, int stride, IntBuffer pPointer) { BufferChecks.checkDirect(pPointer); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglMatrixIndexPointerARB(size, GL11.GL_UNSIGNED_INT, stride, pPointer, pPointer.position()<<2); } private static native void nglMatrixIndexPointerARB(int size, int type, int stride, Buffer pPointer, int pPointer_offset); public static void glMatrixIndexPointerARB(int size, int type, int stride, int buffer_offset) { - BufferChecks.ensureArrayVBOenabled(); + GLBufferChecks.ensureArrayVBOenabled(); nglMatrixIndexPointerARBVBO(size, type, stride, buffer_offset); } private static native void nglMatrixIndexPointerARBVBO(int size, int type, int stride, int buffer_offset); diff --git a/src/java/org/lwjgl/opengl/ARBOcclusionQuery.java b/src/java/org/lwjgl/opengl/ARBOcclusionQuery.java index 9e7e1ce1..ad88ecb8 100644 --- a/src/java/org/lwjgl/opengl/ARBOcclusionQuery.java +++ b/src/java/org/lwjgl/opengl/ARBOcclusionQuery.java @@ -34,6 +34,7 @@ package org.lwjgl.opengl; import java.nio.IntBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class ARBOcclusionQuery { diff --git a/src/java/org/lwjgl/opengl/ARBPointParameters.java b/src/java/org/lwjgl/opengl/ARBPointParameters.java index 5451cbcc..500fa68e 100644 --- a/src/java/org/lwjgl/opengl/ARBPointParameters.java +++ b/src/java/org/lwjgl/opengl/ARBPointParameters.java @@ -34,6 +34,7 @@ package org.lwjgl.opengl; import java.nio.FloatBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class ARBPointParameters { public static final int GL_POINT_SIZE_MIN_ARB = 0x8126; diff --git a/src/java/org/lwjgl/opengl/ARBProgram.java b/src/java/org/lwjgl/opengl/ARBProgram.java index ffe90cb8..5c633868 100644 --- a/src/java/org/lwjgl/opengl/ARBProgram.java +++ b/src/java/org/lwjgl/opengl/ARBProgram.java @@ -39,6 +39,7 @@ import java.nio.FloatBuffer; import java.nio.IntBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public class ARBProgram { diff --git a/src/java/org/lwjgl/opengl/ARBShaderObjects.java b/src/java/org/lwjgl/opengl/ARBShaderObjects.java index 9098ed62..7c5b7407 100644 --- a/src/java/org/lwjgl/opengl/ARBShaderObjects.java +++ b/src/java/org/lwjgl/opengl/ARBShaderObjects.java @@ -37,6 +37,7 @@ import java.nio.FloatBuffer; import java.nio.IntBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class ARBShaderObjects { diff --git a/src/java/org/lwjgl/opengl/ARBTextureCompression.java b/src/java/org/lwjgl/opengl/ARBTextureCompression.java index 7d00e8cd..120ca830 100644 --- a/src/java/org/lwjgl/opengl/ARBTextureCompression.java +++ b/src/java/org/lwjgl/opengl/ARBTextureCompression.java @@ -38,6 +38,7 @@ import java.nio.IntBuffer; import java.nio.ShortBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class ARBTextureCompression { diff --git a/src/java/org/lwjgl/opengl/ARBTransposeMatrix.java b/src/java/org/lwjgl/opengl/ARBTransposeMatrix.java index 30c0bebf..92331609 100644 --- a/src/java/org/lwjgl/opengl/ARBTransposeMatrix.java +++ b/src/java/org/lwjgl/opengl/ARBTransposeMatrix.java @@ -34,6 +34,7 @@ package org.lwjgl.opengl; import java.nio.FloatBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class ARBTransposeMatrix { public static final int GL_TRANSPOSE_MODELVIEW_MATRIX_ARB = 0x84E3; diff --git a/src/java/org/lwjgl/opengl/ARBVertexBlend.java b/src/java/org/lwjgl/opengl/ARBVertexBlend.java index 11119c82..17efcfbf 100644 --- a/src/java/org/lwjgl/opengl/ARBVertexBlend.java +++ b/src/java/org/lwjgl/opengl/ARBVertexBlend.java @@ -38,6 +38,7 @@ import java.nio.IntBuffer; import java.nio.ShortBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class ARBVertexBlend { public static final int GL_MAX_VERTEX_UNITS_ARB = 0x86A4; @@ -129,27 +130,27 @@ public final class ARBVertexBlend { public static void glWeightPointerARB(int size, boolean unsigned, int stride, ByteBuffer pPointer) { BufferChecks.checkDirect(pPointer); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglWeightPointerARB(size, unsigned ? GL11.GL_UNSIGNED_BYTE : GL11.GL_BYTE, stride, pPointer, pPointer.position()); } public static void glWeightPointerARB(int size, boolean unsigned, int stride, ShortBuffer pPointer) { BufferChecks.checkDirect(pPointer); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglWeightPointerARB(size, unsigned ? GL11.GL_UNSIGNED_SHORT : GL11.GL_SHORT, stride, pPointer, pPointer.position()<<1); } public static void glWeightPointerARB(int size, int stride, FloatBuffer pPointer) { BufferChecks.checkDirect(pPointer); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglWeightPointerARB(size, GL11.GL_FLOAT, stride, pPointer, pPointer.position()<<2); } public static void glWeightPointerARB(int size, boolean unsigned, int stride, IntBuffer pPointer) { BufferChecks.checkDirect(pPointer); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglWeightPointerARB(size, unsigned ? GL11.GL_UNSIGNED_INT : GL11.GL_INT, stride, pPointer, pPointer.position()<<2); } private static native void nglWeightPointerARB(int size, int type, int stride, Buffer pPointer, int pPointer_offset); public static void glWeightPointerARB(int size, int type, int stride, int buffer_offset) { - BufferChecks.ensureArrayVBOenabled(); + GLBufferChecks.ensureArrayVBOenabled(); nglWeightPointerARBVBO(size, type, stride, buffer_offset); } private static native void nglWeightPointerARBVBO(int size, int type, int stride, int buffer_offset); diff --git a/src/java/org/lwjgl/opengl/ARBVertexProgram.java b/src/java/org/lwjgl/opengl/ARBVertexProgram.java index f9af1661..d5cc0380 100644 --- a/src/java/org/lwjgl/opengl/ARBVertexProgram.java +++ b/src/java/org/lwjgl/opengl/ARBVertexProgram.java @@ -38,6 +38,7 @@ import java.nio.IntBuffer; import java.nio.ShortBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class ARBVertexProgram extends ARBProgram { @@ -110,22 +111,22 @@ public final class ARBVertexProgram extends ARBProgram { public static native void glVertexAttrib4NubARB(int index, byte x, byte y, byte z, byte w); public static void glVertexAttribPointerARB(int index, int size, boolean unsigned, boolean normalized, int stride, ByteBuffer buffer) { - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglVertexAttribPointerARB(index, size, unsigned ? GL11.GL_UNSIGNED_BYTE : GL11.GL_BYTE, normalized, stride, buffer, buffer.position()); } public static void glVertexAttribPointerARB(int index, int size, boolean unsigned, boolean normalized, int stride, ShortBuffer buffer) { - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglVertexAttribPointerARB(index, size, unsigned ? GL11.GL_UNSIGNED_SHORT : GL11.GL_SHORT, normalized, stride, buffer, buffer.position() << 1); } public static void glVertexAttribPointerARB(int index, int size, boolean normalized, int stride, FloatBuffer buffer) { - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglVertexAttribPointerARB(index, size, GL11.GL_FLOAT, normalized, stride, buffer, buffer.position() << 2); } public static void glVertexAttribPointerARB(int index, int size, boolean unsigned, boolean normalized, int stride, IntBuffer buffer) { - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglVertexAttribPointerARB(index, size, unsigned ? GL11.GL_UNSIGNED_INT : GL11.GL_INT, normalized, stride, buffer, buffer.position() << 2); } @@ -133,7 +134,7 @@ public final class ARBVertexProgram extends ARBProgram { // --------------------------- public static void glVertexAttribPointerARB(int index, int size, int type, boolean normalized, int stride, int bufferOffset) { - BufferChecks.ensureArrayVBOenabled(); + GLBufferChecks.ensureArrayVBOenabled(); nglVertexAttribPointerARBVBO(index, size, type, normalized, stride, bufferOffset); } diff --git a/src/java/org/lwjgl/opengl/ARBVertexShader.java b/src/java/org/lwjgl/opengl/ARBVertexShader.java index 41bcd1e1..0bc29158 100644 --- a/src/java/org/lwjgl/opengl/ARBVertexShader.java +++ b/src/java/org/lwjgl/opengl/ARBVertexShader.java @@ -35,6 +35,7 @@ import java.nio.ByteBuffer; import java.nio.IntBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class ARBVertexShader { diff --git a/src/java/org/lwjgl/opengl/ATIDrawBuffers.java b/src/java/org/lwjgl/opengl/ATIDrawBuffers.java index df2aa322..0b9034eb 100644 --- a/src/java/org/lwjgl/opengl/ATIDrawBuffers.java +++ b/src/java/org/lwjgl/opengl/ATIDrawBuffers.java @@ -34,6 +34,7 @@ package org.lwjgl.opengl; import java.nio.IntBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class ATIDrawBuffers { diff --git a/src/java/org/lwjgl/opengl/ATIElementArray.java b/src/java/org/lwjgl/opengl/ATIElementArray.java index 616a6d9d..c5cf6e03 100644 --- a/src/java/org/lwjgl/opengl/ATIElementArray.java +++ b/src/java/org/lwjgl/opengl/ATIElementArray.java @@ -37,6 +37,7 @@ import java.nio.IntBuffer; import java.nio.ShortBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class ATIElementArray { public static final int GL_ELEMENT_ARRAY_ATI = 0x8768; @@ -47,23 +48,23 @@ public final class ATIElementArray { public static void glElementPointerATI(ByteBuffer pPointer) { BufferChecks.checkDirect(pPointer); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglElementPointerATI(GL11.GL_UNSIGNED_BYTE, pPointer, pPointer.position()); } public static void glElementPointerATI(ShortBuffer pPointer) { BufferChecks.checkDirect(pPointer); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglElementPointerATI(GL11.GL_UNSIGNED_SHORT, pPointer, pPointer.position()<<1); } public static void glElementPointerATI(IntBuffer pPointer) { BufferChecks.checkDirect(pPointer); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglElementPointerATI(GL11.GL_UNSIGNED_INT, pPointer, pPointer.position()<<2); } private static native void nglElementPointerATI(int type, Buffer pPointer, int pPointer_offset); public static void glElementPointerATI(int type, int buffer_offset) { - BufferChecks.ensureArrayVBOenabled(); + GLBufferChecks.ensureArrayVBOenabled(); nglElementPointerATIVBO(type, buffer_offset); } private static native void nglElementPointerATIVBO(int type, int buffer_offset); diff --git a/src/java/org/lwjgl/opengl/ATIEnvmapBumpmap.java b/src/java/org/lwjgl/opengl/ATIEnvmapBumpmap.java index 8df6453f..e20e079d 100644 --- a/src/java/org/lwjgl/opengl/ATIEnvmapBumpmap.java +++ b/src/java/org/lwjgl/opengl/ATIEnvmapBumpmap.java @@ -35,6 +35,7 @@ import java.nio.FloatBuffer; import java.nio.IntBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class ATIEnvmapBumpmap { public static final int GL_BUMP_ROT_MATRIX_ATI = 0x8775; diff --git a/src/java/org/lwjgl/opengl/ATIFragmentShader.java b/src/java/org/lwjgl/opengl/ATIFragmentShader.java index 22dc1215..61ad93bc 100644 --- a/src/java/org/lwjgl/opengl/ATIFragmentShader.java +++ b/src/java/org/lwjgl/opengl/ATIFragmentShader.java @@ -39,6 +39,7 @@ package org.lwjgl.opengl; import java.nio.FloatBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class ATIFragmentShader { public static final int GL_FRAGMENT_SHADER_ATI = 0x8920; diff --git a/src/java/org/lwjgl/opengl/ATIVertexArrayObject.java b/src/java/org/lwjgl/opengl/ATIVertexArrayObject.java index 21033fb0..b3328fd8 100644 --- a/src/java/org/lwjgl/opengl/ATIVertexArrayObject.java +++ b/src/java/org/lwjgl/opengl/ATIVertexArrayObject.java @@ -38,6 +38,7 @@ import java.nio.IntBuffer; import java.nio.ShortBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class ATIVertexArrayObject { public static final int GL_STATIC_ATI = 0x8760; diff --git a/src/java/org/lwjgl/opengl/ATIVertexAttribArrayObject.java b/src/java/org/lwjgl/opengl/ATIVertexAttribArrayObject.java index bad2fca6..165b24e7 100644 --- a/src/java/org/lwjgl/opengl/ATIVertexAttribArrayObject.java +++ b/src/java/org/lwjgl/opengl/ATIVertexAttribArrayObject.java @@ -35,6 +35,7 @@ import java.nio.FloatBuffer; import java.nio.IntBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class ATIVertexAttribArrayObject { diff --git a/src/java/org/lwjgl/opengl/EXTDrawRangeElements.java b/src/java/org/lwjgl/opengl/EXTDrawRangeElements.java index 11b46882..8c7d1d42 100644 --- a/src/java/org/lwjgl/opengl/EXTDrawRangeElements.java +++ b/src/java/org/lwjgl/opengl/EXTDrawRangeElements.java @@ -37,6 +37,7 @@ import java.nio.IntBuffer; import java.nio.ShortBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class EXTDrawRangeElements { public static final int GL_MAX_ELEMENTS_VERTICES_EXT = 0x80E8; @@ -46,23 +47,23 @@ public final class EXTDrawRangeElements { public static void glDrawRangeElementsEXT(int mode, int start, int end, ByteBuffer pIndices) { BufferChecks.checkDirect(pIndices); - BufferChecks.ensureElementVBOdisabled(); + GLBufferChecks.ensureElementVBOdisabled(); nglDrawRangeElementsEXT(mode, start, end, pIndices.remaining(), GL11.GL_UNSIGNED_BYTE, pIndices, pIndices.position()); } public static void glDrawRangeElementsEXT(int mode, int start, int end, ShortBuffer pIndices) { BufferChecks.checkDirect(pIndices); - BufferChecks.ensureElementVBOdisabled(); + GLBufferChecks.ensureElementVBOdisabled(); nglDrawRangeElementsEXT(mode, start, end, pIndices.remaining(), GL11.GL_UNSIGNED_SHORT, pIndices, pIndices.position()<<1); } public static void glDrawRangeElementsEXT(int mode, int start, int end, IntBuffer pIndices) { BufferChecks.checkDirect(pIndices); - BufferChecks.ensureElementVBOdisabled(); + GLBufferChecks.ensureElementVBOdisabled(); nglDrawRangeElementsEXT(mode, start, end, pIndices.remaining(), GL11.GL_UNSIGNED_INT, pIndices, pIndices.position()<<2); } private static native void nglDrawRangeElementsEXT(int mode, int start, int end, int count, int type, Buffer pIndices, int pIndices_offset); public static void glDrawRangeElementsEXT(int mode, int start, int end, int count, int type, int buffer_offset) { - BufferChecks.ensureElementVBOenabled(); + GLBufferChecks.ensureElementVBOenabled(); nglDrawRangeElementsEXTVBO(mode, start, end, count, type, buffer_offset); } private static native void nglDrawRangeElementsEXTVBO(int mode, int start, int end, int count, int type, int buffer_offset); diff --git a/src/java/org/lwjgl/opengl/EXTFogCoord.java b/src/java/org/lwjgl/opengl/EXTFogCoord.java index 90b7513e..f19fc9ac 100644 --- a/src/java/org/lwjgl/opengl/EXTFogCoord.java +++ b/src/java/org/lwjgl/opengl/EXTFogCoord.java @@ -35,6 +35,7 @@ import java.nio.Buffer; import java.nio.FloatBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class EXTFogCoord { public static final int GL_FOG_COORDINATE_SOURCE_EXT = 0x8450; @@ -52,12 +53,12 @@ public final class EXTFogCoord { public static native void glFogCoordfEXT(float coord); public static void glFogCoordPointerEXT(int stride, FloatBuffer data) { BufferChecks.checkDirect(data); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglFogCoordPointerEXT(GL11.GL_FLOAT, stride, data, data.position() << 2); } private static native void nglFogCoordPointerEXT(int type, int stride, Buffer data, int data_offset); public static void glFogCoordPointerEXT(int type, int stride, int buffer_offset) { - BufferChecks.ensureArrayVBOenabled(); + GLBufferChecks.ensureArrayVBOenabled(); nglFogCoordPointerEXTVBO(type, stride, buffer_offset); } private static native void nglFogCoordPointerEXTVBO(int type, int stride, int buffer_offset); diff --git a/src/java/org/lwjgl/opengl/EXTMultiDrawArrays.java b/src/java/org/lwjgl/opengl/EXTMultiDrawArrays.java index d5183cb5..6a1e3755 100644 --- a/src/java/org/lwjgl/opengl/EXTMultiDrawArrays.java +++ b/src/java/org/lwjgl/opengl/EXTMultiDrawArrays.java @@ -34,6 +34,7 @@ package org.lwjgl.opengl; import java.nio.IntBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class EXTMultiDrawArrays { static native void initNativeStubs() throws LWJGLException; diff --git a/src/java/org/lwjgl/opengl/EXTPointParameters.java b/src/java/org/lwjgl/opengl/EXTPointParameters.java index 027d7a1e..da1f3973 100644 --- a/src/java/org/lwjgl/opengl/EXTPointParameters.java +++ b/src/java/org/lwjgl/opengl/EXTPointParameters.java @@ -34,6 +34,7 @@ package org.lwjgl.opengl; import java.nio.FloatBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class EXTPointParameters { public static final int GL_POINT_SIZE_MIN_EXT = 0x8126; diff --git a/src/java/org/lwjgl/opengl/EXTSecondaryColor.java b/src/java/org/lwjgl/opengl/EXTSecondaryColor.java index 7b1c84d3..c449510a 100644 --- a/src/java/org/lwjgl/opengl/EXTSecondaryColor.java +++ b/src/java/org/lwjgl/opengl/EXTSecondaryColor.java @@ -36,6 +36,7 @@ import java.nio.ByteBuffer; import java.nio.FloatBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class EXTSecondaryColor { public static final int GL_COLOR_SUM_EXT = 0x8458; @@ -56,18 +57,18 @@ public final class EXTSecondaryColor { public static void glSecondaryColorPointerEXT(int size, boolean unsigned, int stride, ByteBuffer pPointer) { BufferChecks.checkDirect(pPointer); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglSecondaryColorPointerEXT(size, unsigned ? GL11.GL_UNSIGNED_BYTE: GL11.GL_BYTE, stride, pPointer, pPointer.position()); } public static void glSecondaryColorPointerEXT(int size, int stride, FloatBuffer pPointer) { BufferChecks.checkDirect(pPointer); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglSecondaryColorPointerEXT(size, GL11.GL_FLOAT, stride, pPointer, pPointer.position()<<2); } private static native void nglSecondaryColorPointerEXT(int size, int type, int stride, Buffer pPointer, int pPointer_offset); public static void glSecondaryColorPointerEXT(int size, int type, int stride, int buffer_offset) { - BufferChecks.ensureArrayVBOenabled(); + GLBufferChecks.ensureArrayVBOenabled(); nglSecondaryColorPointerEXTVBO(size, type, stride, buffer_offset); } private static native void nglSecondaryColorPointerEXTVBO(int size, int type, int stride, int buffer_offset); diff --git a/src/java/org/lwjgl/opengl/EXTVertexShader.java b/src/java/org/lwjgl/opengl/EXTVertexShader.java index 9fb3a8c9..4566dc24 100644 --- a/src/java/org/lwjgl/opengl/EXTVertexShader.java +++ b/src/java/org/lwjgl/opengl/EXTVertexShader.java @@ -38,6 +38,7 @@ import java.nio.IntBuffer; import java.nio.ShortBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class EXTVertexShader { public static final int GL_VERTEX_SHADER_EXT = 0x8780; @@ -276,27 +277,27 @@ public final class EXTVertexShader { private static native void nglVariantuivEXT(int id, IntBuffer piAddr, int piAddr_offset); public static void glVariantPointerEXT(int id, boolean unsigned, int stride, ByteBuffer pAddr) { BufferChecks.checkDirect(pAddr); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglVariantPointerEXT(id, unsigned ? GL11.GL_UNSIGNED_BYTE : GL11.GL_BYTE, stride, pAddr, pAddr.position()); } public static void glVariantPointerEXT(int id, boolean unsigned, int stride, ShortBuffer pAddr) { BufferChecks.checkDirect(pAddr); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglVariantPointerEXT(id, unsigned ? GL11.GL_UNSIGNED_SHORT : GL11.GL_SHORT, stride, pAddr, pAddr.position()<<1); } public static void glVariantPointerEXT(int id, int stride, FloatBuffer pAddr) { BufferChecks.checkDirect(pAddr); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglVariantPointerEXT(id, GL11.GL_FLOAT, stride, pAddr, pAddr.position()<<2); } public static void glVariantPointerEXT(int id, boolean unsigned, int stride, IntBuffer pAddr) { BufferChecks.checkDirect(pAddr); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglVariantPointerEXT(id, unsigned ? GL11.GL_UNSIGNED_INT : GL11.GL_INT, stride, pAddr, pAddr.position()<<2); } private static native void nglVariantPointerEXT(int id, int type, int stride, Buffer pAddr, int pAddr_offset); public static void glVariantPointerEXT(int id, int type, int stride, int buffer_offset) { - BufferChecks.ensureArrayVBOenabled(); + GLBufferChecks.ensureArrayVBOenabled(); nglVariantPointerEXTVBO(id, type, stride, buffer_offset); } private static native void nglVariantPointerEXTVBO(int id, int type, int stride, int buffer_offset); diff --git a/src/java/org/lwjgl/opengl/EXTVertexWeighting.java b/src/java/org/lwjgl/opengl/EXTVertexWeighting.java index 48d4ff57..b9004cf5 100644 --- a/src/java/org/lwjgl/opengl/EXTVertexWeighting.java +++ b/src/java/org/lwjgl/opengl/EXTVertexWeighting.java @@ -35,6 +35,7 @@ import java.nio.Buffer; import java.nio.FloatBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class EXTVertexWeighting { public static final int GL_MODELVIEW0_STACK_DEPTH_EXT = 0x0BA3; /* alias to MODELVIEW_STACK_DEPTH */ @@ -57,12 +58,12 @@ public final class EXTVertexWeighting { public static void glVertexWeightPointerEXT(int size, int stride, FloatBuffer pPointer) { BufferChecks.checkDirect(pPointer); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglVertexWeightPointerEXT(size, GL11.GL_FLOAT, stride, pPointer, pPointer.position()<<2); } private static native void nglVertexWeightPointerEXT(int size, int type, int stride, Buffer pPointer, int pPointer_offset); public static void glVertexWeightPointerEXT(int size, int type, int stride, int buffer_offset) { - BufferChecks.ensureArrayVBOenabled(); + GLBufferChecks.ensureArrayVBOenabled(); nglVertexWeightPointerEXTVBO(size, type, stride, buffer_offset); } private static native void nglVertexWeightPointerEXTVBO(int size, int type, int stride, int buffer_offset); diff --git a/src/java/org/lwjgl/opengl/GL11.java b/src/java/org/lwjgl/opengl/GL11.java index 2189a300..9c32a910 100644 --- a/src/java/org/lwjgl/opengl/GL11.java +++ b/src/java/org/lwjgl/opengl/GL11.java @@ -31,6 +31,8 @@ */ package org.lwjgl.opengl; +import org.lwjgl.BufferChecks; + import java.nio.*; import java.nio.Buffer; import java.nio.BufferUnderflowException; @@ -769,17 +771,17 @@ public final class GL11 { public static void glColorPointer(int size, boolean unsigned, int stride, ByteBuffer pointer) { BufferChecks.checkDirect(pointer); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglColorPointer(size, unsigned ? GL_UNSIGNED_BYTE : GL_BYTE, stride, pointer, pointer.position()); } public static void glColorPointer(int size, int stride, FloatBuffer pointer) { BufferChecks.checkDirect(pointer); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglColorPointer(size, GL_FLOAT, stride, pointer, pointer.position() << 2); } private static native void nglColorPointer(int size, int type, int stride, Buffer pointer, int pointer_offset); public static void glColorPointer(int size, int type, int stride, int buffer_offset) { - BufferChecks.ensureArrayVBOenabled(); + GLBufferChecks.ensureArrayVBOenabled(); nglColorPointerVBO(size, type, stride, buffer_offset); } private static native void nglColorPointerVBO(int size, int type, int stride, int buffer_offset); @@ -810,47 +812,47 @@ public final class GL11 { public static native void glDisable(int cap); public static void glEdgeFlagPointer(int stride, ByteBuffer pointer) { BufferChecks.checkDirect(pointer); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglEdgeFlagPointer(stride, pointer, pointer.position()); } private static native void nglEdgeFlagPointer(int stride, Buffer pointer, int pointer_offset); public static void glEdgeFlagPointer(int stride, int buffer_offset) { - BufferChecks.ensureArrayVBOenabled(); + GLBufferChecks.ensureArrayVBOenabled(); nglEdgeFlagPointerVBO(stride, buffer_offset); } private static native void nglEdgeFlagPointerVBO(int stride, int buffer_offset); public static native void glEdgeFlag(boolean flag); public static void glDrawPixels(int width, int height, int format, int type, ByteBuffer pixels) { - BufferChecks.checkBuffer(pixels, BufferChecks.calculateImageStorage(format, type, width, height, 1)); + BufferChecks.checkBuffer(pixels, GLBufferChecks.calculateImageStorage(format, type, width, height, 1)); nglDrawPixels(width, height, format, type, pixels, pixels.position()); } public static void glDrawPixels(int width, int height, int format, int type, ShortBuffer pixels) { - BufferChecks.checkBuffer(pixels, BufferChecks.calculateImageStorage(format, type, width, height, 1)>>1); + BufferChecks.checkBuffer(pixels, GLBufferChecks.calculateImageStorage(format, type, width, height, 1)>>1); nglDrawPixels(width, height, format, type, pixels, pixels.position() << 1); } public static void glDrawPixels(int width, int height, int format, int type, IntBuffer pixels) { - BufferChecks.checkBuffer(pixels, BufferChecks.calculateImageStorage(format, type, width, height, 1)>>2); + BufferChecks.checkBuffer(pixels, GLBufferChecks.calculateImageStorage(format, type, width, height, 1)>>2); nglDrawPixels(width, height, format, type, pixels, pixels.position() << 2); } private static native void nglDrawPixels(int width, int height, int format, int type, Buffer pixels, int pixels_offset); public static void glDrawElements(int mode, ByteBuffer indices) { BufferChecks.checkDirect(indices); - BufferChecks.ensureElementVBOdisabled(); + GLBufferChecks.ensureElementVBOdisabled(); nglDrawElements(mode, indices.remaining(), GL_UNSIGNED_BYTE, indices, indices.position()); } public static void glDrawElements(int mode, ShortBuffer indices) { BufferChecks.checkDirect(indices); - BufferChecks.ensureElementVBOdisabled(); + GLBufferChecks.ensureElementVBOdisabled(); nglDrawElements(mode, indices.remaining(), GL_UNSIGNED_SHORT, indices, indices.position() << 1); } public static void glDrawElements(int mode, IntBuffer indices) { BufferChecks.checkDirect(indices); - BufferChecks.ensureElementVBOdisabled(); + GLBufferChecks.ensureElementVBOdisabled(); nglDrawElements(mode, indices.remaining(), GL_UNSIGNED_INT, indices, indices.position() << 2); } private static native void nglDrawElements(int mode, int count, int type, Buffer indices, int indices_offset); public static void glDrawElements(int mode, int count, int type, int buffer_offset) { - BufferChecks.ensureElementVBOenabled(); + GLBufferChecks.ensureElementVBOenabled(); nglDrawElementsVBO(mode, count, type, buffer_offset); } private static native void nglDrawElementsVBO(int mode, int count, int type, int buffer_offset); @@ -969,27 +971,27 @@ public final class GL11 { public static native boolean glIsEnabled(int cap); public static void glInterleavedArrays(int format, int stride, ByteBuffer pointer) { BufferChecks.checkDirect(pointer); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglInterleavedArrays(format, stride, pointer, pointer.position()); } public static void glInterleavedArrays(int format, int stride, ShortBuffer pointer) { BufferChecks.checkDirect(pointer); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglInterleavedArrays(format, stride, pointer, pointer.position() << 1); } public static void glInterleavedArrays(int format, int stride, IntBuffer pointer) { BufferChecks.checkDirect(pointer); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglInterleavedArrays(format, stride, pointer, pointer.position() << 2); } public static void glInterleavedArrays(int format, int stride, FloatBuffer pointer) { BufferChecks.checkDirect(pointer); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglInterleavedArrays(format, stride, pointer, pointer.position() << 2); } private static native void nglInterleavedArrays(int format, int stride, Buffer pointer, int pointer_offset); public static void glInterleavedArrays(int format, int stride, int buffer_offset) { - BufferChecks.ensureArrayVBOenabled(); + GLBufferChecks.ensureArrayVBOenabled(); nglInterleavedArraysVBO(format, stride, buffer_offset); } private static native void nglInterleavedArraysVBO(int format, int stride, int buffer_offset); @@ -1019,21 +1021,21 @@ public final class GL11 { int width = 1; int height = 1; int depth = 1; - BufferChecks.checkBuffer(pixels, BufferChecks.calculateImageStorage(format, type, width, height, depth)); + BufferChecks.checkBuffer(pixels, GLBufferChecks.calculateImageStorage(format, type, width, height, depth)); nglGetTexImage(target, level, format, type, pixels, pixels.position()); } public static void glGetTexImage(int target, int level, int format, int type, ShortBuffer pixels) { int width = 1; int height = 1; int depth = 1; - BufferChecks.checkBuffer(pixels, BufferChecks.calculateImageStorage(format, type, width, height, depth)>>1); + BufferChecks.checkBuffer(pixels, GLBufferChecks.calculateImageStorage(format, type, width, height, depth)>>1); nglGetTexImage(target, level, format, type, pixels, pixels.position() << 1); } public static void glGetTexImage(int target, int level, int format, int type, IntBuffer pixels) { int width = 1; int height = 1; int depth = 1; - BufferChecks.checkBuffer(pixels, BufferChecks.calculateImageStorage(format, type, width, height, depth)>>2); + BufferChecks.checkBuffer(pixels, GLBufferChecks.calculateImageStorage(format, type, width, height, depth)>>2); nglGetTexImage(target, level, format, type, pixels, pixels.position() << 2); } private static native void nglGetTexImage(int target, int level, int format, int type, Buffer pixels, int pixels_offset); @@ -1163,22 +1165,22 @@ public final class GL11 { public static native void glOrtho(double left, double right, double bottom, double top, double zNear, double zFar); public static void glNormalPointer(int stride, ByteBuffer pointer) { BufferChecks.checkDirect(pointer); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglNormalPointer(GL_BYTE, stride, pointer, pointer.position()); } public static void glNormalPointer(int stride, IntBuffer pointer) { BufferChecks.checkDirect(pointer); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglNormalPointer(GL_INT, stride, pointer, pointer.position() << 2); } public static void glNormalPointer(int stride, FloatBuffer pointer) { BufferChecks.checkDirect(pointer); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglNormalPointer(GL_FLOAT, stride, pointer, pointer.position() << 2); } private static native void nglNormalPointer(int type, int stride, Buffer pointer, int pointer_offset); public static void glNormalPointer(int type, int stride, int buffer_offset) { - BufferChecks.ensureArrayVBOenabled(); + GLBufferChecks.ensureArrayVBOenabled(); nglNormalPointerVBO(type, stride, buffer_offset); } private static native void nglNormalPointerVBO(int type, int stride, int buffer_offset); @@ -1205,15 +1207,15 @@ public final class GL11 { public static native void glRectf(float x1, float y1, float x2, float y2); public static native void glRecti(int x1, int y1, int x2, int y2); public static void glReadPixels(int x, int y, int width, int height, int format, int type, ByteBuffer pixels) { - BufferChecks.checkBuffer(pixels, BufferChecks.calculateImageStorage(format, type, width, height, 1)); + BufferChecks.checkBuffer(pixels, GLBufferChecks.calculateImageStorage(format, type, width, height, 1)); nglReadPixels(x, y, width, height, format, type, pixels, pixels.position()); } public static void glReadPixels(int x, int y, int width, int height, int format, int type, ShortBuffer pixels) { - BufferChecks.checkBuffer(pixels, BufferChecks.calculateImageStorage(format, type, width, height, 1)>>1); + BufferChecks.checkBuffer(pixels, GLBufferChecks.calculateImageStorage(format, type, width, height, 1)>>1); nglReadPixels(x, y, width, height, format, type, pixels, pixels.position() << 1); } public static void glReadPixels(int x, int y, int width, int height, int format, int type, IntBuffer pixels) { - BufferChecks.checkBuffer(pixels, BufferChecks.calculateImageStorage(format, type, width, height, 1)>>2); + BufferChecks.checkBuffer(pixels, GLBufferChecks.calculateImageStorage(format, type, width, height, 1)>>2); nglReadPixels(x, y, width, height, format, type, pixels, pixels.position() << 2); } private static native void nglReadPixels(int x, int y, int width, int height, int format, int type, Buffer pixels, int pixels_offset); @@ -1251,17 +1253,17 @@ public final class GL11 { public static native void glStencilFunc(int func, int ref, int mask); public static void glVertexPointer(int size, int stride, FloatBuffer pointer) { BufferChecks.checkDirect(pointer); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglVertexPointer(size, GL_FLOAT, stride, pointer, pointer.position() << 2); } public static void glVertexPointer(int size, int stride, IntBuffer pointer) { BufferChecks.checkDirect(pointer); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglVertexPointer(size, GL_INT, stride, pointer, pointer.position() << 2); } private static native void nglVertexPointer(int size, int type, int stride, Buffer pointer, int pointer_offset); public static void glVertexPointer(int size, int type, int stride, int buffer_offset) { - BufferChecks.ensureArrayVBOenabled(); + GLBufferChecks.ensureArrayVBOenabled(); nglVertexPointerVBO(size, type, stride, buffer_offset); } private static native void nglVertexPointerVBO(int size, int type, int stride, int buffer_offset); @@ -1273,28 +1275,28 @@ public final class GL11 { public static native void glVertex4i(int x, int y, int z, int w); public static native void glTranslatef(float x, float y, float z); public static void glTexSubImage2D(int target, int level, int xoffset, int yoffset, int width, int height, int format, int type, ByteBuffer pixels) { - BufferChecks.checkBuffer(pixels, BufferChecks.calculateImageStorage(format, type, width, height, 1)); + BufferChecks.checkBuffer(pixels, GLBufferChecks.calculateImageStorage(format, type, width, height, 1)); nglTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels, pixels.position()); } public static void glTexSubImage2D(int target, int level, int xoffset, int yoffset, int width, int height, int format, int type, ShortBuffer pixels) { - BufferChecks.checkBuffer(pixels, BufferChecks.calculateImageStorage(format, type, width, height, 1)>>1); + BufferChecks.checkBuffer(pixels, GLBufferChecks.calculateImageStorage(format, type, width, height, 1)>>1); nglTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels, pixels.position() << 1); } public static void glTexSubImage2D(int target, int level, int xoffset, int yoffset, int width, int height, int format, int type, IntBuffer pixels) { - BufferChecks.checkBuffer(pixels, BufferChecks.calculateImageStorage(format, type, width, height, 1)>>2); + BufferChecks.checkBuffer(pixels, GLBufferChecks.calculateImageStorage(format, type, width, height, 1)>>2); nglTexSubImage2D(target, level, xoffset, yoffset, width, height, format, type, pixels, pixels.position() << 2); } private static native void nglTexSubImage2D(int target, int level, int xoffset, int yoffset, int width, int height, int format, int type, Buffer pixels, int pixels_offset); public static void glTexSubImage1D(int target, int level, int xoffset, int width, int format, int type, ByteBuffer pixels) { - BufferChecks.checkBuffer(pixels, BufferChecks.calculateImageStorage(format, type, width, 1, 1)); + BufferChecks.checkBuffer(pixels, GLBufferChecks.calculateImageStorage(format, type, width, 1, 1)); nglTexSubImage1D(target, level, xoffset, width, format, type, pixels, pixels.position()); } public static void glTexSubImage1D(int target, int level, int xoffset, int width, int format, int type, ShortBuffer pixels) { - BufferChecks.checkBuffer(pixels, BufferChecks.calculateImageStorage(format, type, width, 1, 1)>>1); + BufferChecks.checkBuffer(pixels, GLBufferChecks.calculateImageStorage(format, type, width, 1, 1)>>1); nglTexSubImage1D(target, level, xoffset, width, format, type, pixels, pixels.position() << 1); } public static void glTexSubImage1D(int target, int level, int xoffset, int width, int format, int type, IntBuffer pixels) { - BufferChecks.checkBuffer(pixels, BufferChecks.calculateImageStorage(format, type, width, 1, 1)>>2); + BufferChecks.checkBuffer(pixels, GLBufferChecks.calculateImageStorage(format, type, width, 1, 1)>>2); nglTexSubImage1D(target, level, xoffset, width, format, type, pixels, pixels.position() << 2); } private static native void nglTexSubImage1D(int target, int level, int xoffset, int width, int format, int type, Buffer pixels, int pixels_offset); @@ -1311,36 +1313,36 @@ public final class GL11 { } private static native void nglTexParameteriv(int target, int pname, IntBuffer param, int param_position); public static void glTexImage2D(int target, int level, int internalformat, int width, int height, int border, int format, int type, ByteBuffer pixels) { - BufferChecks.checkBuffer(pixels, BufferChecks.calculateImageStorage(format, type, width, height, 1)); + BufferChecks.checkBuffer(pixels, GLBufferChecks.calculateImageStorage(format, type, width, height, 1)); nglTexImage2D(target, level, internalformat, width, height, border, format, type, pixels, pixels.position()); } public static void glTexImage2D(int target, int level, int internalformat, int width, int height, int border, int format, int type, ShortBuffer pixels) { - BufferChecks.checkBuffer(pixels, BufferChecks.calculateImageStorage(format, type, width, height, 1)>>1); + BufferChecks.checkBuffer(pixels, GLBufferChecks.calculateImageStorage(format, type, width, height, 1)>>1); nglTexImage2D(target, level, internalformat, width, height, border, format, type, pixels, pixels.position() << 1); } public static void glTexImage2D(int target, int level, int internalformat, int width, int height, int border, int format, int type, IntBuffer pixels) { - BufferChecks.checkBuffer(pixels, BufferChecks.calculateImageStorage(format, type, width, height, 1)>>2); + BufferChecks.checkBuffer(pixels, GLBufferChecks.calculateImageStorage(format, type, width, height, 1)>>2); nglTexImage2D(target, level, internalformat, width, height, border, format, type, pixels, pixels.position() << 2); } public static void glTexImage2D(int target, int level, int internalformat, int width, int height, int border, int format, int type, FloatBuffer pixels) { - BufferChecks.checkBuffer(pixels, BufferChecks.calculateImageStorage(format, type, width, height, 1)>>2); + BufferChecks.checkBuffer(pixels, GLBufferChecks.calculateImageStorage(format, type, width, height, 1)>>2); nglTexImage2D(target, level, internalformat, width, height, border, format, type, pixels, pixels.position() << 2); } private static native void nglTexImage2D(int target, int level, int internalformat, int width, int height, int border, int format, int type, Buffer pixels, int pixels_offset); public static void glTexImage1D(int target, int level, int internalformat, int width, int border, int format, int type, ByteBuffer pixels) { - BufferChecks.checkBuffer(pixels, BufferChecks.calculateImageStorage(format, type, width, 1, 1)); + BufferChecks.checkBuffer(pixels, GLBufferChecks.calculateImageStorage(format, type, width, 1, 1)); nglTexImage1D(target, level, internalformat, width, border, format, type, pixels, pixels.position()); } public static void glTexImage1D(int target, int level, int internalformat, int width, int border, int format, int type, ShortBuffer pixels) { - BufferChecks.checkBuffer(pixels, BufferChecks.calculateImageStorage(format, type, width, 1, 1)>>1); + BufferChecks.checkBuffer(pixels, GLBufferChecks.calculateImageStorage(format, type, width, 1, 1)>>1); nglTexImage1D(target, level, internalformat, width, border, format, type, pixels, pixels.position() << 1); } public static void glTexImage1D(int target, int level, int internalformat, int width, int border, int format, int type, IntBuffer pixels) { - BufferChecks.checkBuffer(pixels, BufferChecks.calculateImageStorage(format, type, width, 1, 1)>>2); + BufferChecks.checkBuffer(pixels, GLBufferChecks.calculateImageStorage(format, type, width, 1, 1)>>2); nglTexImage1D(target, level, internalformat, width, border, format, type, pixels, pixels.position() << 2); } public static void glTexImage1D(int target, int level, int internalformat, int width, int border, int format, int type, FloatBuffer pixels) { - BufferChecks.checkBuffer(pixels, BufferChecks.calculateImageStorage(format, type, width, 1, 1)>>2); + BufferChecks.checkBuffer(pixels, GLBufferChecks.calculateImageStorage(format, type, width, 1, 1)>>2); nglTexImage1D(target, level, internalformat, width, border, format, type, pixels, pixels.position() << 2); } private static native void nglTexImage1D(int target, int level, int internalformat, int width, int border, int format, int type, Buffer pixels, int pixels_offset); @@ -1370,12 +1372,12 @@ public final class GL11 { private static native void nglTexEnviv(int target, int pname, IntBuffer params, int params_offset); public static void glTexCoordPointer(int size, int stride, FloatBuffer pointer) { BufferChecks.checkDirect(pointer); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglTexCoordPointer(size, GL_FLOAT, stride, pointer, pointer.position() << 2); } private static native void nglTexCoordPointer(int size, int type, int stride, Buffer pointer, int pointer_offset); public static void glTexCoordPointer(int size, int type, int stride, int buffer_offset) { - BufferChecks.ensureArrayVBOenabled(); + GLBufferChecks.ensureArrayVBOenabled(); nglTexCoordPointerVBO(size, type, stride, buffer_offset); } private static native void nglTexCoordPointerVBO(int size, int type, int stride, int buffer_offset); diff --git a/src/java/org/lwjgl/opengl/GL12.java b/src/java/org/lwjgl/opengl/GL12.java index 16d5b2b9..86d3605f 100644 --- a/src/java/org/lwjgl/opengl/GL12.java +++ b/src/java/org/lwjgl/opengl/GL12.java @@ -39,6 +39,7 @@ import java.nio.IntBuffer; import java.nio.ShortBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; /** * $Id$ @@ -95,56 +96,56 @@ public final class GL12 { public static void glDrawRangeElements(int mode, int start, int end, ByteBuffer indices) { BufferChecks.checkDirect(indices); - BufferChecks.ensureElementVBOdisabled(); + GLBufferChecks.ensureElementVBOdisabled(); nglDrawRangeElements(mode, start, end, indices.remaining(), GL11.GL_UNSIGNED_BYTE, indices, indices.position()); } public static void glDrawRangeElements(int mode, int start, int end, ShortBuffer indices) { BufferChecks.checkDirect(indices); - BufferChecks.ensureElementVBOdisabled(); + GLBufferChecks.ensureElementVBOdisabled(); nglDrawRangeElements(mode, start, end, indices.remaining(), GL11.GL_UNSIGNED_SHORT, indices, indices.position() << 1); } public static void glDrawRangeElements(int mode, int start, int end, IntBuffer indices) { BufferChecks.checkDirect(indices); - BufferChecks.ensureElementVBOdisabled(); + GLBufferChecks.ensureElementVBOdisabled(); nglDrawRangeElements(mode, start, end, indices.remaining(), GL11.GL_UNSIGNED_INT, indices, indices.position() << 2); } private static native void nglDrawRangeElements(int mode, int start, int end, int count, int type, Buffer indices, int indices_offset); public static void glDrawRangeElements(int mode, int start, int end, int count, int type, int buffer_offset) { - BufferChecks.ensureElementVBOenabled(); + GLBufferChecks.ensureElementVBOenabled(); nglDrawRangeElementsVBO(mode, start, end, count, type, buffer_offset); } private static native void nglDrawRangeElementsVBO(int mode, int start, int end, int count, int type, int buffer_offset); public static void glTexImage3D(int target, int level, int internalFormat, int width, int height, int depth, int border, int format, int type, ByteBuffer pixels) { - BufferChecks.checkBuffer(pixels, BufferChecks.calculateImageStorage(format, type, width, height, depth)); + BufferChecks.checkBuffer(pixels, GLBufferChecks.calculateImageStorage(format, type, width, height, depth)); nglTexImage3D(target, level, internalFormat, width, height, depth, border, format, type, pixels, pixels.position()); } public static void glTexImage3D(int target, int level, int internalFormat, int width, int height, int depth, int border, int format, int type, ShortBuffer pixels) { - BufferChecks.checkBuffer(pixels, BufferChecks.calculateImageStorage(format, type, width, height, depth)>>1); + BufferChecks.checkBuffer(pixels, GLBufferChecks.calculateImageStorage(format, type, width, height, depth)>>1); nglTexImage3D(target, level, internalFormat, width, height, depth, border, format, type, pixels, pixels.position() << 1); } public static void glTexImage3D(int target, int level, int internalFormat, int width, int height, int depth, int border, int format, int type, IntBuffer pixels) { - BufferChecks.checkBuffer(pixels, BufferChecks.calculateImageStorage(format, type, width, height, depth)>>2); + BufferChecks.checkBuffer(pixels, GLBufferChecks.calculateImageStorage(format, type, width, height, depth)>>2); nglTexImage3D(target, level, internalFormat, width, height, depth, border, format, type, pixels, pixels.position() << 2); } public static void glTexImage3D(int target, int level, int internalFormat, int width, int height, int depth, int border, int format, int type, FloatBuffer pixels) { - BufferChecks.checkBuffer(pixels, BufferChecks.calculateImageStorage(format, type, width, height, depth)>>2); + BufferChecks.checkBuffer(pixels, GLBufferChecks.calculateImageStorage(format, type, width, height, depth)>>2); nglTexImage3D(target, level, internalFormat, width, height, depth, border, format, type, pixels, pixels.position() << 2); } private static native void nglTexImage3D(int target, int level, int internalFormat, int width, int height, int depth, int border, int format, int type, Buffer pixels, int pixels_offset); public static void glTexSubImage3D(int target, int level, int xoffset, int yoffset, int zoffset, int width, int height, int depth, int format, int type, ByteBuffer pixels) { - BufferChecks.checkBuffer(pixels, BufferChecks.calculateImageStorage(format, type, width, height, depth)); + BufferChecks.checkBuffer(pixels, GLBufferChecks.calculateImageStorage(format, type, width, height, depth)); nglTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels, pixels.position()); } public static void glTexSubImage3D(int target, int level, int xoffset, int yoffset, int zoffset, int width, int height, int depth, int format, int type, ShortBuffer pixels) { - BufferChecks.checkBuffer(pixels, BufferChecks.calculateImageStorage(format, type, width, height, depth)>>1); + BufferChecks.checkBuffer(pixels, GLBufferChecks.calculateImageStorage(format, type, width, height, depth)>>1); nglTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels, pixels.position() << 1); } public static void glTexSubImage3D(int target, int level, int xoffset, int yoffset, int zoffset, int width, int height, int depth, int format, int type, IntBuffer pixels) { - BufferChecks.checkBuffer(pixels, BufferChecks.calculateImageStorage(format, type, width, height, depth)>>2); + BufferChecks.checkBuffer(pixels, GLBufferChecks.calculateImageStorage(format, type, width, height, depth)>>2); nglTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels, pixels.position() << 2); } public static void glTexSubImage3D(int target, int level, int xoffset, int yoffset, int zoffset, int width, int height, int depth, int format, int type, FloatBuffer pixels) { - BufferChecks.checkBuffer(pixels, BufferChecks.calculateImageStorage(format, type, width, height, depth)>>2); + BufferChecks.checkBuffer(pixels, GLBufferChecks.calculateImageStorage(format, type, width, height, depth)>>2); nglTexSubImage3D(target, level, xoffset, yoffset, zoffset, width, height, depth, format, type, pixels, pixels.position() << 2); } private static native void nglTexSubImage3D(int target, int level, int xoffset, int yoffset, int zoffset, int width, int height, int depth, int format, int type, Buffer pixels, int pixels_offset); diff --git a/src/java/org/lwjgl/opengl/GL13.java b/src/java/org/lwjgl/opengl/GL13.java index 8ae94a98..42b0c120 100644 --- a/src/java/org/lwjgl/opengl/GL13.java +++ b/src/java/org/lwjgl/opengl/GL13.java @@ -38,6 +38,7 @@ import java.nio.IntBuffer; import java.nio.ShortBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; /** * $Id$ diff --git a/src/java/org/lwjgl/opengl/GL14.java b/src/java/org/lwjgl/opengl/GL14.java index 45ecbf66..2845c9b3 100644 --- a/src/java/org/lwjgl/opengl/GL14.java +++ b/src/java/org/lwjgl/opengl/GL14.java @@ -37,6 +37,7 @@ import java.nio.FloatBuffer; import java.nio.IntBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; /** * $Id$ @@ -94,12 +95,12 @@ public final class GL14 { public static native void glFogCoordf(float coord); public static void glFogCoordPointer(int stride, FloatBuffer data) { BufferChecks.checkDirect(data); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglFogCoordPointer(GL11.GL_FLOAT, stride, data, data.position() << 2); } private static native void nglFogCoordPointer(int type, int stride, Buffer data, int data_offset); public static void glFogCoordPointer(int type, int stride, int buffer_offset) { - BufferChecks.ensureArrayVBOenabled(); + GLBufferChecks.ensureArrayVBOenabled(); nglFogCoordPointerVBO(type, stride, buffer_offset); } private static native void nglFogCoordPointerVBO(int type, int stride, int buffer_offset); @@ -124,17 +125,17 @@ public final class GL14 { public static native void glSecondaryColor3ub (byte red, byte green, byte blue); public static void glSecondaryColorPointer(int size, boolean unsigned, int stride, ByteBuffer data) { BufferChecks.checkDirect(data); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglSecondaryColorPointer(size, unsigned ? GL11.GL_UNSIGNED_BYTE : GL11.GL_BYTE, stride, data, data.position()); } public static void glSecondaryColorPointer(int size, int stride, FloatBuffer data) { BufferChecks.checkDirect(data); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglSecondaryColorPointer(size, GL11.GL_FLOAT, stride, data, data.position() << 2); } private static native void nglSecondaryColorPointer (int size, int type, int stride, Buffer data, int data_offset); public static void glSecondaryColorPointer(int size, int type, int stride, int buffer_offset) { - BufferChecks.ensureArrayVBOenabled(); + GLBufferChecks.ensureArrayVBOenabled(); nglSecondaryColorPointerVBO(size, type, stride, buffer_offset); } private static native void nglSecondaryColorPointerVBO(int size, int type, int stride, int buffer_offset); diff --git a/src/java/org/lwjgl/opengl/GL15.java b/src/java/org/lwjgl/opengl/GL15.java index bcc295c3..13f0cfd8 100644 --- a/src/java/org/lwjgl/opengl/GL15.java +++ b/src/java/org/lwjgl/opengl/GL15.java @@ -34,6 +34,7 @@ package org.lwjgl.opengl; import java.nio.*; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class GL15 { diff --git a/src/java/org/lwjgl/opengl/BufferChecks.java b/src/java/org/lwjgl/opengl/GLBufferChecks.java similarity index 58% rename from src/java/org/lwjgl/opengl/BufferChecks.java rename to src/java/org/lwjgl/opengl/GLBufferChecks.java index 6bf8c8a5..119a5a69 100644 --- a/src/java/org/lwjgl/opengl/BufferChecks.java +++ b/src/java/org/lwjgl/opengl/GLBufferChecks.java @@ -54,168 +54,11 @@ import java.nio.DoubleBuffer; * @author cix_foo * @version $Revision$ */ -class BufferChecks { +class GLBufferChecks { /** Static methods only! */ - private BufferChecks() { + private GLBufferChecks() { } - /** - * Default buffer size for most buffer checks. - */ - private static final int DEFAULT_BUFFER_SIZE = 4; - - /** - * Helper methods to ensure a buffer is direct or null. - */ - static void checkDirectOrNull(ByteBuffer buf) { - if (buf != null) { - checkDirect(buf); - } - } - - static void checkDirectOrNull(FloatBuffer buf) { - if (buf != null) { - checkDirect(buf); - } - } - - static void checkDirectOrNull(ShortBuffer buf) { - if (buf != null) { - checkDirect(buf); - } - } - - static void checkDirectOrNull(IntBuffer buf) { - if (buf != null) { - checkDirect(buf); - } - } - - static void checkDirectOrNull(DoubleBuffer buf) { - if (buf != null) { - checkDirect(buf); - } - } - - /** - * Helper methods to ensure a buffer is direct (and, implicitly, non-null). - */ - static void checkDirectBuffer(Buffer buf) { - if (buf instanceof ByteBuffer) - checkDirect((ByteBuffer)buf); - else if (buf instanceof ShortBuffer) - checkDirect((ShortBuffer)buf); - else if (buf instanceof IntBuffer) - checkDirect((IntBuffer)buf); - else if (buf instanceof FloatBuffer) - checkDirect((FloatBuffer)buf); - else if (buf instanceof DoubleBuffer) - checkDirect((DoubleBuffer)buf); - else - throw new IllegalStateException("Unsupported buffer type"); - } - - static void checkDirect(ByteBuffer buf) { - if (!buf.isDirect()) { - throw new IllegalArgumentException("ByteBuffer is not direct"); - } - } - - static void checkDirect(FloatBuffer buf) { - if (!buf.isDirect()) { - throw new IllegalArgumentException("FloatBuffer is not direct"); - } - } - - static void checkDirect(ShortBuffer buf) { - if (!buf.isDirect()) { - throw new IllegalArgumentException("ShortBuffer is not direct"); - } - } - - static void checkDirect(IntBuffer buf) { - if (!buf.isDirect()) { - throw new IllegalArgumentException("IntBuffer is not direct"); - } - } - - static void checkDirect(DoubleBuffer buf) { - if (!buf.isDirect()) { - throw new IllegalArgumentException("IntBuffer is not direct"); - } - } - - /** - * Helper method to ensure a buffer is big enough to receive data from a - * glGet* operation. - * - * @param buf - * The buffer to check - * @param size - * The minimum buffer size - * @throws BufferOverflowException - */ - private static void checkBufferSize(Buffer buf, int size) { - if (buf.remaining() < size) { - throw new IllegalArgumentException("Number of remaining buffer elements is " + buf.remaining() + ", must be at least " + size); - } - } - - static void checkBuffer(ByteBuffer buf, int size) { - checkBufferSize(buf, size); - checkDirect(buf); - } - - static void checkBuffer(IntBuffer buf, int size) { - checkBufferSize(buf, size); - checkDirect(buf); - } - - static void checkBuffer(ShortBuffer buf, int size) { - checkBufferSize(buf, size); - checkDirect(buf); - } - - static void checkBuffer(FloatBuffer buf, int size) { - checkBufferSize(buf, size); - checkDirect(buf); - } - - static void checkBuffer(DoubleBuffer buf, int size) { - checkBufferSize(buf, size); - checkDirect(buf); - } - - /** - * Helper methods to ensure a buffer is big enough to receive data from a - * glGet* operation. To avoid unnecessarily complex buffer size checking - * we've just set the bar artificially high and insist that any receiving - * buffer has at least 4 remaining(). - * - * @param buf - * The buffer to check - * @throws BufferOverflowException - */ - static void checkBuffer(ByteBuffer buf) { - checkBuffer(buf, DEFAULT_BUFFER_SIZE); - } - - static void checkBuffer(ShortBuffer buf) { - checkBuffer(buf, DEFAULT_BUFFER_SIZE); - } - - static void checkBuffer(FloatBuffer buf) { - checkBuffer(buf, DEFAULT_BUFFER_SIZE); - } - - static void checkBuffer(IntBuffer buf) { - checkBuffer(buf, DEFAULT_BUFFER_SIZE); - } - - static void checkBuffer(DoubleBuffer buf) { - checkBuffer(buf, DEFAULT_BUFFER_SIZE); - } - /** * Helper method to ensure that vertex buffer objects are disabled. If they * are enabled, we'll throw an OpenGLException diff --git a/src/java/org/lwjgl/opengl/NVEvaluators.java b/src/java/org/lwjgl/opengl/NVEvaluators.java index d1800c6f..109aab22 100644 --- a/src/java/org/lwjgl/opengl/NVEvaluators.java +++ b/src/java/org/lwjgl/opengl/NVEvaluators.java @@ -36,6 +36,7 @@ import java.nio.FloatBuffer; import java.nio.IntBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class NVEvaluators { public static final int GL_EVAL_2D_NV = 0x86C0; diff --git a/src/java/org/lwjgl/opengl/NVFence.java b/src/java/org/lwjgl/opengl/NVFence.java index 2f1df995..03f92275 100644 --- a/src/java/org/lwjgl/opengl/NVFence.java +++ b/src/java/org/lwjgl/opengl/NVFence.java @@ -34,6 +34,7 @@ package org.lwjgl.opengl; import java.nio.IntBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class NVFence { public static final int GL_ALL_COMPLETED_NV = 0x84F2; diff --git a/src/java/org/lwjgl/opengl/NVFragmentProgram.java b/src/java/org/lwjgl/opengl/NVFragmentProgram.java index 4b0d0e5d..492807be 100644 --- a/src/java/org/lwjgl/opengl/NVFragmentProgram.java +++ b/src/java/org/lwjgl/opengl/NVFragmentProgram.java @@ -35,6 +35,7 @@ import java.nio.ByteBuffer; import java.nio.FloatBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class NVFragmentProgram extends NVProgram { diff --git a/src/java/org/lwjgl/opengl/NVHalfFloat.java b/src/java/org/lwjgl/opengl/NVHalfFloat.java index 9f30978d..d2c2a718 100644 --- a/src/java/org/lwjgl/opengl/NVHalfFloat.java +++ b/src/java/org/lwjgl/opengl/NVHalfFloat.java @@ -34,6 +34,7 @@ package org.lwjgl.opengl; import java.nio.ShortBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class NVHalfFloat { diff --git a/src/java/org/lwjgl/opengl/NVOcclusionQuery.java b/src/java/org/lwjgl/opengl/NVOcclusionQuery.java index 888c190d..4d893bfe 100644 --- a/src/java/org/lwjgl/opengl/NVOcclusionQuery.java +++ b/src/java/org/lwjgl/opengl/NVOcclusionQuery.java @@ -34,6 +34,7 @@ package org.lwjgl.opengl; import java.nio.IntBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class NVOcclusionQuery { public static final int GL_OCCLUSION_TEST_HP = 0x8165; diff --git a/src/java/org/lwjgl/opengl/NVPixelDataRange.java b/src/java/org/lwjgl/opengl/NVPixelDataRange.java index 06d892b8..ddd60012 100644 --- a/src/java/org/lwjgl/opengl/NVPixelDataRange.java +++ b/src/java/org/lwjgl/opengl/NVPixelDataRange.java @@ -38,6 +38,7 @@ import java.nio.IntBuffer; import java.nio.ShortBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class NVPixelDataRange { diff --git a/src/java/org/lwjgl/opengl/NVPointSprite.java b/src/java/org/lwjgl/opengl/NVPointSprite.java index 86b80a2e..bd0af580 100644 --- a/src/java/org/lwjgl/opengl/NVPointSprite.java +++ b/src/java/org/lwjgl/opengl/NVPointSprite.java @@ -34,6 +34,7 @@ package org.lwjgl.opengl; import java.nio.IntBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class NVPointSprite { public static final int GL_POINT_SPRITE_NV = 0x8861; diff --git a/src/java/org/lwjgl/opengl/NVProgram.java b/src/java/org/lwjgl/opengl/NVProgram.java index 0016e489..3e5414ca 100644 --- a/src/java/org/lwjgl/opengl/NVProgram.java +++ b/src/java/org/lwjgl/opengl/NVProgram.java @@ -36,6 +36,7 @@ import java.nio.ByteBuffer; import java.nio.IntBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public class NVProgram { diff --git a/src/java/org/lwjgl/opengl/NVRegisterCombiners.java b/src/java/org/lwjgl/opengl/NVRegisterCombiners.java index ddacf26a..9e7f9090 100644 --- a/src/java/org/lwjgl/opengl/NVRegisterCombiners.java +++ b/src/java/org/lwjgl/opengl/NVRegisterCombiners.java @@ -35,6 +35,7 @@ import java.nio.FloatBuffer; import java.nio.IntBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class NVRegisterCombiners { public static final int GL_REGISTER_COMBINERS_NV = 0x8522; diff --git a/src/java/org/lwjgl/opengl/NVRegisterCombiners2.java b/src/java/org/lwjgl/opengl/NVRegisterCombiners2.java index 174b89f9..56daa00d 100644 --- a/src/java/org/lwjgl/opengl/NVRegisterCombiners2.java +++ b/src/java/org/lwjgl/opengl/NVRegisterCombiners2.java @@ -34,6 +34,7 @@ package org.lwjgl.opengl; import java.nio.FloatBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class NVRegisterCombiners2 { diff --git a/src/java/org/lwjgl/opengl/NVVertexArrayRange.java b/src/java/org/lwjgl/opengl/NVVertexArrayRange.java index 2bffcaf4..e9e0ce74 100644 --- a/src/java/org/lwjgl/opengl/NVVertexArrayRange.java +++ b/src/java/org/lwjgl/opengl/NVVertexArrayRange.java @@ -35,6 +35,7 @@ import java.nio.Buffer; import java.nio.ByteBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class NVVertexArrayRange { public static final int GL_VERTEX_ARRAY_RANGE_NV = 0x851D; diff --git a/src/java/org/lwjgl/opengl/NVVertexProgram.java b/src/java/org/lwjgl/opengl/NVVertexProgram.java index 129461d8..4cab41e1 100644 --- a/src/java/org/lwjgl/opengl/NVVertexProgram.java +++ b/src/java/org/lwjgl/opengl/NVVertexProgram.java @@ -39,6 +39,7 @@ import java.nio.IntBuffer; import java.nio.ShortBuffer; import org.lwjgl.LWJGLException; +import org.lwjgl.BufferChecks; public final class NVVertexProgram extends NVProgram { @@ -292,7 +293,7 @@ public final class NVVertexProgram extends NVProgram { public static void glVertexAttribPointerNV(int index, int size, boolean unsigned, int stride, ByteBuffer buffer) { BufferChecks.checkDirect(buffer); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglVertexAttribPointerNV( index, size, @@ -304,7 +305,7 @@ public final class NVVertexProgram extends NVProgram { public static void glVertexAttribPointerNV(int index, int size, boolean unsigned, int stride, ShortBuffer buffer) { BufferChecks.checkDirect(buffer); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglVertexAttribPointerNV( index, size, @@ -316,13 +317,13 @@ public final class NVVertexProgram extends NVProgram { public static void glVertexAttribPointerNV(int index, int size, int stride, FloatBuffer buffer) { BufferChecks.checkDirect(buffer); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglVertexAttribPointerNV(index, size, GL11.GL_FLOAT, stride, buffer, buffer.position() << 2); } public static void glVertexAttribPointerNV(int index, int size, boolean unsigned, int stride, IntBuffer buffer) { BufferChecks.checkDirect(buffer); - BufferChecks.ensureArrayVBOdisabled(); + GLBufferChecks.ensureArrayVBOdisabled(); nglVertexAttribPointerNV( index, size, @@ -343,7 +344,7 @@ public final class NVVertexProgram extends NVProgram { // --------------------------- public static void glVertexAttribPointerNV(int index, int size, int type, int stride, int bufferOffset) { - BufferChecks.ensureArrayVBOenabled(); + GLBufferChecks.ensureArrayVBOenabled(); nglVertexAttribPointerNVVBO(index, size, type, stride, bufferOffset); }