Qt Forum

    • Login
    • Search
    • Categories
    • Recent
    • Tags
    • Popular
    • Users
    • Groups
    • Search
    • Unsolved

    Update: Forum Guidelines & Code of Conduct


    Qt World Summit: Early-Bird Tickets

    Opengl and maximing viewport

    General and Desktop
    1
    3
    1203
    Loading More Posts
    • Oldest to Newest
    • Newest to Oldest
    • Most Votes
    Reply
    • Reply as topic
    Log in to reply
    This topic has been deleted. Only users with topic management privileges can see it.
    • A
      atlas last edited by

      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
      !http://www.leposit.com/qgl1.jpg!

      when i maximize (1920X1080)
      !http://www.leposit.com/qgl2.jpg!

      @

      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);

          glMatrixMode(GL_PROJECTION);
          glLoadIdentity();
          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()
      {
      glClear (GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT );// | GL_STENCIL_BUFFER_BIT );

          SetViewPort();
          glMatrixMode (GL_MODELVIEW);
          glLoadIdentity ();
      
          gluLookAt(  EyePosition[0],EyePosition[1],EyePosition[2],
                          EyeDir[0] ,EyeDir[1] ,EyeDir[2] ,
                          LookUpV[0],LookUpV[1],LookUpV[2]);
      
         glEnable(GL_TEXTURE_2D);
         glPolygonMode(GL_FRONT_AND_BACK , GL_FILL);
      
          //Typing in White Color
          glColor3f(1.0f,1.0f,1.0f);
          renderText(5,10,QString(VendorInfo));
          renderText(5,20,QString(RendererInfo));
          renderText(5,30,QString(VersionInfo));
          renderText(5,40,QString("X: %1").arg(MouseXYZ[0]));
          renderText(55,40,QString("Y: %1").arg(MouseXYZ[1]));
         DrawBasicGrid();
          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.

      1 Reply Last reply Reply Quote 0
      • A
        atlas last edited by

        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

        1 Reply Last reply Reply Quote 0
        • A
          atlas last edited by

          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
          5)Reboot
          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

          1 Reply Last reply Reply Quote 0
          • First post
            Last post