API reference / Windows and drawing
SDL_ConvertEventToRenderCoordinates
Function, SDL3
Changes the position in a mouse or touch event from window coordinates to renderer coordinates.
Declaration
#include <SDL3/SDL.h>
bool SDL_ConvertEventToRenderCoordinates(SDL_Renderer *renderer, SDL_Event *event);Parameters
renderer | The renderer. |
event | The event to change. |
Return value
True on success, which includes an event that needs no change. On failure it returns false.
Example
SDL_ConvertEventToRenderCoordinates(renderer, event);See this code run in Use the mouse. Download the full program (.zip)
Notes
- Without a scaled renderer, the two sets of coordinates are the same. This call keeps your code correct after you add scaling.
In SDL2
SDL2 has no such call. SDL2 converts the events for you.