Jump to content
  • Advertisement
Sign in to follow this  
mishal153

OpenGL regarding glDrawElements() .... i use TAO library in C#

This topic is 4827 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

hi, i am an OpenGL Newbie and am learning stuff. I tried the following code
double[] Vertices = { 0.0,0.0, 0.0,1.0, 0.5,0.5, 1.0,1.0, 1.0,0.0 };
double[]   Indices  = { 0,1,2 };

glColor3f(255.0f,0.0f,0.0f);
glLoadIdentity();
glOrtho(0.0,1.0,0.0,1.0,0.0,1.0);

glEnableClientState(GL_VERTEX_ARRAY);
glVertexPointer( 2, GL_DOUBLE , 0 , Vertices ); 

glBegin(GL_POLYGON);         //Line A

for( int i = 0; i< 3; i++)          
glArrayElement((int)Indices); 
		
glEnd();                        //Line B

and it draws the a triangle as expected. But when i use glDrawElements( GL_POLYGON , 3 , GL_DOUBLE , Indices ); in place of Lines A to B it does nothing. any idea why? thanx mishal

Share this post


Link to post
Share on other sites
Advertisement
Check the documentation for glDrawElements (yes, that link is python documentation, but only the Python Specification and Python Sample Code sections are python specific). In particular, note the requirements on the type parameter:
Quote:
glDrawElements documentation:
type
Specifies the type of the values in indices. Must be one of GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT, or GL_UNSIGNED_INT.

Enigma

Share this post


Link to post
Share on other sites
thanx. it works now.

(i had a book infron of me sayin the same thing but i guess i am blind !!! wasted good 30 minutes trying everything.....with eyes cloed obviously, bye)

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • 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!