public class RenderEngine {
private FloatBuffer fb;
int vch = 1;
public RenderEngine() {
fb = BufferUtils.createFloatBuffer(100 * 10 * 10 * 6 * 4 * 6);
//place stuff in fb
fb.flip();
}
public void render() {
if(!bFlipped) {
fb.flip();
bFlipped = true;
}
glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_COLOR_ARRAY);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, vch);
glBufferDataARB(GL_ARRAY_BUFFER_ARB, fb, GL_STATIC_DRAW_ARB);
glVertexPointer(3, GL_FLOAT, (3 * 2) << 2, 0);
glColorPointer(3, GL_FLOAT, (3 * 2) * 4, 3 * 4);
glDrawArrays(GL_QUADS, 0, fb.capacity() / 4);
glBindBufferARB(GL_ARRAY_BUFFER_ARB, 0);
glDisableClientState(GL_COLOR_ARRAY);
glDisableClientState(GL_VERTEX_ARRAY);
}
}
This code seems somewhat inefficient to me for a number of reasons:
- The vch variable is defaulted to 1 and I’m not really 100% sure why this works, I imagine this is used for rendering multiple VBOs
- Every time I go to render the VBO, i redo the glBufferData() call, I have seen examples where people call this once when they initialise the VBO and not every render cycle
If anyone could give me any pointers on mistakes I have made please let me know.
(please note, this code does work, I just don’t see it as very efficient which is why I’m asking)