i’m trying run a simple test to see how vertex arrays work (just drawing two triangles on screen), but sort of stuck/confused on how lwjgl does the buffer stuff array stuff here my code so far.
FloatBuffer vertices;
IntBuffer buf;
public void initVariables() {
vertices = BufferUtils.createFloatBuffer(12);
vertices.put(100).put(100).put(300).put(100).put(200).put(250).put(400).put(100).put(600).put(100).put(500).put(250);
vertices.rewind();
buf = BufferUtils.createIntBuffer(12);
buf.put(0).put(1).put(2).put(3).put(4).put(5).put(6).put(7).put(8).put(9).put(10).put(11);
buf.flip();
}
public void mainloop() {
GL11.glClear(GL11.GL_COLOR_BUFFER_BIT | GL11.GL_DEPTH_BUFFER_BIT);
GL11.glColor3f(1.0f, 1.0f, 1.0f);
/*This is what it should do
GL11.glBegin(GL11.GL_TRIANGLES);
GL11.glVertex2f(100, 100);
GL11.glVertex2f(300, 100);
GL11.glVertex2f(200, 250);
GL11.glVertex2f(400, 100);
GL11.glVertex2f(600, 100);
GL11.glVertex2f(500, 250);
GL11.glEnd();*/
GL11.glEnableClientState(GL11.GL_VERTEX_ARRAY);
GL11.glVertexPointer(2, GL11.GL_FLOAT, buf);
GL11.glDrawElements(GL11.GL_TRIANGLES, buf);
}
}