Sign in to follow this  
Stoic

OGL 2D and origin in Screen upper-left

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

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now

Sign in to follow this