Buffer checking code

This commit is contained in:
Caspian Rychlik-Prince 2004-02-18 22:31:00 +00:00
parent ecc62164e8
commit e2f13953d2
7 changed files with 91 additions and 78 deletions

View File

@ -126,51 +126,51 @@ public abstract class ARBImaging {
public static final int GL_MINMAX_SINK = 0x8030; public static final int GL_MINMAX_SINK = 0x8030;
public static void glColorTable(int target, int internalFormat, int width, int format, int type, ByteBuffer data) { public static void glColorTable(int target, int internalFormat, int width, int format, int type, ByteBuffer data) {
// TODO: check buffer size valid BufferChecks.checkBuffer(data, 256);
nglColorTable(target, internalFormat, width, format, type, data, data.position()); nglColorTable(target, internalFormat, width, format, type, data, data.position());
} }
public static void glColorTable(int target, int internalFormat, int width, int format, int type, FloatBuffer data) { public static void glColorTable(int target, int internalFormat, int width, int format, int type, FloatBuffer data) {
// TODO: check buffer size valid BufferChecks.checkBuffer(data, 256);
nglColorTable(target, internalFormat, width, format, type, data, data.position() << 2); nglColorTable(target, internalFormat, width, format, type, data, data.position() << 2);
} }
private static native void nglColorTable(int target, int internalFormat, int width, int format, int type, Buffer data, int data_offset); private static native void nglColorTable(int target, int internalFormat, int width, int format, int type, Buffer data, int data_offset);
public static void glColorSubTable(int target, int start, int count, int format, int type, ByteBuffer data) { public static void glColorSubTable(int target, int start, int count, int format, int type, ByteBuffer data) {
// TODO: check buffer size valid BufferChecks.checkBuffer(data, 256);
nglColorSubTable(target, start, count, format, type, data, data.position()); nglColorSubTable(target, start, count, format, type, data, data.position());
} }
public static void glColorSubTable(int target, int start, int count, int format, int type, FloatBuffer data) { public static void glColorSubTable(int target, int start, int count, int format, int type, FloatBuffer data) {
// TODO: check buffer size valid BufferChecks.checkBuffer(data, 256);
nglColorSubTable(target, start, count, format, type, data, data.position() << 2); nglColorSubTable(target, start, count, format, type, data, data.position() << 2);
} }
private static native void nglColorSubTable(int target, int start, int count, int format, int type, Buffer data, int data_offset); private static native void nglColorSubTable(int target, int start, int count, int format, int type, Buffer data, int data_offset);
public static void glColorTableParameter(int target, int pname, IntBuffer params) { public static void glColorTableParameter(int target, int pname, IntBuffer params) {
// TODO: check buffer size valid BufferChecks.checkBuffer(params);
nglColorTableParameteriv(target, pname, params, params.position()); nglColorTableParameteriv(target, pname, params, params.position());
} }
private static native void nglColorTableParameteriv(int target, int pname, IntBuffer params, int data_offset); private static native void nglColorTableParameteriv(int target, int pname, IntBuffer params, int data_offset);
public static void glColorTableParameter(int target, int pname, FloatBuffer params) { public static void glColorTableParameter(int target, int pname, FloatBuffer params) {
// TODO: check buffer size valid BufferChecks.checkBuffer(params);
nglColorTableParameterfv(target, pname, params, params.position()); nglColorTableParameterfv(target, pname, params, params.position());
} }
private static native void nglColorTableParameterfv(int target, int pname, FloatBuffer params, int data_offset); private static native void nglColorTableParameterfv(int target, int pname, FloatBuffer params, int data_offset);
public static native void glCopyColorSubTable(int target, int start, int x, int y, int width); public static native void glCopyColorSubTable(int target, int start, int x, int y, int width);
public static native void glCopyColorTable(int target, int internalformat, int x, int y, int width); public static native void glCopyColorTable(int target, int internalformat, int x, int y, int width);
public static void glGetColorTable(int target, int format, int type, ByteBuffer data) { public static void glGetColorTable(int target, int format, int type, ByteBuffer data) {
// TODO: check buffer size valid BufferChecks.checkBuffer(data, 256);
nglGetColorTable(target, format, type, data, data.position()); nglGetColorTable(target, format, type, data, data.position());
} }
public static void glGetColorTable(int target, int format, int type, FloatBuffer data) { public static void glGetColorTable(int target, int format, int type, FloatBuffer data) {
// TODO: check buffer size valid BufferChecks.checkBuffer(data, 256);
nglGetColorTable(target, format, type, data, data.position()); nglGetColorTable(target, format, type, data, data.position());
} }
private static native void nglGetColorTable(int target, int format, int type, Buffer data, int data_offset); private static native void nglGetColorTable(int target, int format, int type, Buffer data, int data_offset);
public static void glGetColorTableParameter(int target, int pname, IntBuffer params) { public static void glGetColorTableParameter(int target, int pname, IntBuffer params) {
// TODO: check buffer size valid BufferChecks.checkBuffer(params);
nglGetColorTableParameteriv(target, pname, params, params.position()); nglGetColorTableParameteriv(target, pname, params, params.position());
} }
private static native void nglGetColorTableParameteriv(int target, int pname, IntBuffer params, int params_offset); private static native void nglGetColorTableParameteriv(int target, int pname, IntBuffer params, int params_offset);
public static void glGetColorTableParameter(int target, int pname, FloatBuffer params) { public static void glGetColorTableParameter(int target, int pname, FloatBuffer params) {
// TODO: check buffer size valid BufferChecks.checkBuffer(params);
nglGetColorTableParameterfv(target, pname, params, params.position()); nglGetColorTableParameterfv(target, pname, params, params.position());
} }
private static native void nglGetColorTableParameterfv(int target, int pname, FloatBuffer params, int params_offset); private static native void nglGetColorTableParameterfv(int target, int pname, FloatBuffer params, int params_offset);
@ -179,24 +179,24 @@ public abstract class ARBImaging {
public static native void glHistogram(int target, int width, int internalformat, boolean sink); public static native void glHistogram(int target, int width, int internalformat, boolean sink);
public static native void glResetHistogram(int target); public static native void glResetHistogram(int target);
public static void glGetHistogram(int target, boolean reset, int format, int type, ByteBuffer values) { public static void glGetHistogram(int target, boolean reset, int format, int type, ByteBuffer values) {
// TODO: check buffer size valid BufferChecks.checkBuffer(values, 256);
nglGetHistogram(target, reset, format, type, values, values.position()); nglGetHistogram(target, reset, format, type, values, values.position());
} }
public static void glGetHistogram(int target, boolean reset, int format, int type, ShortBuffer values) { public static void glGetHistogram(int target, boolean reset, int format, int type, ShortBuffer values) {
// TODO: check buffer size valid BufferChecks.checkBuffer(values, 256);
nglGetHistogram(target, reset, format, type, values, values.position() << 1); nglGetHistogram(target, reset, format, type, values, values.position() << 1);
} }
public static void glGetHistogram(int target, boolean reset, int format, int type, IntBuffer values) { public static void glGetHistogram(int target, boolean reset, int format, int type, IntBuffer values) {
// TODO: check buffer size valid BufferChecks.checkBuffer(values, 256);
nglGetHistogram(target, reset, format, type, values, values.position() << 2); nglGetHistogram(target, reset, format, type, values, values.position() << 2);
} }
public static void glGetHistogram(int target, boolean reset, int format, int type, FloatBuffer values) { public static void glGetHistogram(int target, boolean reset, int format, int type, FloatBuffer values) {
// TODO: check buffer size valid BufferChecks.checkBuffer(values, 256);
nglGetHistogram(target, reset, format, type, values, values.position() << 2); nglGetHistogram(target, reset, format, type, values, values.position() << 2);
} }
private static native void nglGetHistogram(int target, boolean reset, int format, int type, Buffer values, int values_offset); private static native void nglGetHistogram(int target, boolean reset, int format, int type, Buffer values, int values_offset);
public static void glGetHistogramParameter(int target, int pname, FloatBuffer params) { public static void glGetHistogramParameter(int target, int pname, FloatBuffer params) {
BufferChecks.checkBuffer(params); BufferChecks.checkBuffer(params, 256);
nglGetHistogramParameterfv(target, pname, params, params.position()); nglGetHistogramParameterfv(target, pname, params, params.position());
} }
private static native void nglGetHistogramParameterfv(int target, int pname, FloatBuffer params, int params_offset); private static native void nglGetHistogramParameterfv(int target, int pname, FloatBuffer params, int params_offset);
@ -235,23 +235,47 @@ public abstract class ARBImaging {
} }
private static native void nglGetMinmaxParameteriv(int target, int pname, IntBuffer params, int params_offset); 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) { public static void glConvolutionFilter1D(int target, int internalformat, int width, int format, int type, ByteBuffer image) {
// TODO: check buffer size valid if (image.remaining() < BufferChecks.calculateImageStorage(format, type, width, 1, 1)) {
throw new BufferUnderflowException();
}
nglConvolutionFilter1D(target, internalformat, width, format, type, image, image.position()); 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) { public static void glConvolutionFilter1D(int target, int internalformat, int width, int format, int type, ShortBuffer image) {
// TODO: check buffer size valid if (image.remaining() * 2 < BufferChecks.calculateImageStorage(format, type, width, 1, 1)) {
throw new BufferUnderflowException();
}
nglConvolutionFilter1D(target, internalformat, width, format, type, image, image.position()); 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) { public static void glConvolutionFilter1D(int target, int internalformat, int width, int format, int type, IntBuffer image) {
// TODO: check buffer size valid if (image.remaining() * 4 < BufferChecks.calculateImageStorage(format, type, width, 1, 1)) {
throw new BufferUnderflowException();
}
nglConvolutionFilter1D(target, internalformat, width, format, type, image, image.position()); 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) { public static void glConvolutionFilter1D(int target, int internalformat, int width, int format, int type, FloatBuffer image) {
// TODO: check buffer size valid if (image.remaining() * 4 < BufferChecks.calculateImageStorage(format, type, width, 1, 1)) {
throw new BufferUnderflowException();
}
nglConvolutionFilter1D(target, internalformat, width, format, type, image, image.position()); 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); 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, Buffer image) { public static void glConvolutionFilter2D(int target, int internalformat, int width, int height, int format, int type, ByteBuffer image) {
if (image.remaining() < BufferChecks.calculateImageStorage(format, type, width, height, 1)) {
throw new BufferUnderflowException();
}
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) {
if (image.remaining() * 2 < BufferChecks.calculateImageStorage(format, type, width, height, 1)) {
throw new BufferUnderflowException();
}
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) {
if (image.remaining() * 4 < BufferChecks.calculateImageStorage(format, type, width, height, 1)) {
throw new BufferUnderflowException();
}
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); private static native void nglConvolutionFilter2D(int target, int internalformat, int width, int height, int format, int type, Buffer image, int image_offset);
public static native void glConvolutionParameterf(int target, int pname, float params); public static native void glConvolutionParameterf(int target, int pname, float params);
@ -286,12 +310,12 @@ public abstract class ARBImaging {
} }
private static native void nglGetConvolutionFilter(int target, int format, int type, Buffer image, int image_offset); private static native void nglGetConvolutionFilter(int target, int format, int type, Buffer image, int image_offset);
public static void glGetConvolutionParameter(int target, int pname, FloatBuffer params) { public static void glGetConvolutionParameter(int target, int pname, FloatBuffer params) {
// TODO: check buffer size valid BufferChecks.checkBuffer(params);
nglGetConvolutionParameterfv(target, pname, params, params.position()); nglGetConvolutionParameterfv(target, pname, params, params.position());
} }
private static native void nglGetConvolutionParameterfv(int target, int pname, FloatBuffer params, int params_offset); private static native void nglGetConvolutionParameterfv(int target, int pname, FloatBuffer params, int params_offset);
public static void glGetConvolutionParameter(int target, int pname, IntBuffer params) { public static void glGetConvolutionParameter(int target, int pname, IntBuffer params) {
// TODO: check buffer size valid BufferChecks.checkBuffer(params);
nglGetConvolutionParameteriv(target, pname, params, params.position()); nglGetConvolutionParameteriv(target, pname, params, params.position());
} }
private static native void nglGetConvolutionParameteriv(int target, int pname, IntBuffer params, int params_offset); private static native void nglGetConvolutionParameteriv(int target, int pname, IntBuffer params, int params_offset);

