PDA

View Full Version : Problems with gluLookAt



Abschiedsstein
03-15-2009, 05:32 AM
Hi guys,
I have got a quite special problem with gluLookat.
I work on an program that has got an opengl window as child window in an WINAPI window.
My proglem is that the gluLookAt routine has no influence on the shown image!
I have got implemented following code in the routine which is called at WM_SIZE messages:


glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(60.0f,GLfloat)width/(GLfloat)height,5.0f,1000.0f);

glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(LEN_Z*2., LEN_Y*2.+1000., LEN_X*2.,
LEN_Z*2., LEN_Y*2., LEN_X*2.,
0.0, 0.0, 1.0);
LEN_X/Y/Z are constants.
I wondered why dont see anything and found out that the camera is still looking at the old origin. I also tried to tilt the camera by using 1.0, 0.0, 1.0 as last vector but there was no difference in the shown image(which consists of simple geometric forms).
I wonder because the gluPerspectiv function works perfect and it is in the same routine....
I would be very happy if you could tell me any guesses why this dont works.
Thank you!

dletozeun
03-15-2009, 07:34 AM
gluLookAt works well. Check the values of your LEN_X, LEN_Y and LEN_Z variables. There must be something wrong here.

Look at the gluLookAt man page (http://www.opengl.org/sdk/docs/man/xhtml/gluLookAt.xml) and see if you use it correctly.

Abschiedsstein
03-15-2009, 08:10 AM
No. Unfortunately this is not the problem.I changed to:

gluLookAt(10., 10., 10.,
10., 10, 10.,
0.0, 0.0, 1.0);
I see my forms....
If I change to:

gluLookAt(10., 10., 10.,
10., 10, 10.,
1.0, 0.0, 1.0);
Compared to the one before, this should be rotated by 45 degrees.
It is not. More over the figures ar not drawn at the position the camera looks at. So I should not see anything...

dletozeun
03-15-2009, 08:19 AM
Have you taken a look to the gluLookAt man page?

If you set the eye and the target at the same location, sure you will have problems.

If the eye is at the origin (0,0,0), the target at say (10,10,10) and the camera up axis is (0,1,0)

you must call gluLookAt this way:



gluLookAt( 0,0,0, 10,10,10, 0,1,0 );

Abschiedsstein
03-15-2009, 09:38 AM
Thanks very much!
I took a look at the defenition, but simply faild in eliminating my constants.