Fixes OpenGL* Clip Rect functions (by Emmanuel Gil Peyrot)
authorGabriel Jacobo <gabomdq@gmail.com>
Fri, 10 May 2013 10:31:01 -0300
changeset 7160bfb5f8f4f006
parent 7159 ffc613268eb1
child 7161 1619292eec30
Fixes OpenGL* Clip Rect functions (by Emmanuel Gil Peyrot)
src/render/opengl/SDL_render_gl.c
src/render/opengles/SDL_glesfuncs.h
src/render/opengles/SDL_render_gles.c
src/render/opengles2/SDL_gles2funcs.h
src/render/opengles2/SDL_render_gles2.c
     1.1 --- a/src/render/opengl/SDL_render_gl.c	Thu May 09 16:30:44 2013 -0700
     1.2 +++ b/src/render/opengl/SDL_render_gl.c	Fri May 10 10:31:01 2013 -0300
     1.3 @@ -794,7 +794,7 @@
     1.4  
     1.5      if (!SDL_RectEmpty(rect)) {
     1.6          data->glEnable(GL_SCISSOR_TEST);
     1.7 -        data->glScissor(rect->x, rect->y, rect->x + rect->w, rect->y + rect->h);
     1.8 +        data->glScissor(rect->x, rect->h - rect->y, rect->x, rect->y);
     1.9      } else {
    1.10          data->glDisable(GL_SCISSOR_TEST);
    1.11      }
     2.1 --- a/src/render/opengles/SDL_glesfuncs.h	Thu May 09 16:30:44 2013 -0700
     2.2 +++ b/src/render/opengles/SDL_glesfuncs.h	Fri May 10 10:31:01 2013 -0300
     2.3 @@ -20,6 +20,7 @@
     2.4  SDL_PROC(void, glOrthof, (GLfloat, GLfloat, GLfloat, GLfloat, GLfloat, GLfloat))
     2.5  SDL_PROC(void, glPixelStorei, (GLenum, GLint))
     2.6  SDL_PROC(void, glReadPixels, (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid*))
     2.7 +SDL_PROC(void, glScissor, (GLint, GLint, GLsizei, GLsizei))
     2.8  SDL_PROC(void, glTexCoordPointer, (GLint, GLenum, GLsizei, const GLvoid *))
     2.9  SDL_PROC(void, glTexEnvf, (GLenum, GLenum, GLfloat))
    2.10  SDL_PROC(void, glTexImage2D, (GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid *))
     3.1 --- a/src/render/opengles/SDL_render_gles.c	Thu May 09 16:30:44 2013 -0700
     3.2 +++ b/src/render/opengles/SDL_render_gles.c	Fri May 10 10:31:01 2013 -0300
     3.3 @@ -635,13 +635,19 @@
     3.4  static int
     3.5  GLES_UpdateClipRect(SDL_Renderer * renderer)
     3.6  {
     3.7 +    GLES_RenderData *data = (GLES_RenderData *) renderer->driverdata;
     3.8      const SDL_Rect *rect = &renderer->clip_rect;
     3.9  
    3.10 +    if (SDL_CurrentContext != data->context) {
    3.11 +        /* We'll update the clip rect after we rebind the context */
    3.12 +        return 0;
    3.13 +    }
    3.14 +
    3.15      if (!SDL_RectEmpty(rect)) {
    3.16 -        glEnable(GL_SCISSOR_TEST);
    3.17 -        glScissor(rect->x, rect->y, rect->x + rect->w, rect->y + rect->h);
    3.18 +        data->glEnable(GL_SCISSOR_TEST);
    3.19 +        data->glScissor(rect->x, rect->h - rect->y, rect->w, rect->h);
    3.20      } else {
    3.21 -        glDisable(GL_SCISSOR_TEST);
    3.22 +        data->glDisable(GL_SCISSOR_TEST);
    3.23      }
    3.24      return 0;
    3.25  }
     4.1 --- a/src/render/opengles2/SDL_gles2funcs.h	Thu May 09 16:30:44 2013 -0700
     4.2 +++ b/src/render/opengles2/SDL_gles2funcs.h	Fri May 10 10:31:01 2013 -0300
     4.3 @@ -30,6 +30,7 @@
     4.4  SDL_PROC(void, glLinkProgram, (GLuint))
     4.5  SDL_PROC(void, glPixelStorei, (GLenum, GLint))
     4.6  SDL_PROC(void, glReadPixels, (GLint, GLint, GLsizei, GLsizei, GLenum, GLenum, GLvoid*))
     4.7 +SDL_PROC(void, glScissor, (GLint, GLint, GLsizei, GLsizei))
     4.8  SDL_PROC(void, glShaderBinary, (GLsizei, const GLuint *, GLenum, const void *, GLsizei))
     4.9  SDL_PROC(void, glShaderSource, (GLuint, GLsizei, const char **, const GLint *))
    4.10  SDL_PROC(void, glTexImage2D, (GLenum, GLint, GLint, GLsizei, GLsizei, GLint, GLenum, GLenum, const void *))
     5.1 --- a/src/render/opengles2/SDL_render_gles2.c	Thu May 09 16:30:44 2013 -0700
     5.2 +++ b/src/render/opengles2/SDL_render_gles2.c	Fri May 10 10:31:01 2013 -0300
     5.3 @@ -278,13 +278,19 @@
     5.4  static int
     5.5  GLES2_UpdateClipRect(SDL_Renderer * renderer)
     5.6  {
     5.7 +    GLES2_DriverContext *rdata = (GLES2_DriverContext *)renderer->driverdata;
     5.8      const SDL_Rect *rect = &renderer->clip_rect;
     5.9  
    5.10 +    if (SDL_CurrentContext != rdata->context) {
    5.11 +        /* We'll update the clip rect after we rebind the context */
    5.12 +        return 0;
    5.13 +    }
    5.14 +
    5.15      if (!SDL_RectEmpty(rect)) {
    5.16 -        glEnable(GL_SCISSOR_TEST);
    5.17 -        glScissor(rect->x, rect->y, rect->x + rect->w, rect->y + rect->h);
    5.18 +        rdata->glEnable(GL_SCISSOR_TEST);
    5.19 +        rdata->glScissor(rect->x, rect->h - rect->y, rect->w, rect->h);
    5.20      } else {
    5.21 -        glDisable(GL_SCISSOR_TEST);
    5.22 +        rdata->glDisable(GL_SCISSOR_TEST);
    5.23      }
    5.24      return 0;
    5.25  }