Jump to content
  • Advertisement


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



This topic is 5413 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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,
		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
You should really look up glDrawElements in some documentation. There are three mistakes in your code

  • Indices are 0-based.

  • Check what parameters are valid for glDrawElements.

  • Make sure the index array matches the type you pass to glDrawElements.

Share this post

Link to post
Share on other sites
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.


Share this post

Link to post
Share on other sites

  • Advertisement

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!