I'm trying to read and create a VBO from an ArrayList then render it. The problem is that I just render a blank screen. Everything worked fine when I was immediately rendering it; only now with VBO's is it not working.
The game loop looks like this, with Camera calling glTranslate and glRotate functions.
game.clearScreen();
Camera.update(delta);
try {
game.render();
} catch (IOException e) {
System.out.println(e);
}
Display.update();
Display.sync(FRAME_RATE);
Render method:
world.render(vertices,colorVertices);
FloatBuffer VertexPositionData = BufferUtils.createFloatBuffer(vertices.size());
float[] floats = new float[vertices.size()];
int i = 0;
for (Float f : vertices) {
floats[i] = Float.intBitsToFloat(Float.floatToIntBits(f));
i++;
}
VertexPositionData.put(floats);
VertexPositionData.flip();
FloatBuffer VertexColorData = BufferUtils.createFloatBuffer(colorVertices.size());
float[] colorFloats = new float[colorVertices.size()];
int j = 0;
for (Float f : colorVertices) {
colorFloats[j] = Float.intBitsToFloat(Float.floatToIntBits(f));
j++;
}
VertexColorData.put(colorFloats);
VertexColorData.flip();
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER,VBOVertexHandle);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER,VertexPositionData,GL15.GL_STATIC_DRAW);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER,0);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER,VBOColorHandle);
GL15.glBufferData(GL15.GL_ARRAY_BUFFER,VertexColorData,GL15.GL_STATIC_DRAW);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER,0);
GL11.glPushMatrix();
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, VBOVertexHandle);
GL11.glVertexPointer(3, GL11.GL_FLOAT, 0, 0L);
GL15.glBindBuffer(GL15.GL_ARRAY_BUFFER, VBOColorHandle);
GL11.glColorPointer(3, GL11.GL_FLOAT, 0, 0L);
GL11.glDrawArrays(GL11.GL_QUADS, 0, vertices.size()/3);
GL11.glPopMatrix();
The ArrayLists have vertices and linked colors. Each voxel adds its vertices to the ArrayList (instead of immediately rending it).