Advertisement

Cylinders, vertex arrays, vertex lighting.

Started by February 26, 2002 04:54 PM
12 comments, last by Iain Toft 22 years, 11 months ago
I have loads of cylinders that need to be drawn and I''d like to do improve performance and appearance. How can I use vertex arrays to improve the performance and vertex lighting to improve the appearance of my cylinders? I have all the end points calculated before rendering the scene and do not need any gl transformations to draw the scene. Each cylinder is made of 15 quads, or 30 triangles which ever way you look at it :D Iain -= Iain > Chad < Scott =-
-= Iain > Chad < Scott =-
Did you try triangle strips?
Advertisement
Is it possible to draw all the cylinders using only one single triangle strip, or you mean one strip for each cylinder? At the moment I am using quads and drawing ALL cylinders between one glBegin and glEnd statement. Which would be quicker? Couldn't I put all vertex data in a array a use vertex array to draw the quads?
The cylinders are determined by two sets of pre-calculated end points.
Cheers,
Iain

Edited by - Iain Toft on February 27, 2002 9:20:23 AM
-= Iain > Chad < Scott =-
You can use one triangle strip per cylinder, plus two triangle fans for capping.

Yes you can have a vertex array and use it for all your cylinders. You can also do it with display lists.
I''ve used a display list for the track.
i.e

glNewList(TRACK, GL_COMPILE);
glBegin(GL_QUADS);
//all cylinder vertices, normals
glEnd();
glEndList();

void display(void) {
//.....
glCallList(TRACK);
}

The frame rate is quite slow. How could I incorporate the vertex and normal data and use a vertex array?
Cheers
Iain
First of all, I''d recommend using quad strips instead of quads.
You''ll win up to 50%.

Secondly, you should be careful of how many polygons you draw.
If the object if very small on screen (say, around 20x20 pixels) then 10 quads is more than enough.
And if the object is very big you wouldn''t use more than 100 quads (except if you need very smooth lighting).

Thirdly, I don''t know if you draw caps at the top and bottom. Because if you did, I''d recommend triangles (triangle fans, in fact) and you seem to only draw quads.
Advertisement
Did you display list ALL the cylidners into one list ? Or did you display list ONE cylinder and then use glCallList several times ? The latter is MUCH faster. Infact I bet you wouldnt get ANY performance improvement if you put ALL The cylinders into one display list.

Nitzan

-------------------------
www.geocities.com/nitzanw
www.scorchedearth3d.net
-------------------------
Sorry nitzan, but I think he would win some speed.
I agree that it wastes memory and it''s less flexible, but it''s faster I think. He saves the computing time for translations.
All end points for the cylinders are pre-determined so no gl transformations, push or pop matrix op''s are needed. The display list basically has
glBegin(GL_QUADS);
// loads of calls to glVertex3f(..);
glEnd();

Let me re-phrase the question! What is the quickest way to draw cylinders for which I have determined all vertex data for?
Iain
-= Iain > Chad < Scott =-
First of all, you should draw quad strips instead of quads.

Then I''d say a display list is very fast, but if your card support vertex array range, then it may be faster (but more complex to initialize and use, though)

This topic is closed to new replies.

Advertisement