Skip to main content
gamedev.net
🔒 Locked

Loops slow everything down.

Started by ShlomiSteinberg Jan 25, 2003 at 1:19 PM 5 replies 150+ views
Original Post
ShlomiSteinberg
ShlomiSteinberg
In my OpenGL programm I have a loop, which is executed every frame: for (int i=0;i<5000;i++) { glBlendFunc(GL_DST_COLOR,GL_ZERO); // Bind Texture DrawQuad(); glBlendFunc(GL_ONE,GL_ONE); // Bind texture DrawQuad(); } Now I lose about 8-10 fps because the CONTENTS of the loop. I''m using a Pentium 3 700Mhz and a GeForce 4. If I use this however: glBlendFunc(GL_DST_COLOR,GL_ZERO); // Bind Texture for (int i=0;i<5000;i++) DrawQuad(); glBlendFunc(GL_ONE,GL_ONE); // Bind texture for (int i=0;i<5000;i++) DrawQuad(); some of the quads are blended together. What can I do to speed this but not blend the quads?
Member of the Shove Pouya Off A Cliff club, SPOAC. (If you wish to join, add this line to your signature.)Member of "Un-Ban nes8bit" association, UNA (to join put this in your sig)
Lunatic Raven
Lunatic Raven
One thing I can think of is, are there glBegin() and glEnd() within your DrawQuad() function, because if there is, you should gain a speed increase by getting them outside of the loops.
"...."
Julio
Julio
you might try display lists if your geometry is static. that should speed it up a bit.

My Homepage
Freeservers.com sucks. Angelfire.lycos.com is cool.
My HomepageSome shoot to kill, others shoot to mame. I say clear the chamber and let the lord decide. - Reno 911
ShlomiSteinberg
ShlomiSteinberg
quote:
Original post by Lunatic Raven
One thing I can think of is, are there glBegin() and glEnd() within your DrawQuad() function, because if there is, you should gain a speed increase by getting them outside of the loops.



I have to rotate and translate each quad differently and I need to change the blend function and bind a texture...
Member of the Shove Pouya Off A Cliff club, SPOAC. (If you wish to join, add this line to your signature.)Member of "Un-Ban nes8bit" association, UNA (to join put this in your sig)
ShlomiSteinberg
ShlomiSteinberg
quote:
Original post by Julio
you might try display lists if your geometry is static. that should speed it up a bit.




Thats right! I have forgotten display lists.. I don''t think I can use glRotate/glTranslate inside a display list, can I?
Member of the Shove Pouya Off A Cliff club, SPOAC. (If you wish to join, add this line to your signature.)Member of "Un-Ban nes8bit" association, UNA (to join put this in your sig)
ShlomiSteinberg
ShlomiSteinberg
I have tried to use display lists, but I have lost about 6 fps!! What is wrong? I compile the display lists with the glBegin()/glEnd() and everything I do is rotate the lists.
Member of the Shove Pouya Off A Cliff club, SPOAC. (If you wish to join, add this line to your signature.)Member of "Un-Ban nes8bit" association, UNA (to join put this in your sig)
Tron3k
Tron3k
I don''t think display lists give much advantage for rendering only a single quad at a time.

Firebird Entertainment
“[The clergy] believe that any portion of power confided to me, will be exerted in opposition to their schemes. And they believe rightly: for I have sworn upon the altar of God, eternal hostility against every form of tyranny over the mind of man” - Thomas Jefferson

Topic Locked

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

Sign in to reply to this topic.