Windows & displaysSDL 3.2
SDL_GetWindowSize
Reads the size of the window's content area in WINDOW coordinates (the units of mouse events).
Signature
bool SDL_GetWindowSize(SDL_Window *window, int *w, int *h);
How it works
SDL has two units. Window coordinates are what you pass to SDL_CreateWindow and what mouse events report. Pixels are the real dots. On a Retina Mac with SDL_WINDOW_HIGH_PIXEL_DENSITY, a 800×600 window has 1600×1200 pixels.
Use this size to make sense of mouse positions. For anything that draws (viewports, render targets, GPU textures), use SDL_GetWindowSizeInPixels.
Parameters
windowSDL_Window *
The window to measure.
wint *
Where to write the width, or NULL.
hint *
Where to write the height, or NULL.
Return value
true on success, false on failure.
Example
example.cpp
1int w, h;
2SDL_GetWindowSize(window, &w, &h);
3float u = e.motion.x / w; // 0..1 across the window