I am certain this is an opengl problem and not a qt problem. I have posted on the gamedev/opengl board but in the off chance that anyone recognizes this problem or if there is something that I don't know about the paintGL method, I am posting here.

I am trying to zoom in on image and I use the following code to zoom in around the center. I am following the advice of 10.070 in http://www.opengl.org/resources/faq/...l/clipping.htm

Qt Code:
  1. glClearColor(0.0f, 0.0f,0.0f, 0.0f);
  2. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  3.  
  4. glPixelZoom(1.00010 + m_zoomSetting, (1.0000 + m_zoomSetting) * -1);
  5. if (m_zoomSetting == 0) {
  6. glRasterPos2f(0, m_height - 1);
  7. glDrawPixels(m_imageWidth, m_imageHeight,GL_LUMINANCE,
  8. GL_UNSIGNED_BYTE, m_displayPtr);
  9. }
  10. else {
  11. glRasterPos2f((float)m_width/2.0, (float)m_height/2.0);
  12. glBitmap(0,0,0,0,-(m_width * (m_zoomSetting + 1)/2.0), m_height*
  13. (m_zoomSetting + 1)/2.0, NULL);
  14. glDrawPixels(m_imageWidth, m_imageHeight,GL_LUMINANCE,
  15. GL_UNSIGNED_BYTE, m_displayPtr);
  16. }
  17. glPointSize(5.0);
  18.  
  19. glBegin(GL_POINTS);
  20. qglColor(Qt::red);
  21. float rx = 0.0;
  22. float ry = 0.0;
  23. glVertex2f(rx, ry);
  24. glEnd();
  25. glPointSize(2.0);
  26. rx = rx + 10;
  27. ry = ry + 10;
  28. glBegin(GL_POINTS);
  29. for (int r = 0; r < 100; r++)
  30. {
  31. glVertex2f(rx, ry);
  32. rx = rx + 10;
  33. ry = ry + 10;
  34. }
  35. glEnd();
To copy to clipboard, switch view to plain text mode 

where m_width and m_height are the width/height of the window and m_imageWidth and m_imageHeight are image width/height but I have made the window size to equal the image size to maintain a 1:1 ratio.

When m_zoomSetting == 0, the points start at the left hand corner and move diagonally up the image to the right as expected. When m_zoomSetting > 0, the zoomed images look correct but the points on the second image(image B) seem to be scaled by some value. The origin is off to the left (outside of the window) and even the spacing between the points has been scaled. What's even stranger is that when I have just one image appearing (either A or B), I see the scaling issue on the currently displayed image but if I start showing both images again, then only image B has the problem.

I have checked the code visually and with breakpoints and there are no other opengl calls between the paint calls. My only other opengl calls are in the initializeGL and resizeGL methods but those are not called after startup.

I put glPushMatrix(), glLoadIdentity(), glPopMatrix() from before pixel zoom to after the drawPixels and then again before the begin of the points and the end.

I also tried
glBitmap(0,0,0,0,(m_width * (m_zoomSetting + 1)/2.0), -(m_height * (m_zoomSetting + 1)/2.0), NULL);
glRasterPos2f(0, m_height - 1);
glPixelZoom(m_xScale, m_yScale);

after the glDrawPixels to see if that reset it.

I even tried glScalef(1.0, 1.0, 1.0);
Has anyone seen anything like this or is able to comment?

Thanks for any help.

-- ntp