Jump to content
  • Advertisement

Archived

This topic is now archived and is closed to further replies.

Scarab0

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

This topic is 6489 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

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?

Share this post


Link to post
Share on other sites
Advertisement
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

Share this post


Link to post
Share on other sites
Well if glRotate and glTranslate do the same thing in an easier way, then why use rotation/translation matrices at all?

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
But almost no program do their own matrix calculations. glRotate and glTranslate is also hw accelerated on some cards.

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites
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

Share this post


Link to post
Share on other sites

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!