Archived

This topic is now archived and is closed to further replies.

Karg

glDrawElements

Recommended Posts

Karg    133
I've been having trouble with getting glDrawElements to work. In the below code, glDrawArrays works (draws a square), but the glDrawElements won't draw anything. I've tried 0-based and 1-based indices. Here's the code:
		float squareVertices[12] = {0,0,-10,
									-5,0,-10,
									-5,-5,-10,
									0,-5,-10};
		float squareIndices[4] = {1,2,3,4};
		glEnableClientState( GL_VERTEX_ARRAY );
		glVertexPointer( 3, GL_FLOAT, 0, squareVertices );
		//glDrawArrays( GL_POLYGON, 0, 4 );
		glDrawElements( GL_POLYGON, 4, GL_INT, squareIndices );
  
Anyone have an idea? karg [edited by - Karg on January 23, 2004 5:14:15 PM]

Share this post


Link to post
Share on other sites
Karg    133
Yep, two stupid mistakes, changed to unsigned ints for the array and paramater (and switched back to 0-based indices) and it works! Thanks Bob.

karg

Share this post


Link to post
Share on other sites