Windows & displaysSDL 3.2
SDL_GetDisplayForWindow
Tells which monitor (display) the window is on.
Signature
SDL_DisplayID SDL_GetDisplayForWindow(SDL_Window *window);
How it works
Display functions such as SDL_GetCurrentDisplayMode take an SDL_DisplayID, a number naming one monitor. This gets the one the window is mostly on. SDL_GetPrimaryDisplay gives the main monitor instead.
Parameters
windowSDL_Window *
The window.
Return value
The display ID, or 0 on failure.
Example
example.cpp
1SDL_DisplayID display = SDL_GetDisplayForWindow(window);
2const SDL_DisplayMode* mode = SDL_GetCurrentDisplayMode(display);