src/render/opengles/SDL_render_gles.c
changeset 5224 2178ffe17222
parent 5209 115fff0641ee
child 5226 710d00cb3a6a
--- a/src/render/opengles/SDL_render_gles.c	Mon Feb 07 20:05:52 2011 -0800
+++ b/src/render/opengles/SDL_render_gles.c	Mon Feb 07 20:06:26 2011 -0800
@@ -56,6 +56,7 @@
                             const SDL_Rect * rect, void **pixels, int *pitch);
 static void GLES_UnlockTexture(SDL_Renderer * renderer,
                                SDL_Texture * texture);
+static void GLES_SetClipRect(SDL_Renderer * renderer, const SDL_Rect * rect);
 static int GLES_RenderDrawPoints(SDL_Renderer * renderer,
                                  const SDL_Point * points, int count);
 static int GLES_RenderDrawLines(SDL_Renderer * renderer,
@@ -172,6 +173,7 @@
     renderer->UpdateTexture = GLES_UpdateTexture;
     renderer->LockTexture = GLES_LockTexture;
     renderer->UnlockTexture = GLES_UnlockTexture;
+    renderer->SetClipRect = GLES_SetClipRect;
     renderer->RenderDrawPoints = GLES_RenderDrawPoints;
     renderer->RenderDrawLines = GLES_RenderDrawLines;
     renderer->RenderFillRects = GLES_RenderFillRects;
@@ -444,6 +446,22 @@
 }
 
 static void
+GLES_SetClipRect(SDL_Renderer * renderer, const SDL_Rect * rect)
+{
+    GL_ActivateRenderer(renderer);
+
+    if (rect) {
+        int w, h;
+
+        SDL_GetWindowSize(renderer->window, &w, &h);
+        glScissor(rect->x, (h-(rect->y+rect->h)), rect->w, rect->h);
+        glEnable(GL_SCISSOR_TEST);
+    } else {
+        glDisable(GL_SCISSOR_TEST);
+    }
+}
+
+static void
 GLES_SetBlendMode(GLES_RenderData * data, int blendMode)
 {
     if (blendMode != data->blendMode) {