Skip to main content
gamedev.net
🔒 Locked

Window coordinates

Started by patrrr 2 replies 400+ views
Original Post
patrrr
patrrr
Hello, I'm trying to use the upper-left as origin for window coordinates in OpenGL, I've got a function that converts between those and it works great when setting up the viewport (glViewport). But when I try to render to a texture using a FBO, I get the lower-left corner even though my viewport is in the upper-left! Don't FBOs use the current viewport? Thanks for any help.
Brother Bob
Brother Bob
FBO uses the viewport, yes, but the viewport's origin is always in the lower left corner. The best you can do is to convert from your upper-left system into OpenGL's lower-left system, but that only changes the parameters passed, it doesn't change the fact that the viewport is specified in a lower-left system.
patrrr
patrrr
So the FBO covers (0, 0, viewport.width, viewport.height) and not (viewport.x, viewport.y, viewport.width, viewport.height)?
Ie, it doesn't care about the viewport's position?
Brother Bob
Brother Bob
The coordinate system ranges from 0 in the lower/left corner, to height/width in the upper/right corner. This is the coordinate system in which you set the viewport. The viewport itself only defines the transformation from normalized device coordinates (the stage after perspective division) to device coordinates, nothing else.

Topic Locked

This topic has been locked by a moderator. New replies are not allowed.

Sign in to reply to this topic.