ByteBuffer Error

Started by Hellekin, March 30, 2007, 13:16:23

Previous topic - Next topic

Hellekin

Hello....

  I'm trying to use the glPolygonStipple(java.nio.ByteBuffer mask), but i can't make it run, every time I get the error:

   java.lang.IllegalArgumentException: Number of remaining buffer elements is 4, must be at least 1024

What am I doing wrong?

  byte fly[] = {
	     (byte)0x10, (byte)0x00, (byte)0x00, (byte)0x08};
	    
	       ByteBuffer temp = ByteBuffer.allocateDirect(12);
		   temp.order(ByteOrder.nativeOrder());
		   
	      GL11.glPolygonStipple ((ByteBuffer)temp.put(fly).flip());

Fool Running

The reason you are getting that error is because the glPolygonStipple() method is expecting you to have 1024 bytes in the array you pass in. The stipple pattern is supposed to be a 32x32 pixel mask (i.e. 32x32 = 1024 bits = 128 bytes). I think this is a bug in LWJGL.

http://www.opengl.org/documentation/specs/man_pages/hardcopy/GL/html/gl/polygonstipple.html

EDIT: Even with the bug, you need to pass in more data to the method.

EDIT2: There is a topic with a similar question: http://lwjgl.org/forum/index.php/topic,1528.0.html. To make it easier on themselves (which I completely understand ;D) because the code is generated, they just hard-code the buffer to need to be 1024 bytes (even though only 128 bytes are actually used). In other words, its not a bug, just a design decision.
Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option ;D