QGLFrameBuffer useage resulting in distorted images
-
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:
The same [w/o the QGLFrameBuffer] use does not cause any problems.
Output:
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).
-