LWJGL
June 19, 2013, 08:24:45 *
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: glBufferDataARB ignores byte order?  (Read 895 times)
qp8
Newbie
*
Posts: 1


« on: April 11, 2012, 20:41:31 »

I'm working on a model loader, and so I can choose if I want to store my vertices data in big endian or little endian. And my code works fine as long as I save in little endian, which is my PC's native byte order. However if I save as big endian it doesn't work, regardless if I set byte order of the bytebuffer to big or little endian, it's as if glBufferDataARB totally ignores the byte order of the buffer. Even when I save my model in little endian, glBufferDataARB ignores the byte order even if I set it to big endian :/

Help, please  Smiley
Logged
Fool Running
Nerdus Imperius
*****
Posts: 759


« Reply #1 on: April 12, 2012, 05:22:48 »

I'm pretty sure OpenGL always uses the native ordering. Setting the order on a buffer is useful only if you put floats, ints, etc into the buffer using one of the built-in methods, it doesn't affect how OpenGL reads it.
Logged

Programmers will, one day, rule the world... and the world won't notice until its too late.Just testing the marquee option Grin
Riven
Newbie
*
Posts: 15


« Reply #2 on: April 12, 2012, 05:44:36 »

There is no reason to support any other endianness that the native one, in performance sensitive/critical code.

To support it requires lots of bit fiddling. If performance it not one of your worries, you can simply do:
Code:
public static FloatBuffer ensureDirectNativeEndian(FloatBuffer fb) {
   if(fb.isDirect() && fb.order() == ByteOrder.nativeOrder()) {
      return fb;
   }

   FloatBuffer copy = BufferUtils.createFloatBuffer(fb.remaining());
   copy.put(fb); // lots of bit fiddling
   copy.flip();

   return copy;
}
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!