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

Started by
1 comment, last by mishal153 18 years, 7 months ago
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
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
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)

This topic is closed to new replies.

Advertisement