]> Chaos Git - corbenik/ctrulib.git/commitdiff
Scissor test.
authorStapleButter <thetotalworm@gmail.com>
Mon, 10 Nov 2014 23:12:31 +0000 (00:12 +0100)
committerStapleButter <thetotalworm@gmail.com>
Mon, 10 Nov 2014 23:12:31 +0000 (00:12 +0100)
(if calling SetScissorTest right after SetViewport, call FinishDrawing inbetween)

libctru/include/3ds/gpu/gpu.h
libctru/source/gpu/gpu.c

index c865867eadf34964383a902ab4cb3bd76d659c90..5700d93ad7b19386ffd46eda0475821e6af4de24 100644 (file)
@@ -65,6 +65,15 @@ typedef enum
        GPU_GEQUAL = 7
 }GPU_TESTFUNC;
 
+typedef enum
+{
+       GPU_SCISSOR_DISABLE = 0,        // disable scissor test
+       GPU_SCISSOR_INVERT = 1,         // exclude pixels inside the scissor box
+       // 2 is the same as 0
+       GPU_SCISSOR_NORMAL = 3,         // exclude pixels outside of the scissor box
+       
+} GPU_SCISSORMODE;
+
 typedef enum
 {
        GPU_KEEP = 0,           // keep destination value
@@ -183,6 +192,8 @@ void GPU_SetUniform(u32 startreg, u32* data, u32 numreg);
 
 void GPU_SetViewport(u32* depthBuffer, u32* colorBuffer, u32 x, u32 y, u32 w, u32 h);
 
+void GPU_SetScissorTest(GPU_SCISSORMODE mode, u32 x, u32 y, u32 w, u32 h);
+
 void GPU_DepthRange(float nearVal, float farVal);
 void GPU_SetAlphaTest(bool enable, GPU_TESTFUNC function, u8 ref);
 void GPU_SetDepthTestAndWriteMask(bool enable, GPU_TESTFUNC function, GPU_WRITEMASK writemask); // GPU_WRITEMASK values can be ORed together
index 8bfde8b6957c46315d6b5f7c708693b1e91de16e..c83a9aab394857a77d128aaf727afc429ccb5c37 100644 (file)
@@ -304,6 +304,16 @@ void GPU_SetViewport(u32* depthBuffer, u32* colorBuffer, u32 x, u32 y, u32 w, u3
        GPUCMD_Add(0x800F0112, param, 0x00000004);
 }
 
+void GPU_SetScissorTest(GPU_SCISSORMODE mode, u32 x, u32 y, u32 w, u32 h)
+{
+       u32 param[3];
+       
+       param[0x0] = mode;
+       param[0x1] = (y<<16)|(x&0xFFFF);
+       param[0x2] = ((h-1)<<16)|((w-1)&0xFFFF);
+       GPUCMD_Add(0x800F0065, param, 0x00000003);
+}
+
 void GPU_DepthRange(float nearVal, float farVal)
 {
        GPUCMD_AddSingleParam(0x000F006D, 0x00000001); //?