Advertisement

Why use matrices? (yeah I'm a newbie ;)

Started by January 15, 2001 08:09 AM
7 comments, last by Scarab0 23 years, 10 months ago
I was wondering why OpenGL has all kinds of matrix calculation routines when you can just use glTranslate and glRotate routines to position an object in the scene. What am I missing?
Dirk =[Scarab]= Gerrits
Hi,

glTranslate and glRotate work by modifying the currently active matrix, so they are actually just another one of the matrix calculation routines you mentioned.

Using glRotate for example, it''s the same as creating a new rotation matrix, and multiplying it with the currently active matrix. glRotate is just an easier form that does it all for you.

Hope that clears it up a bit.

Dan

Dan

Advertisement
Well if glRotate and glTranslate do the same thing in an easier way, then why use rotation/translation matrices at all?
Dirk =[Scarab]= Gerrits
But almost no program do their own matrix calculations. glRotate and glTranslate is also hw accelerated on some cards.
Really? I didn''t know that. Do you know any cards that do hardware accelerated glRotate and glTranslate?
Dirk =[Scarab]= Gerrits
The Geforce and Geforce 2 (from Nvidia) accelerate this, and I think the ATI Radeon does as well. If you see any 3d card advertised as hardware T&L (Transform and Lighting), that means it will do accelerated rotations, translations and other useful stuff.

It's normally best to leave all transformation and rotation to the 3d card nowdays. The OpenGL drivers are optimised better than most people can do themselves. Most use MMX and 3DNow to accelerate them a bit even if the 3d card itself doesn't. Plus you know the routines are fully debugged and tested, saving us developers a whole load of time.

If anyone else ever has to read your code, I'm sure they will thank you as well. A single glTranslate statement is far easier and quicker to understand than setting up a matrix by hand, then multiplying it by the current one.

Dan

Edited by - danbrown on January 15, 2001 1:13:07 PM

Dan

Advertisement
Cool. Another reason to like my GeForce 2 MX card.
Thanks for the information people.
Dirk =[Scarab]= Gerrits
real time Shadow casting is calculated using a Matrix.....there is one in a Appendix of the Red Book.
various timings on my computer (in operations per second)

glLoadMatrixf 741289
glMultMatrixf 507614
glRotatef 354609
glTranslatef 1041666

NOTE no calculations were involved.

advantages of glLoadMatrix
-with matrices u can advoid the gimbal lock problem.
-only one call is needed to orientate someit instead of a couple eg translate,rotatef,rotatef

with hardware tnl cards glLoadMatrix,multmatrix,glRotate,glTranslate etc are all accelerated


http://members.xoom.com/myBollux

This topic is closed to new replies.

Advertisement