View Full Version : PopMatrix or Translate
08-26-2000, 06:58 PM
Is it faster to push a matrix onto the stack or do 2 translations?
I need to position some models and return to my original position to position others. Am I better off to do a translation to my desired rendering position and then another back to my starting postion or 1 push/popmatrix?
Doesn't matter. You won't (and never will) see any difference in speed. Of course, making two translasions, you might not be 100% guarateed to get back to the same matrix, 'cause of finit precision.
And making a push/pop is cleaner code, and you can easily implement more trasformations without having to write more code to do the reverse.
not that the performance is the same Bob. Don't forget that if you call glTranslate, you will multiply a matrix with the current one.
If you use glPushPop, you simply do a memcopy.
[This message has been edited by Gorg (edited 08-27-2000).]
Well, I dunno how many multiplications/adds you will have to perform to multiply two 4x4 matrices, but I know you have to copy 64 bytes (if we are using 4-byte frloats) when pushing. Do you have to copy anything when popping? I don't know, changing the stack pointer would probably be sufficent, you already got the other matrix stored below. Anyways, the difference in speed here is not much. Unless we are doing this thousands of times each frame, I think it's the wrong place to optimize.
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.