ARB array rebinding

Hi there!

I’ve implemented my jogl engine using ARB vertex buffers. My mesh class holds several float buffers which contain vertex and texture coord information; At rendering time, these buffers are bound using glXXXPointer and displayed using glDrawArrays.

Now I have several cases in which the data in the buffers needs to be updated dynamically. For example, detail-mapped surfaces require their light vectors recomputed and in particle systems, all data needs to be updated constantly.

For my question: Is there any possibility to update those buffers dynamically? Currently, I’m clearing the buffer and then rewriting its data from vertex data stored locally in the mesh. This is horrible … slow and redundant. I realize that during each buffer bind call, gl has to copy data to the gfx card, no way around that. But isn’t there a way to access data in the buffers by reference, avoiding rewriting them every frame? Nio buffers can be backed by arrays, however, jogl only supports direct buffers not backed.

Any ideas would be appreciated!

Cheers,

Wolfgang

Couldn’t you use absolute addressing with the NIO buffers? There’s no need to erase the previous contents of the buffer - just copy the mesh data into the buffer once and then dynamically alter it as needed. For example:

// A float buffer containing the data
FloatBuffer fb …

// Put “value” into array location specified by “index”
fb.put(index, value);

Cheers

Great idea, I’m not all that far into nio, didn’t know this is possible. Not as good as byref, but still saves a lot of time. Beside, its more ellegant :slight_smile:

Thanks a lot

Wolfgang