gluLookAt vs. glRotatef/glTranslatef...etc

Member
Posts: 153
Joined: 2004.12
Post: #1
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?

There was a long silence...
'I claim them all,' said the Savage at last.
Quote this message in a reply
Member
Posts: 129
Joined: 2005.02
Post: #2
i think thats apples & oranges. one deals with camera view, and the other with where you are drawing an item?
Quote this message in a reply
Member
Posts: 153
Joined: 2004.12
Post: #3
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...

There was a long silence...
'I claim them all,' said the Savage at last.
Quote this message in a reply
Member
Posts: 129
Joined: 2005.02
Post: #4
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?
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #5
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.
Quote this message in a reply
Moderator
Posts: 335
Joined: 2002.04
Post: #6
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 ?
Quote this message in a reply
Moderator
Posts: 335
Joined: 2002.04
Post: #7
moved to the OpenGL forum in Graphics & Audio programming
Quote this message in a reply
Member
Posts: 153
Joined: 2004.12
Post: #8
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.

There was a long silence...
'I claim them all,' said the Savage at last.
Quote this message in a reply
Member
Posts: 277
Joined: 2004.10
Post: #9
Hangt5 Wrote:Are there any major disadvantages or advantages of using one or the other?

OneSadCookie Wrote: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...

OneSadCookie Wrote: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.
Quote this message in a reply
Luminary
Posts: 5,143
Joined: 2002.04
Post: #10
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.
Quote this message in a reply
Post Reply 

Possibly Related Threads...
Thread: Author Replies: Views: Last Post
  OpenGL gluLookAt() not doing anything? ene777 1 3,581 May 1, 2008 08:50 AM
Last Post: ThemsAllTook
  gluLookAt problem vobla 0 2,639 Sep 1, 2007 12:44 PM
Last Post: vobla
  Trouble with glRotatef() anthony 4 6,548 Sep 1, 2007 09:27 AM
Last Post: Nevada
  Problems with gluLookAt(); ghettotek 6 5,647 Feb 9, 2003 04:35 AM
Last Post: ghettotek
  when is 'glTranslatef()' reset? sealfin 5 4,908 Jan 13, 2003 07:39 AM
Last Post: DoG