Login  Register

Re: Requesting help with VBO's

Posted by Wade Walker on Dec 01, 2012; 11:47pm
URL: https://forum.jogamp.org/Requesting-help-with-VBO-s-tp4027348p4027371.html

Braindrool wrote
1. listDataObjects is just the vertex data?
2. aiVertexBufferIndices is?
3. Could you do the traditional Byte / FloatBuffer as in X = Bytebuffer.allocateDirect( size ).asFloatBuffer().order(Buffer.nativeOrder())? Or however that goes.
1. Oops, I missed a @param when I wrote this :) Yes, listDataObjects is just a list of class instances, each of which is a colored quad in my case. A DataObject is just meant to represent some object in the host application that needs to be drawn. storeVerticesAndColors() is responsible for turning such an object into vertex and color data and putting it in the VBO. Normally apps copy their data into the VBO when it's time to draw, instead of just maintaining it there always (because VBO memory is allocated and managed by the OpenGL kernel driver).

2. There's should be comment for aiVertexBufferIndices at the top of the file. It's the array of integer VBO indices returned by gl2.glGenBuffers().

3. I don't think so. The VBO must be allocated by OpenGL, then you put data into it by "mapping" a FloatBuffer over it as shown. If you call Bytebuffer.allocateDirect() as you showed, you're allocating the memory yourself, it's not being managed by the OpenGL driver, so its contents are unknown to OpenGL.