Search code examples
c++graphicsraylib

How to mirror one axis in raylib?


Change in coordinate system

I am creating a game using the raylib library in c++. By default, raylib's coordinate system (top) origin is at the top-left corner of the screen with the positive x-direction towards the right and the positive y-direction down. I wish to have a coordinate system (bottom) with its origin at the bottom center of the screen with the positive x-direction towards the right and positive y-direction up.

Using Camera2D, I am able to get the correct translation and scaling for the game coordinate system. However, I am unable to align the axis how I want. That is, either the x-axis or y-axis is reflected. Is there any way to reflect only a single axis?

Note: I understand I can simply use negative values on one axis to get the desired effect. Though, that is impractical for my purposes.


Solution

  • I ended up solving this issue by using rlgl.h functionality rather than the Camera2D system. Specifically, the rlScalef function allows for scaling each axis individually, rather than just the single zoom attribute of Camera2D.