OGL 2D and origin in Screen upper-left

Started by
4 comments, last by samuraicrow 16 years, 10 months ago
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!
...
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.
umm...
		glOrtho(0, xres, yres, 0, -1.0, 1.0);
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.

...
Just disable back face culling....
- Iliak -
[ ArcEngine: An open source .Net gaming framework ]
[ Dungeon Eye: An open source remake of Eye of the Beholder II ]
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.

This topic is closed to new replies.

Advertisement