From d4f9123500e793c19eaf32384bff92b4013e9dfc Mon Sep 17 00:00:00 2001 From: Chris Dill Date: Sat, 25 Jul 2026 10:44:36 +0100 Subject: [PATCH] Add render batch utility functions for depth control Allows existing draw functions to be drawn out of order at different depths while still using batching. * Add rlGetRenderBatchActive to match rlSetRenderBatchActive * Add rlGetRenderBatchDepth to get the depth for the active render batch * Add rlSetRenderBatchDepth to set the depth for the active render batch --- src/rlgl.h | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/src/rlgl.h b/src/rlgl.h index be24bbb78ca2..c827fd270431 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -730,10 +730,14 @@ RLAPI int *rlGetShaderLocsDefault(void); // Get default shader lo RLAPI rlRenderBatch rlLoadRenderBatch(int numBuffers, int bufferElements); // Load a render batch system RLAPI void rlUnloadRenderBatch(rlRenderBatch batch); // Unload render batch system RLAPI void rlDrawRenderBatch(rlRenderBatch *batch); // Draw render batch data (Update->Draw->Reset) +RLAPI rlRenderBatch* rlGetRenderBatchActive(void); // Get the active render batch RLAPI void rlSetRenderBatchActive(rlRenderBatch *batch); // Set the active render batch for rlgl (NULL for default internal) RLAPI void rlDrawRenderBatchActive(void); // Update and draw internal render batch RLAPI bool rlCheckRenderBatchLimit(int vCount); // Check internal buffer overflow for a given number of vertex +RLAPI float rlGetRenderBatchDepth(); // Get the depth for the active render batch +RLAPI void rlSetRenderBatchDepth(float depth); // Set the depth for the active render batch + RLAPI void rlSetTexture(unsigned int id); // Set current texture for render batch and check buffers limits //------------------------------------------------------------------------------------------------------------------------ @@ -3179,6 +3183,12 @@ void rlDrawRenderBatch(rlRenderBatch *batch) #endif } +// Get the active render batch for rlgl +rlRenderBatch* rlGetRenderBatchActive() +{ + return RLGL.currentBatch; +} + // Set the active render batch for rlgl void rlSetRenderBatchActive(rlRenderBatch *batch) { @@ -3225,6 +3235,18 @@ bool rlCheckRenderBatchLimit(int vCount) return overflow; } +// Get the depth for the active render batch +float rlGetRenderBatchDepth() +{ + return RLGL.currentBatch->currentDepth; +} + +// Set the depth for the active render batch +void rlSetRenderBatchDepth(float depth) +{ + RLGL.currentBatch->currentDepth = depth; +} + // Textures data management //----------------------------------------------------------------------------------------- // Convert image data to OpenGL texture (returns OpenGL valid Id)