if glVertex3f(..) is slow how should I draw everything ?

Started by
11 comments, last by cippyboy 21 years, 9 months ago
if glVertex3f(..) is slow how should I draw everything ? I want to draw about 1000 quads and have at least 30 fps . How do I do it ? if glVertex3f(..) is slow ? Is there any other function to draw at vertex level ? Normally at +100 plygons, the framerate begins to go down from 75 fps to 9-11 at 2000 polygons... Why is that ?

Relative Games - My apps

Advertisement
look up vertex arrays these are extremely useful and fast. I'm rendering 270,000 polys at about 40fps with these.

instead of calling glVertex3f for every vertex, you fill an array with your vertex data, and then can render all these in about 3 gl function calls. I'm sure someone will be along with an example soon i just got out of bed and cant think yet

I dont think NeHe has a tutorial on these?

[edited by - Marvin on July 13, 2002 5:40:53 AM]
What exectly do you mean by array ? A vector of coordinates ?
You still draw them with glVertex3f(..) right ?
Could someone give an example ?

Relative Games - My apps

Look up glVertexPointer (and other gl*Pointer functions), glDrawArrays, glDrawElements, and glEnableClientState.

Can anyone tell me of a site or tutorial where these things are applyed ? And if glVertex3f(..) is slow why is it used in most of the tutorials I find on the Net ?

Relative Games - My apps

If found this tutorial by Nutty useful.

I guess most tutorials use glVertex??() calls cause it''s usually easier to understand what''s going on.
quote:Can anyone tell me of a site or tutorial where these things are applyed ?

The Redbook provides articles with source code demonstrating the use of vertex arrays and display lists.

OpenGL Programming Guide (Redbook)
http://www.gamedev.net/reference/count.asp?LinkID=993


The Bluebook details specific functions, such as glVertexPointer, glEnable/DisableClientState, etc...
OpenGL Reference Manual (Bluebook)
http://ask.ii.uib.no/ebt-bin/nph-dweb/dynaweb/SGI_Developer/OpenGL_RM/


quote:And if glVertex3f(..) is slow why is it used in most of the tutorials I find on the Net ?
As Sibbo2001 said, it''s used just for simplicity for the reader.
masterghttp:/masterg.andyc.org
if this is good(And it works for me) it is you`re array drawing ok ?

glEnableClientState(GL_VERTEX_ARRAY);
glEnableClientState(GL_TEXTURE_COORD_ARRAY);
GLfloat vertices []={0,0,0 1,0,0, 1,1,0};
GLfloat tex_coord[]={0,0, 1,0, 1,1};
glTexCoordPointer(2,GL_FLOAT,0,tex_coord);
glVertexPointer(3,GL_FLOAT,0,vertices);
glDrawArray(GL_TRIANGLES,0,3);


I draw a 100-150 poly-s with a function : drawmodel();
When i drawmodel(); 100 times(in the same spot to test performance) ->25 frames

Relative Games - My apps

Tried display lists? I''ve found those easy and amazing to use.

GLuint disp_list = glGenLists(1);

glNewList(disp_list, GL_COMPILE);
glBegin(GL_POINTS);
glVertex3d(0,0,-10);
glEnd();
glEndList();

glCallList(disp_list);

glDeleteLists(disp_list, 1);
-iGore-
there are only 2 main advantages that not using glVertexX calls have.
the smaller one is that you can''t index verticies, and thus take advantage of vertex caches (usually 10 verticies).
The bigger one though, is that when you make a glDrawElements call, there is very little cpu overhead on the thread your using, so, your app can go about it''s business.
But, you will find that if all your app is doing is drawing stuff, ie, there is no _COMPLEX_ ai or physics (etc) going on in the background (and you will be surprised how fast PC''s really are at this stuff ) then using glVertex over drawElements is quite honestly pointless. I''ve tested it. I''ve seen maybe 2% max fsp boosts. Yet if your demanding more of your app, eg physics, then drawElements can be a massive boost (especially if the app works on fixed frequency calculations) - underwhich cases you can see boosts in the order of 5x.

This topic is closed to new replies.

Advertisement