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. QGLFrameBuffer useage resulting in distorted images
Forum Update on Monday, May 27th 2025

QGLFrameBuffer useage resulting in distorted images

Scheduled Pinned Locked Moved General and Desktop
2 Posts 2 Posters 331 Views
  • 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
    Ankit.Jain
    wrote on last edited by
    #1

    Hi,
    I was trying the use of QGLFrameBuffer, I found that the resultant image was a distorted image of what I get without using a frame buffer.
    Framebuffer usage code:

    QGLFramebufferObject fbObject(1500, 1500);
        fbObject.bind();
        glEnable(GL_BLEND);
        glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
        glPolygonMode(GL_FRONT_AND_BACK, GL_FILL);
    	glMatrixMode(GL_PROJECTION);					// Select Projection
    	glPushMatrix();							// Push The Matrix
    	glLoadIdentity();						// Reset The Matrix
    	glOrtho( 0, 1500 , 0 , 1500, -1, 1 );				// Select Ortho Mode 
    	glMatrixMode(GL_MODELVIEW);					// Select Modelview Matrix
    	glPushMatrix();							// Push The Matrix
    	glLoadIdentity();						// Reset The Matrix
        //Set transparency [currently hardcoded]
        const int transparency = 255;	//0-255 0->completely transparent; 255->completely opaque
    
        //Initialize variables
        SPointData point1, point2, point3, point4;
        for (int itrX = 0; itrX < heatmapPointsData.fragmentsX - 1; ++itrX)
        {
            for (int itrY = 0; itrY < heatmapPointsData.fragmentsY - 1; ++itrY)
            {
                point1 = heatmapPointsData.pointData[itrX][itrY][0];
                point2 = heatmapPointsData.pointData[itrX + 1][itrY][0];
                point3 = heatmapPointsData.pointData[itrX + 1][itrY + 1][0];
                point4 = heatmapPointsData.pointData[itrX][itrY + 1][0];
                glBegin(GL_QUADS);
                glColor4ub(point1.color.red(), point1.color.green(), point1.color.blue(), transparency);
                glVertex2d(point1.xCood, point1.yCood);
                glColor4ub(point2.color.red(), point2.color.green(), point2.color.blue(), transparency);
                glVertex2d(point2.xCood, point2.yCood);
                glColor4ub(point3.color.red(), point3.color.green(), point3.color.blue(), transparency);
                glVertex2d(point3.xCood, point3.yCood);
                glColor4ub(point4.color.red(), point4.color.green(), point4.color.blue(), transparency);
                glVertex2d(point4.xCood, point4.yCood);
                glEnd();
            }
        }
        glDisable(GL_BLEND);
        glMatrixMode(GL_PROJECTION);					// Select Projection
        glPopMatrix();							// Pop The Matrix
        glMatrixMode(GL_MODELVIEW);					// Select Modelview
        glPopMatrix();							// Pop The Matrix
        fbObject.toImage().save("C:/Users/<name>/Desktop/3.png");
        fbObject.release();
        return fbObject.toImage();
    

    Output:
    0_1518785425124_3.png

    The same [w/o the QGLFrameBuffer] use does not cause any problems.
    Output:
    0_1518785451475_2.png

    Could some suggest me how my usage might be incorrect? [P.S. same data was used and the overall image size is 1500x1500 (I hardcoded for testing).

    1 Reply Last reply
    0
    • SGaistS Offline
      SGaistS Offline
      SGaist
      Lifetime Qt Champion
      wrote on last edited by
      #2

      Hi,

      Please don't post the same question multiple times.One is enough

      Duplicates

      Closing this one.

      Interested in AI ? www.idiap.ch
      Please read the Qt Code of Conduct - https://forum.qt.io/topic/113070/qt-code-of-conduct

      1 Reply Last reply
      0

      • Login

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