Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 8 of 8

Thread: viewport fine, larger screen display blank

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Intern Contributor
    Join Date
    May 2017
    Posts
    59

    viewport fine, larger screen display blank

    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.

    Code :
    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( "1024768: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;
    }
    Last edited by technologist; 11-09-2017 at 11:13 AM. Reason: clarification

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •