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

OpenGL state changes

Started by Lord Chaos Jun 23, 2000 at 1:20 AM 2 replies 350+ views
Original Post
Lord Chaos
Lord Chaos
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
ZenMaster.
ZenMaster.
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..
ZenMaster.
MadKeithV
MadKeithV
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|-| ~
It's only funny 'till someone gets hurt.And then it's just hilarious.Unless it's you.
acw83
acw83
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

Topic Locked

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

Sign in to reply to this topic.