From 797e0ac9401b9e3d8f9162b8e85fd915efeb765c Mon Sep 17 00:00:00 2001 From: 8bitprodigy Date: Wed, 15 Oct 2025 01:18:42 -0700 Subject: [PATCH] Added `void rlClearDepthBuffer(void)` to clear the depth buffer. Very useful for making FPS games. --- src/rlgl.h | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/rlgl.h b/src/rlgl.h index ecd3795a9..8d1b41d7a 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -2108,6 +2108,13 @@ void rlClearColor(unsigned char r, unsigned char g, unsigned char b, unsigned ch glClearColor(cr, cg, cb, ca); } +// Clears the depth buffer. Useful for drawing first person weapons over the +// rendered scene without them clipping through world geometry. +void rlClearDepthBuffer(void) +{ + glClear(GL_DEPTH_BUFFER_BIT); // Beats having to #import just to call this one function. +} + // Clear used screen buffers (color and depth) void rlClearScreenBuffers(void) { @@ -5364,4 +5371,4 @@ static Matrix rlMatrixInvert(Matrix mat) } #endif -#endif // RLGL_IMPLEMENTATION \ No newline at end of file +#endif // RLGL_IMPLEMENTATION