Jump to content
  • Advertisement
Sign in to follow this  
Simian Man

Working with pixels in OpenGL

This topic is 4759 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
When you create the window, use AdjustWindowRectEx() to adjust your window rectangle to match a given client rectangle.

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!