From ba6392d79dd4e6aa3b4a98691d373b01a144e35e Mon Sep 17 00:00:00 2001 From: Alex Szpakowski Date: Mon, 1 Dec 2014 07:31:22 -0400 Subject: [PATCH] Fixed SDL_GetRendererOutputSize on iOS when high-DPI mode is enabled on a Retina device. --- src/render/opengles/SDL_render_gles.c | 9 +++++++++ src/render/opengles2/SDL_render_gles2.c | 8 ++++++++ 2 files changed, 17 insertions(+) diff --git a/src/render/opengles/SDL_render_gles.c b/src/render/opengles/SDL_render_gles.c index 72cce305a..617bf659f 100644 --- a/src/render/opengles/SDL_render_gles.c +++ b/src/render/opengles/SDL_render_gles.c @@ -55,6 +55,7 @@ static const float inv255f = 1.0f / 255.0f; static SDL_Renderer *GLES_CreateRenderer(SDL_Window * window, Uint32 flags); static void GLES_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event); +static int GLES_GetOutputSize(SDL_Renderer * renderer, int *w, int *h); static int GLES_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture); static int GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, const SDL_Rect * rect, const void *pixels, @@ -321,6 +322,7 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags) } renderer->WindowEvent = GLES_WindowEvent; + renderer->GetOutputSize = GLES_GetOutputSize; renderer->CreateTexture = GLES_CreateTexture; renderer->UpdateTexture = GLES_UpdateTexture; renderer->LockTexture = GLES_LockTexture; @@ -438,6 +440,13 @@ GLES_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) } } +static int +GLES_GetOutputSize(SDL_Renderer * renderer, int *w, int *h) +{ + SDL_GL_GetDrawableSize(renderer->window, w, h); + return 0; +} + static SDL_INLINE int power_of_2(int input) { diff --git a/src/render/opengles2/SDL_render_gles2.c b/src/render/opengles2/SDL_render_gles2.c index fd7f1b379..cf9da6a6d 100644 --- a/src/render/opengles2/SDL_render_gles2.c +++ b/src/render/opengles2/SDL_render_gles2.c @@ -351,6 +351,13 @@ GLES2_WindowEvent(SDL_Renderer * renderer, const SDL_WindowEvent *event) } } +static int +GLES2_GetOutputSize(SDL_Renderer * renderer, int *w, int *h) +{ + SDL_GL_GetDrawableSize(renderer->window, w, h); + return 0; +} + static int GLES2_UpdateViewport(SDL_Renderer * renderer) { @@ -2004,6 +2011,7 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags) /* Populate the function pointers for the module */ renderer->WindowEvent = &GLES2_WindowEvent; + renderer->GetOutputSize = &GLES2_GetOutputSize; renderer->CreateTexture = &GLES2_CreateTexture; renderer->UpdateTexture = &GLES2_UpdateTexture; renderer->UpdateTextureYUV = &GLES2_UpdateTextureYUV;