# Thread: What is the definition of gluLookAt?

1. ## What is the definition of gluLookAt?

The description of the gluLookAt is as follows:
Let
F=centerX-eyeXcenterY-eyeYcenterZ-eyeZ
Let UP be the vector upXupYupZ.
Then normalize as follows:
f=FF
UP″=UPUP
Finally, let s=f×UP″, and u=s×f.
M is then constructed as follows:
M=s⁡0s⁡1s⁡20u⁡0u⁡1u⁡20-f⁡0-f⁡1-f⁡200001 //??????
gluLookAt is equivalent to
glMultMatrixf(M);
glTranslated(-eyex, -eyey, -eyez);

Can you explain the description above?Especially the define of M,the line with ????.
Thank you very much.

2. Have a read of this
http://www.songho.ca/opengl/gl_transform.html

gluLookAt is just a shorthand to create the view model matrix

3. Thank you for your help,but I have to use gluLookAt in my program.Can you explain the function?

4. He just linked you to a very detailed explanation of how transforms work and what it does.

And no, you don't "have to use gluLookAt".

5. It would be interesting to know what exactly the OP doesn't get about the function. Any specific questions or are you just not understanding anything at all?

6. I hope a concrete implementation (from MESA3D) would help
Code C:
```gluLookAt(GLdouble eyex, GLdouble eyey, GLdouble eyez, GLdouble centerx,
GLdouble centery, GLdouble centerz, GLdouble upx, GLdouble upy,
GLdouble upz)
{
float forward[3], side[3], up[3];
GLfloat m[4][4];

forward[0] = centerx - eyex;
forward[1] = centery - eyey;
forward[2] = centerz - eyez;

up[0] = upx;
up[1] = upy;
up[2] = upz;

normalize(forward);

/* Side = forward x up */
cross(forward, up, side);
normalize(side);

/* Recompute up as: up = side x forward */
cross(side, forward, up);

__gluMakeIdentityf(&m[0][0]);
m[0][0] = side[0];
m[1][0] = side[1];
m[2][0] = side[2];

m[0][1] = up[0];
m[1][1] = up[1];
m[2][1] = up[2];

m[0][2] = -forward[0];
m[1][2] = -forward[1];
m[2][2] = -forward[2];

glMultMatrixf(&m[0][0]);
glTranslated(-eyex, -eyey, -eyez);
}```

7. The thing is, Alfonse is right in saying you don't need to use gluLookAt, because if you get the math behind it, you can write up a function yourself. I suspect the OP doesn't have a sufficient mathematical basis.

8. This is exactly what I need!!!Thank you so much!
鄙视狗眼看人低。

#### Posting Permissions

• You may not post new threads
• You may not post replies
• You may not post attachments
• You may not edit your posts
•