Sign in to follow this  
mishal153

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

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[i]); 
		
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
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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this