src/render/opengl/SDL_render_gl.c
changeset 5224 2178ffe17222
parent 5204 daa5463466c5
child 5226 710d00cb3a6a
     1.1 --- a/src/render/opengl/SDL_render_gl.c	Mon Feb 07 20:05:52 2011 -0800
     1.2 +++ b/src/render/opengl/SDL_render_gl.c	Mon Feb 07 20:06:26 2011 -0800
     1.3 @@ -52,6 +52,7 @@
     1.4  static int GL_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
     1.5                            const SDL_Rect * rect, void **pixels, int *pitch);
     1.6  static void GL_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
     1.7 +static void GL_SetClipRect(SDL_Renderer * renderer, const SDL_Rect * rect);
     1.8  static int GL_RenderClear(SDL_Renderer * renderer);
     1.9  static int GL_RenderDrawPoints(SDL_Renderer * renderer,
    1.10                                 const SDL_Point * points, int count);
    1.11 @@ -199,6 +200,7 @@
    1.12      renderer->UpdateTexture = GL_UpdateTexture;
    1.13      renderer->LockTexture = GL_LockTexture;
    1.14      renderer->UnlockTexture = GL_UnlockTexture;
    1.15 +    renderer->SetClipRect = GL_SetClipRect;
    1.16      renderer->RenderClear = GL_RenderClear;
    1.17      renderer->RenderDrawPoints = GL_RenderDrawPoints;
    1.18      renderer->RenderDrawLines = GL_RenderDrawLines;
    1.19 @@ -511,6 +513,24 @@
    1.20  }
    1.21  
    1.22  static void
    1.23 +GL_SetClipRect(SDL_Renderer * renderer, const SDL_Rect * rect)
    1.24 +{
    1.25 +    GL_RenderData *data = (GL_RenderData *) renderer->driverdata;
    1.26 +
    1.27 +    GL_ActivateRenderer(renderer);
    1.28 +
    1.29 +    if (rect) {
    1.30 +        int w, h;
    1.31 +
    1.32 +        SDL_GetWindowSize(renderer->window, &w, &h);
    1.33 +        data->glScissor(rect->x, (h-(rect->y+rect->h)), rect->w, rect->h);
    1.34 +        data->glEnable(GL_SCISSOR_TEST);
    1.35 +    } else {
    1.36 +        data->glDisable(GL_SCISSOR_TEST);
    1.37 +    }
    1.38 +}
    1.39 +
    1.40 +static void
    1.41  GL_SetBlendMode(GL_RenderData * data, int blendMode)
    1.42  {
    1.43      if (blendMode != data->blendMode) {