View File

@ -48,13 +48,13 @@ public class ARBTransposeMatrix {
public static final int GL_TRANSPOSE_COLOR_MATRIX_ARB = 0x84E6; public static final int GL_TRANSPOSE_COLOR_MATRIX_ARB = 0x84E6;
public static void glLoadTransposeMatrixARB(FloatBuffer pfMtx) { public static void glLoadTransposeMatrixARB(FloatBuffer pfMtx) {
BufferChecks.checkBuffer(pfMtx); BufferChecks.checkBuffer(pfMtx, 16);
nglLoadTransposeMatrixfARB(pfMtx, pfMtx.position()); nglLoadTransposeMatrixfARB(pfMtx, pfMtx.position());
} }
private static native void nglLoadTransposeMatrixfARB(FloatBuffer pfMtx, int pfMtx_offset); private static native void nglLoadTransposeMatrixfARB(FloatBuffer pfMtx, int pfMtx_offset);
public static void glMultTransposeMatrixfARB(FloatBuffer pfMtx) { public static void glMultTransposeMatrixfARB(FloatBuffer pfMtx) {
BufferChecks.checkBuffer(pfMtx); BufferChecks.checkBuffer(pfMtx, 16);
nglMultTransposeMatrixfARB(pfMtx, pfMtx.position()); nglMultTransposeMatrixfARB(pfMtx, pfMtx.position());
} }
private static native void nglMultTransposeMatrixfARB(FloatBuffer pfMtx, int pfMtx_offset); private static native void nglMultTransposeMatrixfARB(FloatBuffer pfMtx, int pfMtx_offset);

View File

@ -48,45 +48,41 @@ class BufferChecks {
/** Static methods only! */ /** Static methods only! */
private BufferChecks() { private BufferChecks() {
} }
/** The minimum size we'll allow for glGet* operations */
private static final int MIN_BUFFER_SIZE = 16;
/** /**
* The minimum size we'll allow for "large" glGet* operations that can * Default buffer size for most buffer checks.
* return lots of data, eg. glGetPixelMap
*/ */
private static final int MIN_LARGE_BUFFER_SIZE = 256; private static final int DEFAULT_BUFFER_SIZE = 4;
/**
* 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
*/
static void checkBuffer(Buffer buf, int size) {
if (buf.remaining() < size) {
throw new BufferOverflowException();
}
}
/** /**
* Helper method to ensure a buffer is big enough to receive data from a * Helper method to ensure a buffer is big enough to receive data from a
* glGet* operation. To avoid unnecessarily complex buffer size checking * glGet* operation. To avoid unnecessarily complex buffer size checking
* we've just set the bar artificially high and insist that any receiving * we've just set the bar artificially high and insist that any receiving
* buffer has at least 16 remaining(). * buffer has at least 4 remaining().
* *
* @param buf * @param buf
* The buffer to check * The buffer to check
* @throws BufferOverflowException * @throws BufferOverflowException
*/ */
static void checkBuffer(Buffer buf) { static void checkBuffer(Buffer buf) {
if (buf.remaining() < MIN_BUFFER_SIZE) { checkBuffer(buf, DEFAULT_BUFFER_SIZE);
// TODO: I don't think the default MIN_BUFFER_SIZE should be used for other than glGet*
// Others, like glTexEnvf, should use their individual buffer max size (like 4)
// throw new BufferOverflowException();
}
}
/**
* Helper method to ensure a buffer is big enough to receive data from a
* "large" 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 256 remaining().
*
* @param buf
* The buffer to check
* @throws BufferOverflowException
*/
static void checkLargeBuffer(Buffer buf) {
if (buf.remaining() < MIN_LARGE_BUFFER_SIZE) {
throw new BufferOverflowException();
}
} }
/** /**
* Helper method to ensure that vertex buffer objects are disabled. If they * Helper method to ensure that vertex buffer objects are disabled. If they
* are enabled, we'll throw an OpenGLException * are enabled, we'll throw an OpenGLException

View File

@ -862,17 +862,17 @@ public abstract class GL11 {
private static native void nglFeedbackBuffer(int size, int type, FloatBuffer buffer, int buffer_offset); private static native void nglFeedbackBuffer(int size, int type, FloatBuffer buffer, int buffer_offset);
public static void glGetPixelMap(int map, FloatBuffer values) { public static void glGetPixelMap(int map, FloatBuffer values) {
BufferChecks.checkLargeBuffer(values); BufferChecks.checkBuffer(values, 256);
nglGetPixelMapfv(map, values, values.position()); nglGetPixelMapfv(map, values, values.position());
} }
private static native void nglGetPixelMapfv(int map, FloatBuffer values, int values_offset); private static native void nglGetPixelMapfv(int map, FloatBuffer values, int values_offset);
public static void glGetPixelMap(int map, IntBuffer values) { public static void glGetPixelMap(int map, IntBuffer values) {
BufferChecks.checkLargeBuffer(values); BufferChecks.checkBuffer(values, 256);
nglGetPixelMapuiv(map, values, values.position()); nglGetPixelMapuiv(map, values, values.position());
} }
private static native void nglGetPixelMapuiv(int map, IntBuffer values, int values_offset); private static native void nglGetPixelMapuiv(int map, IntBuffer values, int values_offset);
public static void glGetPixelMap(int map, ShortBuffer values) { public static void glGetPixelMap(int map, ShortBuffer values) {
BufferChecks.checkLargeBuffer(values); BufferChecks.checkBuffer(values, 256);
nglGetPixelMapusv(map, values, values.position()); nglGetPixelMapusv(map, values, values.position());
} }
private static native void nglGetPixelMapusv(int map, ShortBuffer values, int values_offset); private static native void nglGetPixelMapusv(int map, ShortBuffer values, int values_offset);
@ -887,11 +887,11 @@ public abstract class GL11 {
} }
private static native void nglGetMaterialiv(int face, int pname, IntBuffer params, int params_offset); private static native void nglGetMaterialiv(int face, int pname, IntBuffer params, int params_offset);
public static void glGetMap(int target, int query, FloatBuffer v) { public static void glGetMap(int target, int query, FloatBuffer v) {
BufferChecks.checkLargeBuffer(v); BufferChecks.checkBuffer(v, 256);
nglGetMapfv(target, query, v, v.position()); nglGetMapfv(target, query, v, v.position());
} }
public static void glGetMap(int target, int query, IntBuffer v) { public static void glGetMap(int target, int query, IntBuffer v) {
BufferChecks.checkLargeBuffer(v); BufferChecks.checkBuffer(v, 256);
nglGetMapiv(target, query, v, v.position()); nglGetMapiv(target, query, v, v.position());
} }
private static native void nglGetMapfv(int target, int query, FloatBuffer v, int v_offset); private static native void nglGetMapfv(int target, int query, FloatBuffer v, int v_offset);
@ -913,22 +913,22 @@ public abstract class GL11 {
} }
private static native void nglGetClipPlane(int plane, DoubleBuffer equation, int equation_offset); private static native void nglGetClipPlane(int plane, DoubleBuffer equation, int equation_offset);
public static void glGetBoolean(int pname, ByteBuffer params) { public static void glGetBoolean(int pname, ByteBuffer params) {
BufferChecks.checkBuffer(params); BufferChecks.checkBuffer(params, 16);
nglGetBooleanv(pname, params, params.position()); nglGetBooleanv(pname, params, params.position());
} }
private static native void nglGetBooleanv(int pname, ByteBuffer params, int params_offset); private static native void nglGetBooleanv(int pname, ByteBuffer params, int params_offset);
public static void glGetDouble(int pname, DoubleBuffer params) { public static void glGetDouble(int pname, DoubleBuffer params) {
BufferChecks.checkBuffer(params); BufferChecks.checkBuffer(params, 16);
nglGetDoublev(pname, params, params.position()); nglGetDoublev(pname, params, params.position());
} }
private static native void nglGetDoublev(int pname, DoubleBuffer params, int params_offset); private static native void nglGetDoublev(int pname, DoubleBuffer params, int params_offset);
public static void glGetFloat(int pname, FloatBuffer params) { public static void glGetFloat(int pname, FloatBuffer params) {
BufferChecks.checkBuffer(params); BufferChecks.checkBuffer(params, 16);
nglGetFloatv(pname, params, params.position()); nglGetFloatv(pname, params, params.position());
} }
private static native void nglGetFloatv(int pname, FloatBuffer params, int params_offset); private static native void nglGetFloatv(int pname, FloatBuffer params, int params_offset);
public static void glGetInteger(int pname, IntBuffer params) { public static void glGetInteger(int pname, IntBuffer params) {
BufferChecks.checkBuffer(params); BufferChecks.checkBuffer(params, 16);
nglGetIntegerv(pname, params, params.position()); nglGetIntegerv(pname, params, params.position());
} }
private static native void nglGetIntegerv(int pname, IntBuffer params, int params_offset); private static native void nglGetIntegerv(int pname, IntBuffer params, int params_offset);
@ -1054,11 +1054,7 @@ public abstract class GL11 {
public static native String glGetString(int name); public static native String glGetString(int name);
public static void glGetPolygonStipple(ByteBuffer mask) { public static void glGetPolygonStipple(ByteBuffer mask) {
// TODO: check buffer size valid. This is a bit more fiddly than you might think; BufferChecks.checkBuffer(mask, 1024);
// it looks like a 32x32 byte array but it might not be according to the spec :/
if (mask.remaining() < 32 * 32) {
throw new BufferOverflowException();
}
nglGetPolygonStipple(mask, mask.position()); nglGetPolygonStipple(mask, mask.position());
} }
private static native void nglGetPolygonStipple(ByteBuffer mask, int mask_offset); private static native void nglGetPolygonStipple(ByteBuffer mask, int mask_offset);
@ -1090,7 +1086,7 @@ public abstract class GL11 {
public static native void glLogicOp(int opcode); public static native void glLogicOp(int opcode);
public static native void glLoadName(int name); public static native void glLoadName(int name);
public static void glLoadMatrix(FloatBuffer m) { public static void glLoadMatrix(FloatBuffer m) {
BufferChecks.checkBuffer(m); BufferChecks.checkBuffer(m, 16);
nglLoadMatrixf(m, m.position()); nglLoadMatrixf(m, m.position());
} }
private static native void nglLoadMatrixf(FloatBuffer m, int m_offset); private static native void nglLoadMatrixf(FloatBuffer m, int m_offset);
@ -1125,10 +1121,7 @@ public abstract class GL11 {
public static native boolean glIsTexture(int texture); public static native boolean glIsTexture(int texture);
public static native void glMatrixMode(int mode); public static native void glMatrixMode(int mode);
public static void glPolygonStipple(ByteBuffer mask) { public static void glPolygonStipple(ByteBuffer mask) {
// TODO: check buffer size valid (again, possibly more complicated than it first appears) BufferChecks.checkBuffer(mask, 1024);
if (mask.remaining() < 32 * 32) {
throw new BufferUnderflowException();
}
nglPolygonStipple(mask, mask.position()); nglPolygonStipple(mask, mask.position());
} }
private static native void nglPolygonStipple(ByteBuffer mask, int mask_offset); private static native void nglPolygonStipple(ByteBuffer mask, int mask_offset);
@ -1178,7 +1171,7 @@ public abstract class GL11 {
public static native void glNewList(int list, int mode); public static native void glNewList(int list, int mode);
public static native void glEndList(); public static native void glEndList();
public static void glMultMatrixf(FloatBuffer m) { public static void glMultMatrixf(FloatBuffer m) {
BufferChecks.checkBuffer(m); BufferChecks.checkBuffer(m, 16);
nglMultMatrixf(m, m.position()); nglMultMatrixf(m, m.position());
} }
private static native void nglMultMatrixf(FloatBuffer m, int m_offset); private static native void nglMultMatrixf(FloatBuffer m, int m_offset);

View File

@ -247,12 +247,12 @@ public abstract class GL13 extends GL12 {
public static native void glMultiTexCoord3f(int target, float s, float t, float r); public static native void glMultiTexCoord3f(int target, float s, float t, float r);
public static native void glMultiTexCoord4f(int target, float s, float t, float r, float q); public static native void glMultiTexCoord4f(int target, float s, float t, float r, float q);
public static void glLoadTransposeMatrix(FloatBuffer m) { public static void glLoadTransposeMatrix(FloatBuffer m) {
BufferChecks.checkBuffer(m); BufferChecks.checkBuffer(m, 16);
nglLoadTransposeMatrixf(m, m.position()); nglLoadTransposeMatrixf(m, m.position());
} }
private static native void nglLoadTransposeMatrixf(FloatBuffer m, int m_offset); private static native void nglLoadTransposeMatrixf(FloatBuffer m, int m_offset);
public static void glMultTransposeMatrix(FloatBuffer m) { public static void glMultTransposeMatrix(FloatBuffer m) {
BufferChecks.checkBuffer(m); BufferChecks.checkBuffer(m, 16);
nglMultTransposeMatrixf(m, m.position()); nglMultTransposeMatrixf(m, m.position());
} }
private static native void nglMultTransposeMatrixf(FloatBuffer m, int m_offset); private static native void nglMultTransposeMatrixf(FloatBuffer m, int m_offset);

View File

@ -40,7 +40,7 @@ package org.lwjgl.opengl;
import java.nio.*; import java.nio.*;
public class GL15 extends GL14 { public abstract class GL15 extends GL14 {
// ---------------------------------------------------------------------- // ----------------------------------------------------------------------
// ---------------------- ARB_vertex_buffer_object ---------------------- // ---------------------- ARB_vertex_buffer_object ----------------------
@ -205,7 +205,7 @@ public class GL15 extends GL14 {
public static native boolean glUnmapBuffer(int target); public static native boolean glUnmapBuffer(int target);
public static void glGetBufferParameter(int target, int pname, IntBuffer params) { public static void glGetBufferParameter(int target, int pname, IntBuffer params) {
// TODO:check buffer size BufferChecks.checkBuffer(params);
nglGetBufferParameteriv(target, pname, params, params.position()); nglGetBufferParameteriv(target, pname, params, params.position());
} }
@ -274,7 +274,7 @@ public class GL15 extends GL14 {
// --------------------------- // ---------------------------
public static void glGetQueryObjecti(int id, int pname, IntBuffer params) { public static void glGetQueryObjecti(int id, int pname, IntBuffer params) {
// TODO: check buffer size BufferChecks.checkBuffer(params);
nglGetQueryObjectiv(id, pname, params, params.position()); nglGetQueryObjectiv(id, pname, params, params.position());
} }
@ -286,7 +286,7 @@ public class GL15 extends GL14 {
// --------------------------- // ---------------------------
public static void glGetQueryObjectui(int id, int pname, IntBuffer params) { public static void glGetQueryObjectui(int id, int pname, IntBuffer params) {
// TODO: check buffer size BufferChecks.checkBuffer(params);
nglGetQueryObjectuiv(id, pname, params, params.position()); nglGetQueryObjectuiv(id, pname, params, params.position());
} }

View File

@ -70,12 +70,12 @@ public class NVEvaluators {
public static final int GL_MAX_RATIONAL_EVAL_ORDER_NV = 0x86D7; public static final int GL_MAX_RATIONAL_EVAL_ORDER_NV = 0x86D7;
public static void glGetMapControlPointsNV(int target, int index, int type, int ustride, int vstride, boolean packed, FloatBuffer pPoints) { public static void glGetMapControlPointsNV(int target, int index, int type, int ustride, int vstride, boolean packed, FloatBuffer pPoints) {
BufferChecks.checkLargeBuffer(pPoints); // TODO:Check buffer size
nglGetMapControlPointsNV(target, index, type, ustride, vstride, packed, pPoints, pPoints.position()<<2); nglGetMapControlPointsNV(target, index, type, ustride, vstride, packed, pPoints, pPoints.position()<<2);
} }
private static native void nglGetMapControlPointsNV(int target, int index, int type, int ustride, int vstride, boolean packed, Buffer pPoints, int pPoints_offset); private static native void nglGetMapControlPointsNV(int target, int index, int type, int ustride, int vstride, boolean packed, Buffer pPoints, int pPoints_offset);
public static void glMapControlPointsNV(int target, int index, int type, int ustride, int vstride, int uorder, int vorder, boolean packed, FloatBuffer pPoints) { public static void glMapControlPointsNV(int target, int index, int type, int ustride, int vstride, int uorder, int vorder, boolean packed, FloatBuffer pPoints) {
BufferChecks.checkLargeBuffer(pPoints); // TODO:Check buffer size
nglMapControlPointsNV(target, index, type, ustride, vstride, uorder, vorder, packed, pPoints, pPoints.position()<<2); nglMapControlPointsNV(target, index, type, ustride, vstride, uorder, vorder, packed, pPoints, pPoints.position()<<2);
} }
private static native void nglMapControlPointsNV(int target, int index, int type, int ustride, int vstride, int uorder, int vorder, boolean packed, Buffer pPoints, int pPoints_offset); private static native void nglMapControlPointsNV(int target, int index, int type, int ustride, int vstride, int uorder, int vorder, boolean packed, Buffer pPoints, int pPoints_offset);