Procházet zdrojové kódy

Added scissor functionality

To draw only in defined area of the screen
ADDED: BeginScissorMode(), EndScissorMode()
Ray před 6 roky
rodič
revize
4008a075a8
2 změnil soubory, kde provedl 22 přidání a 0 odebrání
  1. 3 0
      src/raylib.h
  2. 19 0
      src/rlgl.h

+ 3 - 0
src/raylib.h

@@ -1158,6 +1158,7 @@ RLAPI void MeshTangents(Mesh *mesh);
 RLAPI void MeshBinormals(Mesh *mesh);                                                                   // Compute mesh binormals
 
 // Mesh generation functions
+RLAPI Mesh GenMeshPoly(int sides, float radius);                                                        // Generate polygonal mesh
 RLAPI Mesh GenMeshPlane(float width, float length, int resX, int resZ);                                 // Generate plane mesh (with subdivisions)
 RLAPI Mesh GenMeshCube(float width, float height, float length);                                        // Generate cuboid mesh
 RLAPI Mesh GenMeshSphere(float radius, int rings, int slices);                                          // Generate sphere mesh (standard sphere)
@@ -1228,6 +1229,8 @@ RLAPI void BeginShaderMode(Shader shader);                                // Beg
 RLAPI void EndShaderMode(void);                                           // End custom shader drawing (use default shader)
 RLAPI void BeginBlendMode(int mode);                                      // Begin blending mode (alpha, additive, multiplied)
 RLAPI void EndBlendMode(void);                                            // End blending mode (reset to default: alpha blending)
+RLAPI void BeginScissorMode(int x, int y, int width, int height);         // Begin scissor mode (define screen area for following drawing)
+RLAPI void EndScissorMode(void);                                          // End scissor mode
 
 // VR control functions
 RLAPI VrDeviceInfo GetVrDeviceInfo(int vrDeviceType);   // Get VR device information for some standard devices

+ 19 - 0
src/rlgl.h

@@ -3313,6 +3313,25 @@ void EndBlendMode(void)
     BeginBlendMode(BLEND_ALPHA);
 }
 
+// Begin scissor mode (define screen area for following drawing)
+void BeginScissorMode(int x, int y, int width, int height)
+{
+    rlglDraw();             // Force drawing elements
+    
+    glEnable(GL_SCISSOR_TEST);
+    glScissor(x, y, width, height);
+    
+    rlClearScreenBuffers(); // Clear current scissor area
+}
+
+// End scissor mode
+void EndScissorMode(void)
+{
+    rlglDraw();             // Force drawing elements
+    
+    glDisable(GL_SCISSOR_TEST);
+}
+
 #if defined(SUPPORT_VR_SIMULATOR)
 // Get VR device information for some standard devices
 VrDeviceInfo GetVrDeviceInfo(int vrDeviceType)