Best way to update information for VBO?

Started by elias4444, October 29, 2008, 21:40:36

Previous topic - Next topic

elias4444

I'm finally implementing 3D model animation and am interpolating between keyframes. I'm just wondering if I'm using java FloatBuffers correctly for this.

Each frame, I need to update the VBO coordinates and normals data. I thought I could loop through the floatBuffer doing something like this:
for (int i=0;i<coordinates.length;i++) {
    float newcoordinate = coordinates[i];
    floatBuffer.put(i, newcoordinate);
}


But that gives me a java.lang.IndexOutOfBoundsException (either 0, with the above example, or the high number with "i" reaches it's limit), so instead I'm doing this:

floatBuffer.clear();
for (int i=0;i<coordinates.length;i++) {
    float newcoordinate = coordinates[i];
    floatBuffer.put(newcoordinate);
}


I'm mostly worried about the overhead of clearing the FloatBuffer every frame. Or is this just the way it's meant to be done?

Any help is appreciated! Thanks!
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com

princec

clear() doesn't have any overhead, it just resets a couple of pointers.

Cas :)

elias4444

Well that's good news. That means I'm done.  ;D

Always a good feeling.

Thanks!
=-=-=-=-=-======-=-=-=-=-=-
http://www.tommytwisters.com