@@ -1459,7 +1459,9 @@ void rlBegin(int mode)
1459
1459
// NOTE: In all three cases, vertex are accumulated over default internal vertex buffer
1460
1460
if (RLGL .currentBatch -> draws [RLGL .currentBatch -> drawCounter - 1 ].mode != mode )
1461
1461
{
1462
+ // Get current binded texture to preserve it between draw modes change (QUADS <--> TRIANGLES)
1462
1463
int currentTexture = RLGL .currentBatch -> draws [RLGL .currentBatch -> drawCounter - 1 ].textureId ;
1464
+
1463
1465
if (RLGL .currentBatch -> draws [RLGL .currentBatch -> drawCounter - 1 ].vertexCount > 0 )
1464
1466
{
1465
1467
// Make sure current RLGL.currentBatch->draws[i].vertexCount is aligned a multiple of 4,
@@ -1482,14 +1484,16 @@ void rlBegin(int mode)
1482
1484
1483
1485
RLGL .currentBatch -> draws [RLGL .currentBatch -> drawCounter - 1 ].mode = mode ;
1484
1486
RLGL .currentBatch -> draws [RLGL .currentBatch -> drawCounter - 1 ].vertexCount = 0 ;
1485
- RLGL .currentBatch -> draws [RLGL .currentBatch -> drawCounter - 1 ].textureId = currentTexture ;
1487
+ RLGL .currentBatch -> draws [RLGL .currentBatch -> drawCounter - 1 ].textureId = currentTexture ; // Preserve active texture
1486
1488
}
1487
1489
}
1488
1490
1489
1491
// Finish vertex providing
1490
1492
void rlEnd (void )
1491
1493
{
1494
+ // Reset texture to default
1492
1495
rlSetTexture (RLGL .State .defaultTextureId );
1496
+
1493
1497
// NOTE: Depth increment is dependant on rlOrtho(): z-near and z-far values,
1494
1498
// as well as depth buffer bit-depth (16bit or 24bit or 32bit)
1495
1499
// Correct increment formula would be: depthInc = (zfar - znear)/pow(2, bits)
@@ -3057,7 +3061,7 @@ void rlDrawRenderBatch(rlRenderBatch *batch)
3057
3061
3058
3062
for (int i = 0 , vertexOffset = 0 ; i < batch -> drawCounter ; i ++ )
3059
3063
{
3060
- // Bind current draw call texture, activated as GL_TEXTURE0 and Bound to sampler2D texture0 by default
3064
+ // Bind current draw call texture, activated as GL_TEXTURE0 and bound to sampler2D texture0 by default
3061
3065
glBindTexture (GL_TEXTURE_2D , batch -> draws [i ].textureId );
3062
3066
3063
3067
if ((batch -> draws [i ].mode == RL_LINES ) || (batch -> draws [i ].mode == RL_TRIANGLES )) glDrawArrays (batch -> draws [i ].mode , vertexOffset , batch -> draws [i ].vertexCount );
0 commit comments