Sign in to follow this  
mameman

Changing the Origin In OGL

Recommended Posts

mameman    100
Hi, Been trying to work this one out for a number of days now but have not had any success. So here goes, does anybody know how to change the origin in an ortho window?. For example I want to set the origin for ALL drawing operations to the top left corner of the window as opposed to the bottom left which is the OGL default. That is the positive y-axis points down and the positive x axis points from left to right. Do I need to maybe change the mapping mode?. Any Ideas Guys?, Thanks, MAMEman

Share this post


Link to post
Share on other sites
Brother Bob    10344
glOrtho2D(0, width, height, 0), where width and height are the width and height of whatever coordinate system you want to map to the viewport. Also, set the pixel zoom to glPixelZoom(1, -1) to get pixel transfers to the frame buffer to use a Y-down axis. The viewport cannot be set in any other coordinate system that the default one though.

As you say, OpenGL's default origin is in the lower left corner. I strongly suggest you reconsider your need to have the origin in the upper left corner. Everything becomes consistent and plays nice with OpenGL (viewport for example, must be set in a lower left system). If you're not careful with translating everyting between the two coordinate systems, you are up for some unexepcted errors at some point.

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