I want to implement a camera that follows my 3D object (a car). To set the camera I use the following structure:
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
gluPerspective(45, 1, -5, 5);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(pos_x + (cos(90)*0.5), pos_y + (0.5*sin(90)), 8, pos_x, pos_y, 6, 0, 1, 0);
//pos are the coordinates of the car
My problem is when I change to that camera, the camera doesn't stay behind the car, just on top of it. Why?