Important: Please read the Qt Code of Conduct -

Opengl and maximing viewport

  • I am trying to make a basic opengl app using QGLWidget and qt examples. I managed to make it show a basic grid on viewport and even change the viewpoint , but when i maximize the window it keeps showing a portion of the last rendered image in front of the actual view. This happens only when i maximize the window , resizing in any other way (minimize , change it in x,y direction) works fine.

    I put breakpoing inside resizegl and it is activated when any resizing happens.

    Below are some shots of what it looks like

    when i start program

    when i maximize (1920X1080)


    void GL_Renderer_Widget::resizeGL(int width, int height)
    glClear (GL_COLOR_BUFFER_BIT);//i put this here, trying to force clear screen on each resize
    int side = qMin(width, height);
    glViewport((width - side) / 2, (height - side) / 2, side, side);

        glOrtho(-0.5, +0.5, +0.5, -0.5, 4.0, 15.0);


    void GL_Renderer_Widget::SetViewPort()
    glViewport(0,0, width(), height());
    glMatrixMode (GL_PROJECTION);
    glLoadIdentity (); // Reset The Projection Matrix
    gluPerspective(PerspectiveAngle, (GLfloat)(width())/(GLfloat)(height()), 0.1f, FarPlane );

    void GL_Renderer_Widget::paintGL()

        glMatrixMode (GL_MODELVIEW);
        glLoadIdentity ();
        gluLookAt(  EyePosition[0],EyePosition[1],EyePosition[2],
                        EyeDir[0] ,EyeDir[1] ,EyeDir[2] ,
       glPolygonMode(GL_FRONT_AND_BACK , GL_FILL);
        //Typing in White Color
        renderText(5,40,QString("X: %1").arg(MouseXYZ[0]));
        renderText(55,40,QString("Y: %1").arg(MouseXYZ[1]));
        glFlush ();



    I made a button in main window that activates clear screen and updateGL() so when i maximize and click it, it all shows right.

    What am i missing here ?

    I am using qt on windows 7 64bit with ming and my drivers are up to date.

  • Just noticed what whenever i maximize view , and problem occurs , but i click anywhere else except the actual opengl rendering windows , coming back restores proper rendering view.

    1)i maximize and problem occurs
    2)i click on windows start bar
    3)i click back inside the render window
    4)view is restored correctly

  • Dont know what it was that caused this , but now it works ...

    I tried the following things but cant get any of these to recreate the problem (so i dont really know if any of those were creating the issue in the first place) :
    1)Used old windows theme
    2)Disabled ATI AI from catalyst
    3)Change vertical refresh from gpu properties
    4)Run exactly the same apps as before while running the program
    6)Clean all

    I think it was just a glitch caused from undefined conditions (thought im sure reboot-clean all must have helped more)

    Anyways if somene can , close this thread

Log in to reply