diff src/render/direct3d/SDL_render_d3d.c @ 5229:2178ffe17222

Added function SDL_RenderSetClipRect()
author Sam Lantinga <slouken@libsdl.org>
date Mon, 07 Feb 2011 20:06:26 -0800
parents 25ffd4e5255c
children 710d00cb3a6a
line wrap: on
line diff
--- a/src/render/direct3d/SDL_render_d3d.c	Mon Feb 07 20:05:52 2011 -0800
+++ b/src/render/direct3d/SDL_render_d3d.c	Mon Feb 07 20:06:26 2011 -0800
@@ -96,6 +96,7 @@
 static int D3D_LockTexture(SDL_Renderer * renderer, SDL_Texture * texture,
                            const SDL_Rect * rect, void **pixels, int *pitch);
 static void D3D_UnlockTexture(SDL_Renderer * renderer, SDL_Texture * texture);
+static void D3D_SetClipRect(SDL_Renderer * renderer, const SDL_Rect * rect);
 static int D3D_RenderDrawPoints(SDL_Renderer * renderer,
                                 const SDL_Point * points, int count);
 static int D3D_RenderDrawLines(SDL_Renderer * renderer,
@@ -308,6 +309,7 @@
     renderer->UpdateTexture = D3D_UpdateTexture;
     renderer->LockTexture = D3D_LockTexture;
     renderer->UnlockTexture = D3D_UnlockTexture;
+    renderer->SetClipRect = D3D_SetClipRect;
     renderer->RenderDrawPoints = D3D_RenderDrawPoints;
     renderer->RenderDrawLines = D3D_RenderDrawLines;
     renderer->RenderFillRects = D3D_RenderFillRects;
@@ -602,6 +604,27 @@
 }
 
 static void
+D3D_SetClipRect(SDL_Renderer * renderer, const SDL_Rect * rect)
+{
+    D3D_RenderData *data = (D3D_RenderData *) renderer->driverdata;
+
+    if (rect) {
+        RECT d3drect;
+
+        d3drect.left = rect->x;
+        d3drect.right = rect->x + rect->w;
+        d3drect.top = rect->y;
+        d3drect.bottom = rect->y + rect->h;
+        IDirect3DDevice9_SetScissorRect(data->device, &d3drect);
+        IDirect3DDevice9_SetRenderState(data->device, D3DRS_SCISSORTESTENABLE,
+                                        TRUE);
+    } else {
+        IDirect3DDevice9_SetRenderState(data->device, D3DRS_SCISSORTESTENABLE,
+                                        FALSE);
+    }
+}
+
+static void
 D3D_SetBlendMode(D3D_RenderData * data, int blendMode)
 {
     switch (blendMode) {