Search code examples
c++graphrenderingcoordinate-systemssfml

Mirroring the Y axis in SFML


Hey so I'm integrating box2d and SFML, and box2D has the same odd, mirrored Y-axis coordinate system as SFML, meaning everything is rendered upside down. Is there some kind of function or short amount of code I can put that simply mirrors the window's render contents?

I'm thinking I can put something in sf::view to help with this...

How can i easily flip the Y-axis easily, for rendering purposes, not effecting the bodies dimensions/locations?


Solution

  • I don't know what is box2d but when I wanted to flip Y axis using openGL, I just applied negative scaling factor to projection matrix, like:

    glMatrixMode(GL_PROJECTION);
    glLoadIdentity();
    glScalef(1.0f, -1.0f, 1.0f);
    

    If you want to do it independent of openGL simply apply a sf::View with a negative x value.