Hi,
My goal is to create a viewport within a full screen, high def, window (1920 x 1080). The program creates the larger window but remains blank although the viewport appears and behaves as predicted. What am I doing wrong? I want the small viewport to be an inset on the screen sized display. I didn’t know,also, whether to call glutSwapBuffer only once after both “canvases” - the large display and the viewport - are finished drawing. Or should glutSwapBuffer should occur twice here. Also when to create a viewport versus subwindow.
void display (void) {
glClearColor (0.0,0.0,0.0,1.0); //clear the screen to black
glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear the color buffer and the depth buffer
glLoadIdentity();
camera();
enable();
cube(); //call the cube drawing function
glutSwapBuffers(); //swap the buffers
angle++; //increase the angle
}
void viewport1 (void) {
glViewport(0,0,600,600);
//glClearColor (0.0,0.0,0.0,1.0); //clear the screen to black
//glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); //clear the color buffer and the depth buffer
glLoadIdentity();
glOrtho(0, 600, 0, 600, -1, 1);
camera();
enable();
cube(); //call the cube drawing function
//glutSwapBuffers(); //swap the buffers
angle++; //increase the angle
}
.....
int main (int argc, char **argv) {
glutInit (&argc, argv);
glutInitDisplayMode (GLUT_DOUBLE | GLUT_DEPTH);
//
//glutGameModeString( "1024×768:32@75" ); //the settings for fullscreen mode
//glutEnterGameMode(); //set glut to fullscreen using the settings in the line above
//to revert comment 2 above and uncomment the 3 below
glutInitWindowSize (1920, 1080);
glutInitWindowPosition (0,0);
int mainWindow = glutCreateWindow ("A basic FPS OpenGL Window");
glutFullScreen();
glViewport(0,0, 1280, 720);
init ();
glutDisplayFunc(display);
glutDisplayFunc(viewport1);
glutIdleFunc(display);
glutReshapeFunc (reshape);
glutPassiveMotionFunc(mouseMovement); //check for mouse movement
glutKeyboardFunc (keyboard);
glutMainLoop ();
return 0;
}