mirror of
https://github.com/libsdl-org/SDL.git
synced 2025-12-21 12:51:07 +08:00
Removed SDL_GetDisplayDPI()
This function wasn't consistently correct across platforms and devices. If you want the UI scale factor, you can use display_scale in the structure returned by SDL_GetDesktopDisplayMode(). If you need an approximate DPI, you can multiply this value times 160 on iPhone and Android, and 96 on other platforms.
This commit is contained in:
@@ -53,19 +53,12 @@ int main(int argc, char *argv[])
|
||||
for (i = 0; i < num_displays; i++) {
|
||||
SDL_DisplayID dpy = displays[i];
|
||||
SDL_Rect rect = { 0, 0, 0, 0 };
|
||||
float ddpi, hdpi, vdpi;
|
||||
int m, num_modes = 0;
|
||||
|
||||
SDL_GetDisplayBounds(dpy, &rect);
|
||||
modes = SDL_GetFullscreenDisplayModes(dpy, &num_modes);
|
||||
SDL_Log("%" SDL_PRIu32 ": \"%s\" (%dx%d, (%d, %d)), %d fullscreen modes.\n", dpy, SDL_GetDisplayName(dpy), rect.w, rect.h, rect.x, rect.y, num_modes);
|
||||
|
||||
if (SDL_GetDisplayPhysicalDPI(dpy, &ddpi, &hdpi, &vdpi) == -1) {
|
||||
SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, " DPI: failed to query (%s)\n", SDL_GetError());
|
||||
} else {
|
||||
SDL_Log(" DPI: ddpi=%f; hdpi=%f; vdpi=%f\n", ddpi, hdpi, vdpi);
|
||||
}
|
||||
|
||||
mode = SDL_GetCurrentDisplayMode(dpy);
|
||||
if (mode) {
|
||||
print_mode("CURRENT", mode);
|
||||
|
||||
Reference in New Issue
Block a user