GLvoid ReSizeGLScene(GLsizei width, GLsizei height) // Resize And Initialize The GL Window
{
if (height==0) // Prevent A Divide By Zero By
{
height=1; // Making Height Equal One
}
winWidth = width;
winHeight = height;
glViewport(0,0,width,height); // Reset The Current Viewport
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
// Calculate The Aspect Ratio Of The Window
gluPerspective(45.0f,(GLfloat)width/(GLfloat)height,0.1f,500.0f);
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glLoadIdentity(); // Reset The Modelview Matrix
}
int DrawGLScene(GLvoid) // Here's Where We Do All The Drawing
{
glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
glLoadIdentity(); // Reset The Current Modelview Matrix
glMatrixMode(GL_PROJECTION); // Select The Projection Matrix
glLoadIdentity(); // Reset The Projection Matrix
glViewport(0,0,winWidth,winHeight); // Reset The Current Viewport
// Calculate The Aspect Ratio Of The Window
gluPerspective(45.0f,(GLfloat)winWidth/(GLfloat)winHeight,0.1f,500.0f);
glMatrixMode(GL_MODELVIEW); // Select The Modelview Matrix
glLoadIdentity(); // Reset The Modelview Matrix
//gluLookAt(0,4.0f,150.0f, 0,3,0.0f, 0,1,0);
gluLookAt(objCamera.mPos.x, objCamera.mPos.y, objCamera.mPos.z,
objCamera.mView.x, objCamera.mView.y, objCamera.mView.z,
objCamera.mUp.x, objCamera.mUp.y, objCamera.mUp.z);
glClear(GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
// At here, set the second viewport at the right upper part
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glViewport(winWidth/2, winHeight/2, winWidth/2, winHeight/2);
glOrtho(0, winWidth, 0, winHeight, -50, 50);
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
gluLookAt(0.0, 50.0, 50.0, 0.0, 2.5, 50.0, 0.0, 1.0, 0.0);
glClear(GL_DEPTH_BUFFER_BIT); // Clear Screen And Depth Buffer
Draw_Grid();
Draw_BoundingBox();
.......
.......
.......
}