Fixed SDL_GetRendererOutputSize on iOS when high-DPI mode is enabled on a Retina device. iOS-improvements
authorAlex Szpakowski <slime73@gmail.com>
Mon, 01 Dec 2014 07:31:22 -0400
branchiOS-improvements
changeset 9530 ac0885050d79
parent 9529 4bf9830d8153
child 9531 b7ad394978b1
Fixed SDL_GetRendererOutputSize on iOS when high-DPI mode is enabled on a Retina device.
src/render/opengles/SDL_render_gles.c
src/render/opengles2/SDL_render_gles2.c
--- a/src/render/opengles/SDL_render_gles.c	Thu Nov 27 20:25:54 2014 -0400
+++ b/src/render/opengles/SDL_render_gles.c	Mon Dec 01 07:31:22 2014 -0400
@@ -55,6 +55,7 @@
 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 @@
     }
 
     renderer->WindowEvent = GLES_WindowEvent;
+    renderer->GetOutputSize = GLES_GetOutputSize;
     renderer->CreateTexture = GLES_CreateTexture;
     renderer->UpdateTexture = GLES_UpdateTexture;
     renderer->LockTexture = GLES_LockTexture;
@@ -438,6 +440,13 @@
     }
 }
 
+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)
 {
--- a/src/render/opengles2/SDL_render_gles2.c	Thu Nov 27 20:25:54 2014 -0400
+++ b/src/render/opengles2/SDL_render_gles2.c	Mon Dec 01 07:31:22 2014 -0400
@@ -352,6 +352,13 @@
 }
 
 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)
 {
     GLES2_DriverContext *data = (GLES2_DriverContext *)renderer->driverdata;
@@ -2004,6 +2011,7 @@
 
     /* 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;