From 558459fb9b8acef1cc9bfdfbcba1de35ab2a7f88 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jean-Andr=C3=A9=20Santoni?= Date: Tue, 21 Apr 2015 18:58:19 +0700 Subject: [PATCH] (iOS) Fix dpi, still incomplete --- gfx/drivers_context/cocoa_gl_ctx.m | 13 +++++++++++-- 1 file changed, 11 insertions(+), 2 deletions(-) diff --git a/gfx/drivers_context/cocoa_gl_ctx.m b/gfx/drivers_context/cocoa_gl_ctx.m index a50ae02ea7..d2d2ac2d15 100644 --- a/gfx/drivers_context/cocoa_gl_ctx.m +++ b/gfx/drivers_context/cocoa_gl_ctx.m @@ -354,6 +354,7 @@ static bool cocoagl_gfx_ctx_get_metrics(void *data, enum display_metric_types ty float physical_width = display_physical_size.width; float physical_height = display_physical_size.height; float scale = screen.backingScaleFactor; + float dpi = (display_width/ physical_width) * 25.4f * scale; #elif defined(HAVE_COCOATOUCH) float scale = cocoagl_gfx_ctx_get_native_scale(); CGRect screen_rect = [[UIScreen mainScreen] bounds]; @@ -362,6 +363,15 @@ static bool cocoagl_gfx_ctx_get_metrics(void *data, enum display_metric_types ty float display_height = screen_rect.size.height; float physical_width = screen_rect.size.width * scale; float physical_height = screen_rect.size.height * scale; + float dpi = 0; + + if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPad) { + dpi = 132 * scale; + } else if (UI_USER_INTERFACE_IDIOM() == UIUserInterfaceIdiomPhone) { + dpi = 163 * scale; + } else { + dpi = 160 * scale; + } #endif (void)display_height; @@ -375,8 +385,7 @@ static bool cocoagl_gfx_ctx_get_metrics(void *data, enum display_metric_types ty *value = physical_height; break; case DISPLAY_METRIC_DPI: - /* 25.4 mm in an inch. */ - *value = (display_width/ physical_width) * 25.4f * scale; + *value = dpi; break; case DISPLAY_METRIC_NONE: default: