Hello,
i defiend this method to make my vbo updateable:
public static ByteBuffer updateNonIndexedTextureBuffer( int buffer, float[] data, ByteBuffer oldBuf ){
ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, buffer );
ByteBuffer buf = ARBVertexBufferObject.glMapBufferARB( ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, ARBVertexBufferObject.GL_WRITE_ONLY_ARB, oldBuf );
FloatBuffer fuf = buf.asFloatBuffer();
int vertexIndex = 0;
for (int i = 0; i < data.length; ++i ) {
fuf.put( vertexIndex++, data[i] );
}
ARBVertexBufferObject.glUnmapBufferARB( ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB );
return buf;
}
The frist call contains a null as 3. parameter, then the returning value is reused all the time. My problem is that it doesn't work.
After the first call, my component disappear, seems to have 0 as coordinates. :(
What am i making wrong? Could anyone help me? I haven't found a tutorial but for jogl, but it looks very similar.
If i replace the method body to this one:
public static ByteBuffer updateNonIndexedTextureBuffer( int buffer, float[] data, ByteBuffer oldBuf ){
ARBVertexBufferObject.glBindBufferARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, buffer );
FloatBuffer dbuffer = BufferUtils.createFloatBuffer( data.length );
for( int i=0; i<data.length; ++i )
dbuffer.put( i, data[i]);
ARBVertexBufferObject.glBufferDataARB(ARBVertexBufferObject.GL_ARRAY_BUFFER_ARB, dbuffer, ARBVertexBufferObject.GL_DYNAMIC_DRAW_ARB);
return oldBuf;
}
It works. As far as i know the mapping is much memory friendly that is why i would like to use the mapping version.
Your second function should work just fine. You may want to call dbuffer.rewind() before glBufferDataARB though - I'm not sure if the ARB function call rewinds the buffer for you.