Better fix for bug 2207 - SDL_RenderSetViewport behavior is different/incorrect on OpenGL renderer vs DirectX renderer
authorSam Lantinga <slouken@libsdl.org>
Fri, 15 Nov 2013 22:07:35 -0800
changeset 79950eed14683885
parent 7994 37c48b4ecb0c
child 7996 be1526907541
Better fix for bug 2207 - SDL_RenderSetViewport behavior is different/incorrect on OpenGL renderer vs DirectX renderer
At least, it works better here on my Mac. :)
src/render/opengl/SDL_render_gl.c
     1.1 --- a/src/render/opengl/SDL_render_gl.c	Fri Nov 15 22:05:26 2013 -0800
     1.2 +++ b/src/render/opengl/SDL_render_gl.c	Fri Nov 15 22:07:35 2013 -0800
     1.3 @@ -919,13 +919,21 @@
     1.4          return 0;
     1.5      }
     1.6  
     1.7 -    data->glViewport(renderer->viewport.x, renderer->viewport.y,
     1.8 -                     renderer->viewport.w, renderer->viewport.h);
     1.9 +    if (renderer->target) {
    1.10 +        data->glViewport(renderer->viewport.x, renderer->viewport.y,
    1.11 +                         renderer->viewport.w, renderer->viewport.h);
    1.12 +    } else {
    1.13 +        int w, h;
    1.14 +
    1.15 +        SDL_GetRendererOutputSize(renderer, &w, &h);
    1.16 +        data->glViewport(renderer->viewport.x, (h - renderer->viewport.y - renderer->viewport.h),
    1.17 +                         renderer->viewport.w, renderer->viewport.h);
    1.18 +    }
    1.19  
    1.20      data->glMatrixMode(GL_PROJECTION);
    1.21      data->glLoadIdentity();
    1.22      if (renderer->viewport.w && renderer->viewport.h) {
    1.23 -        if (!renderer->target) {
    1.24 +        if (renderer->target) {
    1.25              data->glOrtho((GLdouble) 0,
    1.26                            (GLdouble) renderer->viewport.w,
    1.27                            (GLdouble) 0,