Quantcast
Channel: QtWebEngine
Viewing all articles
Browse latest Browse all 13965

Opengl and maximing viewport

$
0
0
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);           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.

Viewing all articles
Browse latest Browse all 13965

Trending Articles