opengl in hardware mode

Started by
16 comments, last by ashtray 20 years, 8 months ago
you were right about the triangle strips... They are much faster the the quads I was using.


I''m still confused about the display lists. What if I wanted to build cubes and pyramids on top (to make it look like a ''cheap'' house, would it be better to use display lists for that?





...
Advertisement
quote:Original post by ashtray
I''m still confused about the display lists. What if I wanted to build cubes and pyramids on top (to make it look like a ''cheap'' house, would it be better to use display lists for that?


Display lists are only faster when they contain a large amount of polys. I forget the exact number but they start being efficient at about ~400 tris. For small scale stuff like this its probably easier to use immediate mode, or try building one vertex array for the whole floor and then telling GL to render it all at once. Or better yet, build one vertex array at the start and only rebuild it when anything changes.
I think I understand now. Is there a doc for optimization techniques comewhere?

SO what I can do is write a function that draws my initial landscape and only update it when something changes like movement ("walking" through my landscape) or any other graphic change or whatever.

Would I use the idleFunc for this? I never in any docs where or how to use that functions.

will this make navigation choppy?

I really appreciate your replies.

I had one more question... If I only use basically 2 big tris to make my whole 200 * 200, How would I attach my texture tiled if my texture is for example 1 * 1 (well, really 128 pixels * 128 pixels )? How would I be able to make it look like it''s been attached to 1*1 squares made of 2 tris and not attached just once on the 200 * 200 square?

If I should be in an other newsgroup... I can always post there..

thx.
...
You could use diffrent u and v coordinates.
When you use for instance 5.0 instead of 1.0 as u and v coordinate the texture would be repeated 5 times.
But you must set the texture wrap mode correctly. Should be something like:

glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S,GL_REPEAT);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T,GL_REPEAT);

[edited by - Roland on August 10, 2003 5:34:23 AM]
quote:Original post by Trienco
and of course dont bind it for every single quad. also if you use immediate mode and a lot of glvertex calls then doing translate AND glvertex means twice more work then necessary.

and yes, using "odd" texture sizes might be possible by now, but its still slow.




if you use glu build mipmaps functions you can uses texture not multiple of 2



http://www.8ung.at/basiror/theironcross.html
U can still optimise the code further by using display lists.

You can compile your code into a display list at load time.
glNewList(GL_COMPILE,LISTNUMBER);
glBindTexture( GL_TEXTURE_2D, grassTexture );
glBegin(GL_QUADS);
for (i = 0; i <= 200; i++ ) {
for (j = 0; j <= 200; j++ ) { // largeur 3.1m
glTexCoord2f( 0.0f, 0.0f);
glVertex3f( i, 0.0f, j);
glTexCoord2f( 1.0f, 0.0f);
glVertex3f( i+1, 0.0f, j);
glTexCoord2f(1.0f, 1.0f);
glVertex3f( i+1, 0.0f, j+1);
glTexCoord2f(0.0f, 1.0f);
glVertex3f( i, 0.0f, j+1); }}
glEnd();
glEndList();

Then when u need to call it just use glCallList(LISTNUMBER).

You should see a huge performance gain because you are now making 1 call instead of 40 000.

[edited by - GamerSg on August 10, 2003 11:49:21 AM]
quote:Original post by Basiror
if you use glu build mipmaps functions you can uses texture not multiple of 2


nobody said you cant.. but just because its possible doesnt mean you should do it. though if i were a 3d api id probably just take that odd texture and blow it up to the next power of 2 size *fg*

f@dzhttp://festini.device-zero.de
Hi there!

I''m making an RTS and I''m having the same problem...
major slowdowns as the polycount increases...
around 3-400 polys = unplayable...

So to optimize:

Minimize glPopMatrix,glPushMatrix calls...?

Build the entire map in a displaylist -( wouldn''t that be acctually slower than rendering each tile, only rendering the visible ones?)

Should I use glTranslate instead of pop/pushmatrix?

Minimize glBindTexture() .... How would I then change textures?
Do you mean, sort all units of the same type and then draw them in a loop...?

Right now I''m doing it this way:

for (int i = 1; i < NrOfUnits+1;i++)
{
glBindTexture(Unit.Texture);
glPushMatrix()
glTranslate(Unit.x,Unit.y,Unit.z);<br> glCallList(Unit.Model);<br> glPopMatrix();<br> }<br><br>Would it be better to sort all the units and then draw them in "order"? <br><br><br><br> </i> <br><br>"Game Maker For Life, probably never professional thou." =)
"Game Maker For Life, probably never professional thou." =)

This topic is closed to new replies.

Advertisement