Jump to content
  • Advertisement
Sign in to follow this  
Stoic

OGL 2D and origin in Screen upper-left

This topic is 4121 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 know this is a rather basic question, but I needed to ask it to remind myself and maintain my sanity. There is NO way simply using matrices at startup (like Ortho and maybe a scale) to set the origin in OGL to the upper left corner of the screen and have positive Y point down (like in D3D, or image rendering programs), correct? gluOrtho2D(0,width,height,0) causes everything to be clipped, because the right clipping plane is to the left of the left clipping plane, and using like a -Y scale causes the vertices to line up, but everything gets drawn upside down. If you really want to pretend the origin is in the upper left, you have to do a lot of (ScreenH- PointY), correct? I spent a chunk of time trying to figure this out a couple of years ago and gave up. (I had convinced myself it was impossible). Now I just wanted to reassure myself again before I invested a bunch more time in it. Thanks for any help!

Share this post


Link to post
Share on other sites
Advertisement
I'm sure flipping the params to glOrtho should do what you want - in fact I'm sure I've done just that myself many moons ago and it's worked without a hitch. I'm not sure what you mean by "the right clipping plane is to the left of the left clipping plane", frankly it sounds like nonsense.

Share this post


Link to post
Share on other sites
Ah, ok, I think I've figured out what the problem was. It's not a clipping plane problem, it's a Face Winding/culling problem. I had forgotten that inverting a single axis will reverse your face winding direction.

I suppose I can fix the whole "my sprites are inverted" problem in my sprite drawing routine, just changing the texture coordinates. My mistake was in thinking that I wouldn't have to change that other stuff.

Thanks for the heads up, guys.

Share this post


Link to post
Share on other sites
If you are just using OpenGL to blit and not using the z-coordinate for overlay priorities, you might want to disable z-buffering also.

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!