Skip to main content
GameDev.net gamedev.net
🔒 Locked

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

Started by cippyboy Jul 13, 2002 at 4:33 AM 11 replies 6.8k views
Original Post
cippyboy
cippyboy
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
Marvin
Marvin
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]
cippyboy
cippyboy
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
Null and Void
Null and Void
Look up glVertexPointer (and other gl*Pointer functions), glDrawArrays, glDrawElements, and glEnableClientState.

cippyboy
cippyboy
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
Sibbo2001
Sibbo2001
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.
masterg
masterg
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
cippyboy
cippyboy
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
iGore
iGore
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-
RipTorn
RipTorn
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.
llvllatrix
llvllatrix
If some of the stuff that you''re drawing doesn''t change, use display lists. I modified Trent''s terrain engine and it runs around 500 fps (fast computer ).
PlasticKS
PlasticKS
I think I understand vertex arrays. But I have a question. Can you use multitexturing with them?
Martee
Martee
Yes, you most certainly can. You just have to call glActiveTextureARB() and glClientActiveTextureARB() before calling glTexCoordPointer().
ReactOS - an Open-source operating system compatible with Windows NT apps and drivers

Topic Locked

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

Sign in to reply to this topic.