Split general buffer checks into org.lwjgl.BufferChecks and the gl specific buffer checks into org.lwjgl.opengl.GLBufferChecks

This commit is contained in:
Elias Naur 2004-07-29 11:20:43 +00:00
parent 89a482e9ce
commit ad1ff19437
45 changed files with 369 additions and 269 deletions

View File

@ -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 <cix_foo@users.sourceforge.net>
* @author elias_naur <elias_naur@users.sourceforge.net>
* @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);
}
}

View File

@ -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)

View File

@ -38,6 +38,7 @@ import java.nio.IntBuffer;
import java.nio.ShortBuffer;
import org.lwjgl.LWJGLException;
import org.lwjgl.BufferChecks;
public final class ARBBufferObject {

View File

@ -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);

View File

@ -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);

View File

@ -34,6 +34,7 @@ package org.lwjgl.opengl;
import java.nio.IntBuffer;
import org.lwjgl.LWJGLException;
import org.lwjgl.BufferChecks;
public final class ARBOcclusionQuery {

View File

@ -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;

View File

@ -39,6 +39,7 @@ import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import org.lwjgl.LWJGLException;
import org.lwjgl.BufferChecks;
public class ARBProgram {

View File

@ -37,6 +37,7 @@ import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import org.lwjgl.LWJGLException;
import org.lwjgl.BufferChecks;
public final class ARBShaderObjects {

View File

@ -38,6 +38,7 @@ import java.nio.IntBuffer;
import java.nio.ShortBuffer;
import org.lwjgl.LWJGLException;
import org.lwjgl.BufferChecks;
public final class ARBTextureCompression
{

View File

@ -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;

View File

@ -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);

View File

@ -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);
}

View File

@ -35,6 +35,7 @@ import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import org.lwjgl.LWJGLException;
import org.lwjgl.BufferChecks;
public final class ARBVertexShader {

View File

@ -34,6 +34,7 @@ package org.lwjgl.opengl;
import java.nio.IntBuffer;
import org.lwjgl.LWJGLException;
import org.lwjgl.BufferChecks;
public final class ATIDrawBuffers {

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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;

View File

@ -35,6 +35,7 @@ import java.nio.FloatBuffer;
import java.nio.IntBuffer;
import org.lwjgl.LWJGLException;
import org.lwjgl.BufferChecks;
public final class ATIVertexAttribArrayObject {

View File

@ -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);

View File

@ -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);

View File

@ -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;

View File

@ -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;

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -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);

View File

@ -38,6 +38,7 @@ import java.nio.IntBuffer;
import java.nio.ShortBuffer;
import org.lwjgl.LWJGLException;
import org.lwjgl.BufferChecks;
/**
* $Id$

View File

@ -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);

View File

@ -34,6 +34,7 @@ package org.lwjgl.opengl;
import java.nio.*;
import org.lwjgl.LWJGLException;
import org.lwjgl.BufferChecks;
public final class GL15 {

View File

@ -54,168 +54,11 @@ import java.nio.DoubleBuffer;
* @author cix_foo <cix_foo@users.sourceforge.net>
* @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

View File

@ -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;

View File

@ -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;

View File

@ -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 {

View File

@ -34,6 +34,7 @@ package org.lwjgl.opengl;
import java.nio.ShortBuffer;
import org.lwjgl.LWJGLException;
import org.lwjgl.BufferChecks;
public final class NVHalfFloat {

View File

@ -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;

View File

@ -38,6 +38,7 @@ import java.nio.IntBuffer;
import java.nio.ShortBuffer;
import org.lwjgl.LWJGLException;
import org.lwjgl.BufferChecks;
public final class NVPixelDataRange {

View File

@ -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;

View File

@ -36,6 +36,7 @@ import java.nio.ByteBuffer;
import java.nio.IntBuffer;
import org.lwjgl.LWJGLException;
import org.lwjgl.BufferChecks;
public class NVProgram {

View File

@ -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;

View File

@ -34,6 +34,7 @@ package org.lwjgl.opengl;
import java.nio.FloatBuffer;
import org.lwjgl.LWJGLException;
import org.lwjgl.BufferChecks;
public final class NVRegisterCombiners2
{

View File

@ -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;

View File

@ -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);
}