From 9017e382d94e27ec53953bece04fbd05edd8ffac Mon Sep 17 00:00:00 2001 From: Bruno Cabral Date: Sun, 6 Apr 2025 17:57:51 -0700 Subject: [PATCH] [rlgl] Preserve current mode and textureId when switching mode or texture --- src/rlgl.h | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/rlgl.h b/src/rlgl.h index d55ae82f2..c90e314f3 100644 --- a/src/rlgl.h +++ b/src/rlgl.h @@ -1473,7 +1473,10 @@ void rlBegin(int mode) if (!rlCheckRenderBatchLimit(RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment)) { RLGL.State.vertexCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment; + + int currentTextureId = RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId; RLGL.currentBatch->drawCounter++; + RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId = currentTextureId; } } @@ -1481,7 +1484,6 @@ void rlBegin(int mode) RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode = mode; RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount = 0; - RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId = RLGL.State.defaultTextureId; } } @@ -1670,7 +1672,9 @@ void rlSetTexture(unsigned int id) { RLGL.State.vertexCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment; + int currentMode = RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode; RLGL.currentBatch->drawCounter++; + RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode = currentMode; } }