glPointParameter Problem

Started by Erestar, May 09, 2005, 23:30:57

Previous topic - Next topic

Erestar

Can anyone tell me why this:
   int[] pointParams = {1,2,3};
    
    //Draw a big ol' grid
    GL11.glPointSize(0.1f);
    GL14.glPointParameterf(GL14.GL_POINT_SIZE_MIN, 0.1f);
    GL14.glPointParameterf(GL14.GL_POINT_SIZE_MAX, 0.9f);
    GL14.glPointParameter(GL14.GL_POINT_DISTANCE_ATTENUATION,
    		IntBuffer.wrap(pointParams));


would yield a:

Exception in thread "main" java.lang.IllegalArgumentException: Number of remaining buffer elements is 2, must be at least 4
	at org.lwjgl.BufferChecks.checkBufferSize(BufferChecks.java:177)
	at org.lwjgl.BufferChecks.checkBuffer(BufferChecks.java:187)
	at org.lwjgl.opengl.GL14.glPointParameter(GL14.java:145)
	at org.liftedlilt.test.TestDriver.render(TestDriver.java:142)
	at org.liftedlilt.test.TestDriver.run(TestDriver.java:119)
	at org.liftedlilt.test.TestDriver.main(TestDriver.java:55)


Not really sure why its throwing that, as the docs say when you're passing GL_POINT_DISTANCE_ATTENUATION it needs an array of three parameters. I've also tried it passing in a float buffer.

After checking the forums, I've read that there's buffer checking on a lot of get* methods, but I'm not getting, I'm setting (sorry, don't have the source to dig around).

Thanks for any insight!

Erestar

Erestar

Oh, I also screwed around with flipped and rewinding to no avail.

Erestar

I see that the IntBuffer and FloatBuffer need to be direct, so I'm creating a ByteBuffer to hold 4 ints, and passing in 1 as the fourth element of the array (even though it only asks for 3, as I still get the error mentioned in the OP when I only pass in 3). Is this the right way to do this? Doesn't seem like it. All of the points I'm rendering like this don't appear any more, though that's probably a result of the numbers I'm using.

Matzon

this is a security check that lwjgl does - whenever you get a value it wants the bytebuffer to hold at least 16 bytes, even though you only read 1 int (4bytes). Increase the size of the byte buffer to 16 and it should do fine