Skip to content

Commit 9017e38

Browse files
committed
[rlgl] Preserve current mode and textureId when switching mode or texture
1 parent f5c9630 commit 9017e38

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

Diff for: src/rlgl.h

+5-1
Original file line numberDiff line numberDiff line change
@@ -1473,15 +1473,17 @@ void rlBegin(int mode)
14731473
if (!rlCheckRenderBatchLimit(RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment))
14741474
{
14751475
RLGL.State.vertexCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment;
1476+
1477+
int currentTextureId = RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId;
14761478
RLGL.currentBatch->drawCounter++;
1479+
RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId = currentTextureId;
14771480
}
14781481
}
14791482

14801483
if (RLGL.currentBatch->drawCounter >= RL_DEFAULT_BATCH_DRAWCALLS) rlDrawRenderBatch(RLGL.currentBatch);
14811484

14821485
RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode = mode;
14831486
RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount = 0;
1484-
RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId = RLGL.State.defaultTextureId;
14851487
}
14861488
}
14871489

@@ -1670,7 +1672,9 @@ void rlSetTexture(unsigned int id)
16701672
{
16711673
RLGL.State.vertexCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment;
16721674

1675+
int currentMode = RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode;
16731676
RLGL.currentBatch->drawCounter++;
1677+
RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode = currentMode;
16741678
}
16751679
}
16761680

0 commit comments

Comments
 (0)