PDA

View Full Version : gluLookAt vs. glRotatef/glTranslatef...etc


hangt5
2005.03.14, 09:29 PM
Im trying to create a camera class. Half the tutorials i have seen use gluLookAt, and the other half simply use glRotate and glTranslate.

Are there any major disadvantages or advantages of using one or the other?

maaaaark
2005.03.15, 12:21 AM
i think thats apples & oranges. one deals with camera view, and the other with where you are drawing an item?

hangt5
2005.03.15, 12:45 AM
There is no visual difference between moving your view around and moving your objects around.

Imagine a cube in the middle of your screen. If your user hits the forward button you can either glTranslate that cube closer to the camera, or you can move your camera closer to the cube.

kinda like when you look outside of your car and the car next to you is going forwards sometimes it feels like your going backwards...

maaaaark
2005.03.15, 05:01 AM
That seems ineffective if you are drawing an actual scene, versus just say, one object. Would you rather adjust XX amount of objects to move forward/backward/up/down/left/right/sideways or just your camera?

OneSadCookie
2005.03.15, 05:51 AM
the two are exactly equivalent. gluLookAt calls glMultMatrix, glRotate/glTranslate are equivalent to glMultMatrix with specialized matrices.

Personally, I find gluLookAt easier to think about, so I tend to use that. Other people feel differently, and use the other calls. It's all a matter of preference.

Zwilnik
2005.03.15, 09:31 AM
It's interesting that just by putting the Game Design thread at the top of the list, it automatically gets all the programming posts. (even ones that should have gone in Graphics and Audio programming). Is it because everyone's used to general programming being at the top, or just people being too lazy to look for the right thread to post in ?

Zwilnik
2005.03.15, 09:52 AM
moved to the OpenGL forum in Graphics & Audio programming

hangt5
2005.03.15, 01:38 PM
Sorry about that. I thought that since i was asking about the design/theory of a camera class it would be more appropriate in the other forum...

OSC: I kinda figured that would be the case. Thanks for the clarification.

BinarySpike
2005.03.15, 01:53 PM
Are there any major disadvantages or advantages of using one or the other?



the two are exactly equivalent.
...I find gluLookAt easier to think about


One thing I would like to point out is that gluLookAt is good for one scene renders, but
when it comes to rotating your camera around a point glTranslatef and glRotatef are much
easyer to use...

I created an animation in OpenGL with a floor and six posts I would move foward and
look left then right, then move forward and look up parralel to one of the posts.

This took tons, and tons of lines of code just to get my camera to look left then right...
gluLookAt is much better for "placing" your camera while (my function) SetCamera was much
easyer rotating...
gluLookAt has to have a point by point place to look at while SetCamera can just rotate the camera with a rotate call, this makes rotating, in the look at part, a circle, while gluLookAt
has square...

It's all a matter of preference.

Not in a team job...
It's whatever works better for what your doing...
that's why I have about... four different self made camera functions... all for different
types of play.

But, yes, It is what you like best when it's just you.

OneSadCookie
2005.03.15, 03:54 PM
more completely random noise from spike...

as I said, anything you can do with LookAt, you can do with Rotate and Translate. It is entirely a matter of preference, neither works better than the other.