Skip to content

Instantly share code, notes, and snippets.

@slouken
Created March 19, 2023 18:15
Show Gist options
  • Save slouken/146fda70e9c919422c70731378ef882d to your computer and use it in GitHub Desktop.
Save slouken/146fda70e9c919422c70731378ef882d to your computer and use it in GitHub Desktop.
SDL 3.0 - Get desktop UI scale
float scale = 1.0f;
SDL_DisplayID display = SDL_GetDisplayForWindow(window);
const SDL_DisplayMode *mode = SDL_GetDesktopDisplayMode(display);
if (mode) {
scale = mode->display_scale;
}
SDL_Log("Window content scale: %d%%\n", (int)(scale * 100.0f));
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment