It cost me one day to realize it :-\
actually, you should use:
ByteOrder.nativeOrder()
Then it will resolve correctly for the OS your stuff is running on…in your case it will return little endian.
Doesn’t the BufferUtils class do this automatically?
Yup.
You shouldn’t need to set little_endian if your using the BufferUtils…using BufferUtils, you shouldn’t need to set anything.
Hi by the way is there a former post with a clear example of using VBO?
I plan to change my display lists containing calls of GlVertex to VBO as it seems it would be far more quick.
There are many examples in C++ in the following URL
http://www.devmaster.net/forums/index.php?showtopic=360
I also have some code but not very clear
// put this in your init()
public void initBufferObject(GL gl) {
gl.glEnableClientState(GL.GL_VERTEX_ARRAY);
gl.glGenBuffersARB(4, bufID);
gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, bufID[0]);
gl.glBufferDataARB(GL.GL_ARRAY_BUFFER_ARB, vbuf.capacity() ),
vbuf, GL.GL_STATIC_DRAW_ARB);
System.out.println(vbuf.capacity() + " " + counter.end());
gl.glVertexPointer(3, GL.GL_FLOAT, 0, BufferUtils.bufferOffset(0));
vbuf = null;
System.gc();
buf_size = (int) ( );
gl.glBindBufferARB(GL.GL_ELEMENT_ARRAY_BUFFER_ARB, bufID[1]);
gl.glBufferDataARB(GL.GL_ELEMENT_ARRAY_BUFFER_ARB, fbuf.capacity() * BufferUtils.SIZEOF_FLOAT,
fbuf, GL.GL_STATIC_DRAW_ARB);
fbuf = null;
System.gc();
if (vertexNormal) {
gl.glEnableClientState(GL.GL_NORMAL_ARRAY);
gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, bufID[2]);
gl.glBufferDataARB(GL.GL_ARRAY_BUFFER_ARB, nbuf.capacity() * BufferUtils.SIZEOF_FLOAT, nbuf, GL.GL_STATIC_DRAW_ARB);
gl.glNormalPointer(GL.GL_FLOAT, 0, BufferUtils.bufferOffset(0));
nbuf = null;
System.gc();
}
if (RGBPointsAvailable) {
gl.glEnableClientState(GL.GL_COLOR_ARRAY);
gl.glBindBufferARB(GL.GL_ARRAY_BUFFER_ARB, bufID[3]);
gl.glBufferDataARB(GL.GL_ARRAY_BUFFER_ARB, cbuf.capacity(),
cbuf, GL.GL_STATIC_DRAW_ARB);
gl.glColorPointer(3, GL.GL_UNSIGNED_BYTE, 0, BufferUtils.bufferOffset(0));
cbuf = null;
System.gc();
}
}
// put this in your display()
public void drawBufferObject(GL gl) {
gl.glDrawElements(GL.GL_TRIANGLS, numTri * 3, GL.GL_UNSIGNED_INT, BufferUtils.bufferOffset(0)); //last 0 is offset in element-array
}
}
There may be some errors, but I’ve deleted some mess code here.