Vertex arrays ?
Hi there !
I''ve heared something about vertex arays. Is it faster ? I guess so. So, I need to know how to do it... I''ve read (in this forum some time ago) that its not good (and fast) to call glVertex3f may times. I don''t know what vertex array looks like. I imagine that it would look like normal array. But i don''t know how to tell OpenGL to draw vertexes from this array. I''ve tried to find something looking like this in gl.h but i didn''t find anything. I imagine that the command would look like glVertexnf( ... ). I just don''t know how to do it...please help me.Send me any www or good tut how to do it. Thanks !!!
Look up:
glDrawArrays
glDrawElements
glVertexPointer
And glColorPointer, glNormalPointer, and glTexCoordPointer.
Yes .
quote:Original post by Lanman
Is it faster?
Yes .
I can''t understand one thing about vertex arrays:
can I use them for drawing for instance several cubes with non-smooth sides? All I have read says they are good for tristrips and nothing more.
can I use them for drawing for instance several cubes with non-smooth sides? All I have read says they are good for tristrips and nothing more.
quote:
can I use them for drawing for instance several cubes with non-smooth sides? All I have read says they are good for tristrips and nothing more
Yes. You can use them to draw GL_POINTS, GL_LINE_STRIP, GL_LINE_LOOP, GL_LINES, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, GL_TRIANGLES, GL_QUAD_STRIP, GL_QUADS, and GL_POLYGON.
Do not share vertex normals along edges for faceted things like cubes. Use 2 GL_TRIANGLES or 1 GL_QUADS per face, instead of sharing vertices with GL_TRIANGLE_STRIP or GL_QUAD_STRIP.
Thanx!!!
Well, finaly I know the command to draw the array...BUT there''s one more thing that I don''t know...how to set up the array (sorry for the newbie question...I''m not a newbie, I''m programming sice my 10 years but I''m triing to work with OpenGL for only less than year)...where can I find an example code...PLEASE...THANX!THANX!THANX! You are probably pissed off when you see every day my new stupid question, huh ?
But thanx !
Well, finaly I know the command to draw the array...BUT there''s one more thing that I don''t know...how to set up the array (sorry for the newbie question...I''m not a newbie, I''m programming sice my 10 years but I''m triing to work with OpenGL for only less than year)...where can I find an example code...PLEASE...THANX!THANX!THANX! You are probably pissed off when you see every day my new stupid question, huh ?
But thanx !
To draw a square (with an extra z coordinate for no reason):
You should also lookup glEnableClientState and glDisableClientState (I forgot about them last time) to use more than just vertices (i.e. to add textures, colors, or normals).
float Data[] = { -1.0f, -1.0f, 0.0f, -1.0f, 1.0f, 0.0f, 1.0f, 1.0f, 0.0f, 1.0f, -1.0f, 0.0f };glVertexPointer(3,GL_FLOAT,0,Data);glDrawArrays(GL_QUAD, 0, 1);
You should also lookup glEnableClientState and glDisableClientState (I forgot about them last time) to use more than just vertices (i.e. to add textures, colors, or normals).
quote:Original post by invective
Yes. You can use them to draw GL_POINTS, GL_LINE_STRIP, GL_LINE_LOOP, GL_LINES, GL_TRIANGLE_STRIP, GL_TRIANGLE_FAN, GL_TRIANGLES, GL_QUAD_STRIP, GL_QUADS, and GL_POLYGON.
Do not share vertex normals along edges for faceted things like cubes. Use 2 GL_TRIANGLES or 1 GL_QUADS per face, instead of sharing vertices with GL_TRIANGLE_STRIP or GL_QUAD_STRIP.
K, but this means a lot of redundant glVertex and glNormal etc, is it still faster than a display list?
quote:Original post by Fritz3DIf you''re drawing anything with hard edges (like a cube), you really have no choice but to duplicate some verticies, whether you''re using display lists or vertex arrays.
K, but this means a lot of redundant glVertex and glNormal etc, is it still faster than a display list?
I''m not really sure what you''re asking, though, because when you''re using vertex arrays, you''re not making calls to glVertex/glNormal at all. The main advantage to vertex arrays is avoiding the overhead of calling those functions repeatedly.
Also, you can place your vertex array code in a display list.
It seems I have missed something...now I get the point. One really needs redundant vertices for the hard edges...ok, thx
This topic is closed to new replies.
Advertisement
Popular Topics
Advertisement