LWJGL Forum

Programming => OpenGL => Topic started by: bezhod on December 25, 2005, 15:37:41

Title: glDrawElements
Post by: bezhod on December 25, 2005, 15:37:41
Hi!

Im trying draw a quad with glDrawElements but I cant get this piece of code working:



setup:

// vertex array
float []vq={0, 0, 0, 5.0f, 0, 0, 5.0f, 4.0f, 0, 0,4.0f, 0};

// index array
int []iq={ 0, 1, 2, 3};

// make buffers
FloatBuffer verts=BufferUtils.createFloatBuffer(vq.length);
IntBuffer ind=BufferUtils.createIntBuffer(iq.length);

verts.put(vq);
ind.put(iq);

verts.flip();
ind.flip();

render:

GL11.glEnableClientState( GL11.GL_VERTEX_ARRAY );
GL11.glVertexPointer( 3,GL11.GL_FLOAT, verts);

GL11.glDrawElements(GL11.GL_QUADS, ind);

GL11.glDisableClientState( GL11.GL_VERTEX_ARRAY );


this renders nothing.. whats wrong?

-bez
Title: glDrawElements
Post by: bezhod on December 28, 2005, 20:12:13
Doh, wrong parameter..

GL11.glVertexPointer( 3,GL11.GL_FLOAT, verts);

must be

GL11.glVertexPointer( 3, 0, verts);