# 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.

## 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 on other sites
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 on other sites
Quote:
 Original post by Brother BobProbably 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 on other sites
Thanks Brother Bob, that has really helped my drop shadow!

1. 1
2. 2
3. 3
4. 4
Rutin
12
5. 5

• 12
• 16
• 10
• 14
• 10
• ### Forum Statistics

• Total Topics
632659
• Total Posts
3007692
• ### Who's Online (See full list)

There are no registered users currently online

×