mirror of
https://github.com/raysan5/raylib.git
synced 2025-10-07 10:26:28 +00:00
[rlgl] Preserve texture on mode switching (#4364)
* Fix textures on draw mode switch * formatting fix * ident
This commit is contained in:
@@ -1459,6 +1459,7 @@ void rlBegin(int mode)
|
||||
// NOTE: In all three cases, vertex are accumulated over default internal vertex buffer
|
||||
if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode != mode)
|
||||
{
|
||||
int currentTexture = RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId;
|
||||
if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount > 0)
|
||||
{
|
||||
// Make sure current RLGL.currentBatch->draws[i].vertexCount is aligned a multiple of 4,
|
||||
@@ -1481,13 +1482,14 @@ 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;
|
||||
RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId = currentTexture;
|
||||
}
|
||||
}
|
||||
|
||||
// Finish vertex providing
|
||||
void rlEnd(void)
|
||||
{
|
||||
rlSetTexture(RLGL.State.defaultTextureId);
|
||||
// NOTE: Depth increment is dependant on rlOrtho(): z-near and z-far values,
|
||||
// as well as depth buffer bit-depth (16bit or 24bit or 32bit)
|
||||
// Correct increment formula would be: depthInc = (zfar - znear)/pow(2, bits)
|
||||
|
Reference in New Issue
Block a user