LWJGL
May 21, 2012, 00:27:36 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

Login with username, password and session length
News: LWJGL 2.8.3 released!
 
   Home   Help Search Login Register  



Pages: [1]
  Print  
Author Topic: ByteBuffer Error  (Read 1775 times)
Hellekin
Newbie
*
Posts: 8


« on: March 30, 2007, 06:16:23 »

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?

Code:
  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());
Logged
Fool Running
Nerdus Imperius
*****
Posts: 647


« Reply #1 on: April 02, 2007, 10:47:07 »

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 Grin) 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.
Logged

Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option Grin
Pages: [1]
  Print  
 
Jump to:  

Powered by MySQL Powered by PHP Powered by SMF 1.1.16 | SMF © 2011, Simple Machines
SMFAds for Free Forums
Valid XHTML 1.0! Valid CSS!