Skip to main content
gamedev.net
🔒 Locked

DrawElements

Started by Oniera Sep 30, 2001 at 12:23 PM 1 replies 550+ views
Original Post
Oniera
Oniera
I seem to be confused about something... In the command: glVertexPointer(3,GL_FLOAT,0,vertexbuffer); the second variable can be set as GL_FLOAT, but in the actual drawing command: glDrawElements() , you''re third variable has to be a type as either GL_UNSIGNED_BYTE, GL_UNSIGNED_SHORT, or GL_UNSIGNED_INT. Well, If I''m allowed to define my data as GL_FLOAT, why can''t I use GL_FLOAT as my type in the glDrawElements command? Demetrios Georgeadis Director/Programmer Oniera Software Artists

www.oniera.com

Demetrios GeorgeadisDirector/ProgrammerOniera Software Artistswww.oniera.com
LousyPhreak
LousyPhreak
the GL_FLOAT in the glVertexPointer references the type of vertex data:


  
struct vertex3d
{
float x,y,z;
};

vertex3d vertexbuffer[100];

glVertexPointer(3,GL_FLOAT,0,vertexbuffer);


means you got 100 vertices which you can index of type 3*float


then when you use glDrawElements() you specify the type if the INDEX array:


  
unsigned int indices={1,2,3,5,3,1};//remember these are 6 entrys (for next call)

glDrawElements(GL_TRIANGLES,6,GL_UNSIGNED_INT,indices);


means you draw 2 (6 elements| 3/tri) triangles (GL_TRIANGLES) and the indices array is of type unsigned int (you can also use ints if your indices arent greater than ~2bil )


mfg Phreak


--
"Input... need input!" - Johnny Five, Short Circuit.
http://mitglied.lycos.de/lousyphreak/

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.