PDA

View Full Version : Help with gluLookAt()



12-14-2000, 07:25 AM
Hi,

I am starting my first 'real' OpenGL program after having produced several demo/test programs, and would like to get it running as fast as possible [doesn't everyone http://www.opengl.org/discussion_boards/ubb/wink.gif]. I remember reading one person's comments (cannot remember where) who indicated that using gluLookAt() to move the camera around the scene produced a great speed impovement when compared to the simpler method of rotating and translating all the primitives to be drawn (the method that all basic tutorials seem to use - probably for a reason) Is this true? If so, how is the above function used? I'm not sure what the 'up' vector is there for...

Sorry if this is a bit of a no-brainer http://www.opengl.org/discussion_boards/ubb/confused.gif, but, as I said, I am new to OpenGL...

Cheers for any info,

Ghee

Bob
12-14-2000, 08:01 AM
gluLookAt is not faster than usual glRotatef/glTranslatef, nor is it slower. They are more or less equal in speed.

Concerning the up-vector, you can think of it as the vector telling gluLookAt where the camera's up is pointing. Placing the camera at a specific point, pointing it in a direction doesn't tell you how the camera is rotated about it's own look-at vector. It can be placed upside down, it can be placed with the upside to the left or so.

If you use the standard coordinate system (x=right, y=up, z=into the screen), you can always set the upvector to {0, 1, 0}. As long as you only look left/right, and not too much up/down that is.

Boubou
12-14-2000, 08:13 AM
hi...

I don't know very well OpenGL... and english too! But I try to help you!




void gluLookAt (GLdouble eyex, GLdouble eyey,GLdouble eyez,GLdouble centerx,GLdouble centery,GLdouble centerz,GLdouble upx,GLdouble upy,GLdouble upz)
Defines a viewing matrix and multiplies it to the right of the current matrix. The desired viewpoint is specified by eyex,eyey and eyez. The centerx, centery and centerz arguments specify any point along the desired line of sight, but typically they specify somme point int he center of the scene being looked at. The upx, upy and upz arguments indicate which direction is up (that is, the direction from the bottom to the top of the viewwing volume).


If you give me your e-mail, I give you an image of gluLookAt... and a exemple for turn around a scene!

I hope I help you

Best regards

Jérôme

12-14-2000, 08:15 AM
Cheers Bob!

As I was exiting from posting my message, I noticed the feature section had an entry about a developer FAQ, which has a section all about gluLookAt()! (http://www.opengl.org/developers/faqs/technical/viewing.htm)

I'm going to take a good look at your comments and this page.

Thanks again,

Ghee

12-14-2000, 08:28 AM
Thanks Jérôme.

I would be interested in some code showing how gluLookAt()is used. I will try to mail you later on. If you speak French, feel free to reply as you feel - my wife is French.

I think that my real problem at the moment is a poor understanding of Matrixes, and how they are used in OpenGL. I have always avoided them before when dealing with geometry.

I'm very impressed by the speed of your answer, by the way.


Thanks,

Ghee