• Advertisement
Sign in to follow this  

Working with pixels in OpenGL

This topic is 4485 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 all. I'm trying to do a 2D game using OpenGL and am having trouble making the points passed to glVertex* come up as actual pixels. My window is 800x600. Ideally, I'd like it like so:
(0,600)   (800,600)
____________
|          |
|          |
|          |
------------
(0,0)    (800,0)
However, after experimenting, it seems to be:
(1,565)   (792,565)
____________
|          |
|          |
|          |
------------
(1,0)    (792,0)
How can I fix this? Thanks!

Share this post


Link to post
Share on other sites
Advertisement
Is this windowed? If it it you'll have to account for the window border, title bar and menus. When you request an 800x600 window in Win32, thats the outer dimension of the entire window, not the client area.

That seems likely to me as the numbers appear to match the default border size, etc. I forget how, but theres a way to querry windows for the border dimensions.

Share this post


Link to post
Share on other sites
Hey there.

To set up your own 2d coordinate system you can use gluOrtho with glut. The code I use is at the following link provided by Lighthouse 3d.

Share this post


Link to post
Share on other sites
Thanks. It does go correctly in fullscreen.

So I guess I'll just pass extra space when I am in windowed mode.

It seems dumb to me, however, that Windows won't adjust for that automatically.

Share this post


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

  • Advertisement