Search code examples
openglcoordinatescoordinate-systems

change the axis Y. From "bottom left" to "top left"? (opengl)


change the axis Y. From "bottom left" to "top left"? Tried glScalef (1.f,-1.f, 1.f); But it turns everything upside down. How to make a glRectf (0,0,200,200); draw in the upper left corner instead of the bottom left?


Solution

  • Given

    • width and height of the viewport,
    • and an "corresponding" orthographic projection (e.g. gluOrtho2D(0, width, 0, height),
    • and no other model view transformation,

    glRectf(0, height, 200, height-200) creates the desired output.