Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • Users
  • Groups
  • Search
  • Get Qt Extensions
  • Unsolved
Collapse
Brand Logo
  1. Home
  2. Qt Development
  3. General and Desktop
  4. Opengl and maximing viewport
Forum Updated to NodeBB v4.3 + New Features

Opengl and maximing viewport

Scheduled Pinned Locked Moved General and Desktop
3 Posts 1 Posters 1.5k Views 1 Watching
  • 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 Offline
    A Offline
    atlas
    wrote on 18 Jan 2014, 08:44 last edited by
    #1

    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
    0
    • A Offline
      A Offline
      atlas
      wrote on 18 Jan 2014, 09:21 last edited by
      #2

      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
      0
      • A Offline
        A Offline
        atlas
        wrote on 18 Jan 2014, 10:32 last edited by
        #3

        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
        0

        1/3

        18 Jan 2014, 08:44

        • Login

        • Login or register to search.
        1 out of 3
        • First post
          1/3
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • Users
        • Groups
        • Search
        • Get Qt Extensions
        • Unsolved