Sign in to follow this  

Flipping Y Coordinate

This topic is 4687 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

Are you doing this in 3d or 2d?
This is what I do for 2d, the GUI:

void oglCanvas::SetupOrthoMode(void)
{
// Setup projection matrix
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
// Go into ortho mode with same dimensions as the frame
// Reverse the bottom,top values so the coordinates are
// 0,0 is upper left, not lower left.
glOrtho(0, Frame->getFrameWidth(), Frame->getFrameHeight(), 0, -1, 1);
// Go back to Model View mode
glMatrixMode(GL_MODELVIEW);
glLoadIdentity();
// Go into Scissor mode since we want to clip the windows
glEnable(GL_SCISSOR_TEST);
glScissor(0, 0, Frame->getFrameWidth(), Frame->getFrameHeight());
}

Share this post


Link to post
Share on other sites
I don't know why you would want to do that? In math 0,0 or the origin is the bottom left, this is how OpenGL is setup. Plus for 2D work doesn't it make more sense to have Y Axis move upward as a positive value instead of a negative value? If you want to still use Y axis as inverted just add or sub the screen height with a const variable to your vertex Y axis values... if you are doing 2D work.

Share this post


Link to post
Share on other sites
Im doing 3d (well perspective) and i need to do it because when i render to a texture opengl creates the pixel buffer from the top left, which doesnt correspond with the way a textured quad in 2d would work (there are more complex issues than just this seemingly simple problem). The most elegant maner, considering my project, to avoid special case code would be for me to alter the y coordinates while transforming to NDC. Although I dont think opengl supplies a means to do this.

Share this post


Link to post
Share on other sites

This topic is 4687 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.

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