Main Menu

glDrawElements

Started by bezhod, December 25, 2005, 15:37:41

Previous topic - Next topic

bezhod

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

bezhod

Doh, wrong parameter..

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

must be

GL11.glVertexPointer( 3, 0, verts);