SDL School

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

rendererThe renderer.
eventThe event to change.

Return value

True on success, which includes an event that needs no change. On failure it returns false.

Example

Use the mouse
SDL_ConvertEventToRenderCoordinates(renderer, event);

See this code run in Use the mouse. Download the full program (.zip)

Notes

In SDL2

SDL2 has no such call. SDL2 converts the events for you.

See also