Hi, I need some help on getting the correct perspective when viewing a cube object.
I’m trying to use the glLookAt function, but am having trouble implementing it when the following function is included:
void myReshape(int w, int h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
aspectRatio=(GLfloat)w/(GLfloat)h;
if (aspectRatio <= 1.0)
glOrtho(-2.0, 2.0, -2.0 * (GLfloat) h / (GLfloat) w,
2.0 * (GLfloat) h / (GLfloat) w, distance-nearPlane, distance-farPlane);
else
glOrtho(-2.0 * (GLfloat) w / (GLfloat) h, 2.0 * (GLfloat) w / (GLfloat) h,
-2.0, 2.0, distance-nearPlane, distance-farPlane);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluPerspective(60.0, aspectRatio, 0.1, 40.0);
glTranslatef(0.0, 0.0, -distance);
//redraw the objects
glutPostRedisplay();
}
I want to be positioned inside the cube where i can see the floor, ceiling and 3 walls. Thanks