glScalef(0.5f, 0.5f, 0);
// do some things
glScalef(2.0f, 2.0f, 0);
Or..
glPushMatrix();
glScalef(0.5f, 0.5f, 0);
// do some things
glPopMatrix();
Which is better, performance wise?
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
The second one. Because the first one computes and multiplies a 4×4 matrix, while the second only writes and reads it. Note that OpenGL can be intelligent about it and only create/multiply a diagonal matrix. Nevertheless, you are comparing 3 floating point multiplications with 16 variable stores. If you are concerned about the difference in performance, you need to write a test.
Precision-wise, the second one is definitely better because due to whatever rounding error
0.5 * x * 2might give a different value thanx. This is why, even if the other method is slightly faster, this method is preferred.