Hello
I start using VBO´s and saw different ways to initialize the buffers.
One is using the opengl.util.BufferUtil classes.
Is this the best way and where do I get it ?
thanks
Hello
I start using VBO´s and saw different ways to initialize the buffers.
One is using the opengl.util.BufferUtil classes.
Is this the best way and where do I get it ?
thanks
Yes. BufferUtil ensures that the byte buffer created is direct and that the correct byte order (native byte order) is used. It’s basically equal to:
ByteBuffer.allocateDirect(size).order(ByteOrder.nativeOrder());
Ok, thanks
but where can I download it ? It was not in the packages that I have downloaded for using jogl.
Ah, you’re using JOGL. BufferUtil is part of LWJGL, which is an alternative to JOGL. Personally I prefer LWJGL, but you can just make your own utility class for buffer creation. To create other buffers (FloatBuffer for example) just create a ByteBuffer (with the code I posted) with 4 times the size (as you’ll need 4 bytes per float) and use asFloatBuffer().
If you’re using JOGL, you don’t use ByteBuffers. You should be able to use a plain-jane array.
wait, what?!? BufferUtil is part of JOGL… it is in: com.sun.opengl.util.BufferUtil
So this is what I usually do:
vertices = ByteBuffer.allocateDirect(totalBuffer * BufferUtil.SIZEOF_FLOAT).order(ByteOrder.nativeOrder()).asFloatBuffer();
You also need to remember to ‘rewind’ the buffer, I think:
vertices.rewind();
No you don’t rewind the buffer, you flip it:
vertices.flip();
Hi
I assume you use an obsolete version of JOGL (JOGL 1.1.1a?). In JOGL 2.0, this class has been renamed Buffers:
http://jogamp.org/deployment/jogamp-next/javadoc/gluegen/javadoc/com/jogamp/common/nio/Buffers.html
I’m sorry, I was busy and many people here gave you confusing answers. I advise you to ask questions specific to JOGL on the official JogAmp forum. Best regards.
Ignore me, listen to the JOGL expert! :yawn:
Ok I ignore you
thanks for all your answers
Hi
Sorry, I didn’t want to be harsh with you and the class Buffers from JOGL works like the class used by our competitor you quoted.
blizzard, I hope you now understand that you don’t need to download another JAR to use the class Buffers. Actually, I assume you were speaking about com.sun.opengl.utils.BufferUtils which was in JOGL 1.1.1a and renamed com.jogamp.common.nio.Buffers in JOGL 2.0.
Nonono, I wasn’t insulted at all, I just felt a little ashamed because I was talking out of my ass! xD
Yes I understand, I found everything and at the moment my first VBO test programms are running well