SDL2 - Draw Bottom Left
SDL2 uses a top-level (0,0) configuration with a positive y-axis pointing down. How can I change this for y pointing up from the bottom left? Note that the area covered by the input coordinates may or may not be the same as the screen area.
Usually I would just change the projection matrix to whatever I need, but I don't have access to that through the SDL API?
+3
source to share
1 answer
How about a function that transforms it for you?
float convertPointY(float y) {
return -y + WINDOW_HEIGHT;
}
And if the window resizes without having a constant height:
float convertPointY(float y) {
int width = 0, height = 0;
SDL_GetWindowSize(window, &width, &height);
return -y + height;
}
+1
source to share