Jump to content
  • Advertisement

Archived

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

Lord Chaos

OpenGL OpenGL state changes

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

Which way is the best to optimize the drawing of objects? To draw all polys with the same texture and switching the modelview matrix as you loop through the objects, or to draw all objects independantly and switch the texture as you loop through all the polys in the object? A little pseudo code:
1) for all textures
   {
     set current texture

     for all objects
     {
       set modelview matrix
       draw bunch of polys with current texture
     }
   }


2) for all objects
   {
     set modelview matrix

     for all textures
     {
       set current texture
       draw bunch of polys with current texture
     }
   }
 
so, which way would be the fastest? To switch modelview or to switch texture? Edited by - Lord Chaos on 6/23/00 1:21:09 AM

Share this post


Link to post
Share on other sites
Advertisement
I would do each Object independantly, but I would experiment with each loop structure. I think each loop would be equal but the question is which takes more time, setting a texture or changing matrix, I would have to say changing matrix would be slower, but then I have not done any tests to confirm this..

Share this post


Link to post
Share on other sites
quote:
Original post by ZenMaster.
I would have to say changing matrix would be slower, but then I have not done any tests to confirm this..


Hmm, well I am almost CERTAIN that switching texture state will be more than an order of magnitude slower than changing the modelview matrix.
Reason: Modelview matrix: 16 doubles. Texture: God knows how many pixels
Plus, the modelview matrix is MEANT to change a lot, so that part has most likely been optimised a lot more than switching texture state.




Give me one more medicated peaceful moment..
~ (V)^|) |<é!t|-| ~

Share this post


Link to post
Share on other sites
If you want it the fastest, draw polygons together that have the same texture. Switching textures takes longer than adjusting the transformation matrices.

---
www.crazycrackerz.org

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!