Advertisement Jump to content

Archived

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

cippyboy

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

This topic is 6033 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

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 ?

Share this post


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

Share this post


Link to post
Share on other sites
What exectly do you mean by array ? A vector of coordinates ?
You still draw them with glVertex3f(..) right ?
Could someone give an example ?

Share this post


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

Share this post


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

Share this post


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

Share this post


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

Share this post


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

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.

GameDev.net is your game development community. Create an account for your GameDev Portfolio and participate in the largest developer community in the games industry.

Sign me up!