• Advertisement
Sign in to follow this  

Changing the Origin In OGL

This topic is 3948 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, 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
Advertisement
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
Sign in to follow this  

  • Advertisement