Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Lanman

Vertex arrays ?

This topic is 5996 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 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 !!!

Share this post


Link to post
Share on other sites
Advertisement
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.

Share this post


Link to post
Share on other sites
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.

Share this post


Link to post
Share on other sites
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 !

Share this post


Link to post
Share on other sites
To draw a square (with an extra z coordinate for no reason):
  
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).

Share this post


Link to post
Share on other sites
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?

Share this post


Link to post
Share on other sites
quote:
Original post by Fritz3D
K, but this means a lot of redundant glVertex and glNormal etc, is it still faster than a display list?

If 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.

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.

Share this post


Link to post
Share on other sites
It seems I have missed something...now I get the point. One really needs redundant vertices for the hard edges...ok, thx

Share this post


Link to post
Share on other sites

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