From 4008a075a857f7674fe82331dae2636fc593dade Mon Sep 17 00:00:00 2001 From: Ray Date: Sat, 15 Dec 2018 23:30:55 +0100 Subject: [PATCH] Added scissor functionality To draw only in defined area of the screen ADDED: BeginScissorMode(), EndScissorMode() --- src/raylib.h | 3 +++ src/rlgl.h | 19 +++++++++++++++++++ 2 files changed, 22 insertions(+) diff --git a/src/raylib.h b/src/raylib.h index 85272943d..3b7a322af 100644 --- a/src/raylib.h +++ b/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 diff --git a/src/rlgl.h b/src/rlgl.h index 0dff9f83d..7631adbff 100644 --- a/src/rlgl.h +++ b/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)