LWJGL
May 21, 2013, 15:52:42 *
Welcome, Guest. Please login or register.
Did you miss your activation email?

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



Pages: [1]
  Print  
Author Topic: BufferSizeException glLoadMatrix  (Read 933 times)
shaddow
Newbie
*
Posts: 5


« on: February 23, 2012, 08:58:56 »

Hi there,

I recently switched from JOGL to LWJGL and I'm currently porting my engine.
Sadly I encountered the following problem:


Quote
Creating 16 buffer
16 capacity, 0 remaining, 16 position, .. flipping..
flipped
16 capacity, 16 remaining, 0 position
Exception in thread "main" java.lang.IllegalArgumentException: Number of remaining buffer elements is 4, must be at least 16. Because at most 16 elements can be returned, a buffer with at least 16 elements is required, regardless of actual returned element count
   at org.lwjgl.BufferChecks.throwBufferSizeException(BufferChecks.java:162)
   at org.lwjgl.BufferChecks.checkBufferSize(BufferChecks.java:189)
   at org.lwjgl.BufferChecks.checkBuffer(BufferChecks.java:244)
   at org.lwjgl.opengl.GL11.glGetInteger(GL11.java:1355)

Please note the debug statements, where i create a floatbuffer from my camera matrix. Nonetheless, this error keeps occuring. As far as google told me, this error was supposed to be resolved by flipping the floatbuffer, but i already did so:

Code:
   glLoadIdentity();

   System.out.println("Creating "+(entity.getMatrix().get().length)+" buffer");
   FloatBuffer floatBuffer = BufferUtils.createFloatBuffer(entity.getMatrix().get().length);
   floatBuffer.put(entity.getMatrix().get());
       System.out.println(floatBuffer.capacity()+" capacity, "+ floatBuffer.remaining()+" remaining, "+ floatBuffer.position()+" position, .. flipping..");
   floatBuffer.flip();
   
       System.out.println("flipped");
       System.out.println(floatBuffer.capacity()+" capacity, "+ floatBuffer.remaining()+" remaining, "+ floatBuffer.position()+" position");

   glLoadMatrix(floatBuffer);

Thank you for your help.

Logged
spasi
Nerdus Imperius
*****
Posts: 752



WWW
« Reply #1 on: February 23, 2012, 10:33:08 »

Quote
Creating 16 buffer
16 capacity, 0 remaining, 16 position, .. flipping..
flipped
16 capacity, 16 remaining, 0 position
Exception in thread "main" java.lang.IllegalArgumentException: Number of remaining buffer elements is 4, must be at least 16. Because at most 16 elements can be returned, a buffer with at least 16 elements is required, regardless of actual returned element count
   at org.lwjgl.BufferChecks.throwBufferSizeException(BufferChecks.java:162)
   at org.lwjgl.BufferChecks.checkBufferSize(BufferChecks.java:189)
   at org.lwjgl.BufferChecks.checkBuffer(BufferChecks.java:244)
   at org.lwjgl.opengl.GL11.glGetInteger(GL11.java:1355)

See the last line, the error comes from glGetInteger, not glLoadMatrix.
Logged
shaddow
Newbie
*
Posts: 5


« Reply #2 on: February 25, 2012, 14:24:09 »

Damn it. I have been so focused on using the right buffer and checking not to use any jogl libs, that i totally overlooked the error resulting from a totally different part of the application..

However, i got my first demo apps running on lwjgl and so far i'm very pleased with the api Wink
Logged
Pages: [1]
  Print  
 
Jump to:  

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