Bug in BufferChecks

it seems that the BufferChecks.checkBufferSize(Buffer buf, int size) function does not take the Buffer kind into account.

Test code:

// create the buffer: 4 ints -> 16 bytes
IntBuffer fb = BufferUtils.createIntBuffer(4);

// get the current color
GL11.glGetInteger(GL11.GL_CURRENT_COLOR,fb);

// the above gives an exception in BufferChecks, but that’s not true as the intbuffer size is enough to get the integers.

For the example given, yes it’s enough. But we can’t possible know the size of the returned data (unless explictly checking the passed param - bad performance). So we compromise by always requiring at least 16 values, which the current maximum number of values a glGet could return (say, for a matrix).

Anyway, you shouldn’t care. A glGet call should be wrapped in an util class that handles the actual getting to a private buffer and then grab out of this buffer whatever you need (e.g. 4 first values for a color).

a getSize_t() in NIO would have been great.

So you’re going to add an utility for glGet into LWJGL ?

Can you also take a look at the following (Elias too):

a bug here:
http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=LWJGL;action=display;num=1105441572

and

a suggestion here:
http://www.java-gaming.org/cgi-bin/JGNetForums/YaBB.cgi?board=LWJGL;action=display;num=1105525367

Many thanks,

Mik