Modelview transformations

Usually using the inverse camera model, you do something like this with the modelview matrix:
glRotate(xrot, 1.0f, 0.0f, 0.0f);
glRotate(yrot, 0.0f, 1.0f, 0.0f);
glTranslate(-eye[0], -eye[1], -eye[2]);

Now I’ve combined these three into one matrix calculation filling it up manually and then loading it with glLoadMatrixf();

Now I would expect the latter to be more efficient since instead of three matrix multiplications I calculate individual matrix elements using all rotation and transformation params. Is that really the case? Or is letting OpenGL do that more efficient?

In general, is it better to use your own
matrix calculations? I’d prefer that since that usually shortens the calculations…

Thanks,

It depends.
I would suggest letting OpenGL do your matrix calculations since you may get hardware matrix calculations acceleration if you use cards like GeForce which support T&L acceleration.

In addition using glLoadMatrix() could take some time e.g. Using glLoadIdentity() is faster than loading the identity matrix yourself using glLoadMatrix().

I recently converted my own engine ot use my own matrix calculations. While doing it I also checked out how Mesa handles its matrix math and noticed one other thing that could affect performance: If an an openGL implementation does its own matrix math with glRotate calls and so on, it can keep flags how the matrix is formed and later use these flags to do a faster inversion if needed.
But if matrix math is critical for your application performance you should make some performance comparisons between using your own matrices and loading them to modelview stack or whether using openGL is the faster way.