Jump to content

  • Log In with Google      Sign In   
  • Create Account

gluLookAt() vs. glTranslatef()


Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.

  • You cannot reply to this topic
6 replies to this topic

#1 krs-one   Members   -  Reputation: 122

Like
Likes
Like

Posted 11 November 2001 - 07:43 AM

I was reading in the OpenGL Game Programming book and it told about functions gluLookAt() and glTranslatef(). It said that the gluLookAt() function merely moves the camera around the plane, while the glTranslatef() function actually moves the plane around the camera, in a sense. First, are they right with this? I assume they are since they did, after all, write the book. And two, wouldn''t glTranslatef() cause a huge performance problem with huge scenes that have to move around the camera rather than the camera moving around them. Is gluLookAt() more efficient than glTranslatef()? Thanks, -Vic

Sponsor:

#2 jwblair   Members   -  Reputation: 122

Like
Likes
Like

Posted 11 November 2001 - 10:48 AM

Actually gluLookAt() and glTranslatef() do the same thing. The only difference is the programming style. Anytime that the camera moves, it is actually the environment that is moving, not the camera. So, no there will not be a performamce hit in using glTranslatef(). gluLookAt() does all the translations for you, so that you dont have to calculate them.

Hope this helps.....

#3 krs-one   Members   -  Reputation: 122

Like
Likes
Like

Posted 11 November 2001 - 11:04 AM

Alright, thanks a lot! The book failed to make that clear to me.

Thanks,
-Vic

#4 Dactylos   Members   -  Reputation: 122

Like
Likes
Like

Posted 11 November 2001 - 11:05 AM

gluLookat also rotates the scene (if appropriate), so it does more work than glTranslate (meaning that you can''t really substitue one for the other, without a little extra work).

#5 Khawk   Senior Staff   -  Reputation: 1362

Like
Likes
Like

Posted 11 November 2001 - 01:32 PM

Right, the point of saying what I said in OGLGP was so you think of glTranslatef() as the scene moving, and gluLookAt() as moving the camera. That''s effectively what is happening, at least when you think of it on a higher level, which I try to do throughout the book to simplify concepts.

If you get MesaGL and look at the gluLookAt() code, you''ll see how they use the glTranslate() and glRotate() functions to "move" the camera.

Kevin


#6 lowlevel   Members   -  Reputation: 122

Like
Likes
Like

Posted 11 November 2001 - 08:25 PM

What''s MesaGL and where can I get it?

#7 brettporter   Members   -  Reputation: 122

Like
Likes
Like

Posted 11 November 2001 - 10:40 PM

www.mesa3d.org

I can''t believe you didn''t put the view transformation in the book Kevin! I think it took me a couple of weeks to get my head around it the first time I saw it. Our lecturer used the whole room to get his point across. IIRC it is 6 transformations. But if all you are doing is looking across the X-Y plane, use glTranslatef

~~~
Cheers!
Brett Porter
PortaLib3D : A portable 3D game/demo libary for OpenGL
Community Service Announcement: Read How to ask questions the smart way before posting!




Old topic!
Guest, the last post of this topic is over 60 days old and at this point you may not reply in this topic. If you wish to continue this conversation start a new topic.



PARTNERS