Jump to content
  • Advertisement
Sign in to follow this  
RealMadPsycho

OpenGL Raster position

This topic is 3714 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

Hi guys! I'm here looking for your precious help! I'm working at a 2d engine using the openGL (with glDrawPixels) and I've met a peculiar problem during the development: Positioning the raster (with glRasterPos2i) from the middle to the end of the screen lenght (e.g., if the screen resolution is 800x600, you call a value >= 400 as x coordinate) the position is increased of a pixel! glRasterPos2i(200, 50) positions the raster at 200 on the axis glRasterPos2i(399, 50) ppositions the raster at 399 on the axis glrasterPos2i(400, 50) positions the raster at 401 on the axis glRasterPos2i(504, 50) positions the raster at 505 on the axis and so on.. How is it possible? Practically, I'm not able to position the raster exactly in the middle of the screen. Is there anything I'm not considering?? Thanks in advice

Share this post


Link to post
Share on other sites
Advertisement
Probably becuase you setup the projection matrix wrong. You do something like this, right?
glOrtho(0, windowwidth-1, 0, windowheight-1, -1, 1)
Those -1 should not be there, since that makes the view volume one unit too small.

... but the real answer is to use glWindowPos, since it was specifically designed to set the raster position in window coordinates.

Share this post


Link to post
Share on other sites
Quote:
Original post by Brother Bob
Probably becuase you setup the projection matrix wrong. You do something like this, right?
glOrtho(0, windowwidth-1, 0, windowheight-1, -1, 1)
Those -1 should not be there, since that makes the view volume one unit too small.

... but the real answer is to use glWindowPos, since it was specifically designed to set the raster position in window coordinates.

Thank you Brother Bob :D

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.

We are the game development community.

Whether you are an indie, hobbyist, AAA developer, or just trying to learn, GameDev.net is the place for you to learn, share, and connect with the games industry. Learn more About Us or sign up!

Sign me up!