Fixed SDL_GetRendererOutputSize on iOS when high-DPI mode is enabled on a Retina device.

This commit is contained in:
Alex Szpakowski 2014-12-01 07:31:22 -04:00
parent bc4b6f061b
commit ba6392d79d
2 changed files with 17 additions and 0 deletions

View File

@ -55,6 +55,7 @@ static const float inv255f = 1.0f / 255.0f;
static SDL_Renderer *GLES_CreateRenderer(SDL_Window * window, Uint32 flags); static SDL_Renderer *GLES_CreateRenderer(SDL_Window * window, Uint32 flags);
static void GLES_WindowEvent(SDL_Renderer * renderer, static void GLES_WindowEvent(SDL_Renderer * renderer,
const SDL_WindowEvent *event); 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_CreateTexture(SDL_Renderer * renderer, SDL_Texture * texture);
static int GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture, static int GLES_UpdateTexture(SDL_Renderer * renderer, SDL_Texture * texture,
const SDL_Rect * rect, const void *pixels, const SDL_Rect * rect, const void *pixels,
@ -321,6 +322,7 @@ GLES_CreateRenderer(SDL_Window * window, Uint32 flags)
} }
renderer->WindowEvent = GLES_WindowEvent; renderer->WindowEvent = GLES_WindowEvent;
renderer->GetOutputSize = GLES_GetOutputSize;
renderer->CreateTexture = GLES_CreateTexture; renderer->CreateTexture = GLES_CreateTexture;
renderer->UpdateTexture = GLES_UpdateTexture; renderer->UpdateTexture = GLES_UpdateTexture;
renderer->LockTexture = GLES_LockTexture; 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 static SDL_INLINE int
power_of_2(int input) power_of_2(int input)
{ {

View File

@ -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 static int
GLES2_UpdateViewport(SDL_Renderer * renderer) GLES2_UpdateViewport(SDL_Renderer * renderer)
{ {
@ -2004,6 +2011,7 @@ GLES2_CreateRenderer(SDL_Window *window, Uint32 flags)
/* Populate the function pointers for the module */ /* Populate the function pointers for the module */
renderer->WindowEvent = &GLES2_WindowEvent; renderer->WindowEvent = &GLES2_WindowEvent;
renderer->GetOutputSize = &GLES2_GetOutputSize;
renderer->CreateTexture = &GLES2_CreateTexture; renderer->CreateTexture = &GLES2_CreateTexture;
renderer->UpdateTexture = &GLES2_UpdateTexture; renderer->UpdateTexture = &GLES2_UpdateTexture;
renderer->UpdateTextureYUV = &GLES2_UpdateTextureYUV; renderer->UpdateTextureYUV = &GLES2_UpdateTextureYUV;