Jump to content
  • Advertisement
Sign in to follow this  
ndtp

OpenGL zoom on glDrawPixels in ortho continued

This topic is 3775 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

I posted this a few months ago: http://www.gamedev.net/community/forums/topic.asp?topic_id=475017 I did get this to work but now I want to draw lines on top of the pixmap and I get very strange results where the origin is not always at the lower left corner. glClearColor(0.0f, 0.0f,0.0f, 0.0f); glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); glPixelZoom(1.01 + m_zoomSetting, (1.01 + m_zoomSetting) * -1); if (m_zoomSetting == 0) { glRasterPos2f(0, m_height - 1); glDrawPixels(m_imageWidth, m_imageHeight,GL_LUMINANCE, GL_UNSIGNED_BYTE, m_displayPtr); } else { glRasterPos2f((float)m_width/2.0, (float)m_height/2.0); glBitmap(0,0,0,0,-(m_width * (m_zoomSetting + 1)/2.0), m_height* (m_zoomSetting + 1)/2.0, NULL); glDrawPixels(m_imageWidth, m_imageHeight,GL_LUMINANCE, GL_UNSIGNED_BYTE, m_displayPtr); } glPointSize(5.0); glBegin(GL_POINTS); float rx = 0.0; float ry = 0.0; glVertex2f(rx, ry); glEnd(); glPointSize(2.0); rx = rx + 10; ry = ry + 10; glBegin(GL_POINTS); for (int r = 0; r < 100; r++) { glVertex2f(rx, ry); rx = rx + 10; ry = ry + 10; } glEnd(); 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 perfect 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 initialize and resize methods but those are not called after startup. Has anyone seen anything like this or is able to comment? Thanks for any help. [Edited by - ndtp on February 22, 2008 2:00:11 PM]

Share this post


Link to post
Share on other sites
Advertisement
I should add that I tried all kinds of calls to see if I couldn't stop the scaling from happening:

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);

-- ndtp

Share this post


Link to post
Share on other sites
Sign in to follow this  

  • Advertisement
×

Important Information

By using GameDev.net, you agree to our community Guidelines, Terms of Use, and Privacy Policy.

Participate in the game development conversation and more when you create an account on GameDev.net!

Sign me up!