I'm having trouble orienting the camera the way I want. I got that I need to use gluLookAt
to set the camera. As far as I understood the first three is for the location of the camera, the second set is for destination and the third set is for the camera upvector
and I'm trying to implement a box which the camera should be looking at its center. This box consists of 6 triangles, does not necessarily make a decent box. To get its center, I get the average of all triangle's vertices (x
, y
, and z
).
So this is inside my display function :
Vect v=getBoxCenter();
gluLookAt(camera.pos.x, camera.pos.y, camera.pos.z,
v.x,v.y,v.z,
camera.upVector.x, camera.upVector.y, camera.upVector.z);
glColor3f(1, 0, 0);
glBegin(GL_TRIANGLES);
glVertex3f(0, 0, 0); glVertex3f(100, 0, 0); glVertex3f(0, 100, 0);
glEnd();
glutSwapBuffers();
When I do not use gluLookAt
, the triangle shows up just fine at the center of the screen. What am I doing wrong?