I’m trying to make rendering VBOs a simpler task. I have this Drawer class with code to render a VBO quad each frame.
public class Drawer {
static int vboVertexHandle;
static int vertices;
static int vertexSize;
public static void drawQuad( int width, int height )
{
boolean initialized = false;
if(!initialized)
{
final int vertices = 6;
final int vertexSize = 6;
FloatBuffer vertexData = BufferUtils.createFloatBuffer(vertices * vertexSize);
vertexData.put(new float[]{0, 0, 0, width, 0, 0, width, height, 0, 0, height, 0});
vertexData.flip();
vboVertexHandle = glGenBuffers();
glBindBuffer(GL_ARRAY_BUFFER, vboVertexHandle);
glBufferData(GL_ARRAY_BUFFER, vertexData, GL_DYNAMIC_DRAW);
glBindBuffer(GL_ARRAY_BUFFER, 0);
System.out.println("boolean...do you work?");
initialized = true;
}
glBindBuffer(GL_ARRAY_BUFFER, vboVertexHandle);
glVertexPointer(vertexSize, GL_FLOAT, 0, 0L);
glEnableClientState(GL_VERTEX_ARRAY);
glDrawArrays(GL_TRIANGLES, 0, vertices);
glDisableClientState(GL_VERTEX_ARRAY);
}
}
I have that boolean there in hopes it wont initialize the VBOs each frame. When I call
Drawer.drawQuad(20, 20);
nothing appears. Why isn’t it working?