Speed difference between manually unrotating and saving matrices

Started by
4 comments, last by slyterence 21 years ago
Hi I''d just like to know whether it''s faster to : a) glPushMatrix() before I rotate, translate and then draw objects, and then glPopMatrix(), or, b) Translate and rotate, draw, rotate by a negative angle, and then translate by a negative vector. Also, if one method is faster (or if there''s a third alternative), i''d like to know how much faster. Thanks $£¥ We scratch our eternal itch A twentieth century bitch We are grateful for Our Iron Lung
We scratch our eternal itchA twentieth century bitchWe are grateful forOur Iron Lung
Advertisement
Funny thing is I asked this exact same question a couple months ago. I''ll give you the answer I got.

Using Push and PopMatrix() is much quicker than translating. The reason is that you are doing a ton of uneccesary math by undoing all of your translations. The *Matrix() functions merely add a new matrix to the stack to be used, and then remove it.

Hope I remembered all that correctly
Actualy there is 3rd alternative that is faster than both. Build complete trnaformation (translatio/rotation/scale) matrix on CPU then send it in one glMultMatrix call instead of bunch of glTranslate/Rotate/Scale calls..

You should never let your fears become the boundaries of your dreams.
You should never let your fears become the boundaries of your dreams.
Another reason not to translate back is that the more transforms are applied to a matrix, the more error it accumulates.
Wow! You''re saying that a general purpose CPU is faster than a specifically made hardware device?

karg
Every ttime you rotate/translate OpenGL builds a matrix and applies it to the modelview matrix, making it quite expensive if you do this unnessecarily...

This topic is closed to new replies.

Advertisement