@@ -1459,6 +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)
1463
+ int currentTexture = RLGL .currentBatch -> draws [RLGL .currentBatch -> drawCounter - 1 ].textureId ;
1464
+
1462
1465
if (RLGL .currentBatch -> draws [RLGL .currentBatch -> drawCounter - 1 ].vertexCount > 0 )
1463
1466
{
1464
1467
// Make sure current RLGL.currentBatch->draws[i].vertexCount is aligned a multiple of 4,
@@ -1481,13 +1484,16 @@ void rlBegin(int mode)
1481
1484
1482
1485
RLGL .currentBatch -> draws [RLGL .currentBatch -> drawCounter - 1 ].mode = mode ;
1483
1486
RLGL .currentBatch -> draws [RLGL .currentBatch -> drawCounter - 1 ].vertexCount = 0 ;
1484
- RLGL .currentBatch -> draws [RLGL .currentBatch -> drawCounter - 1 ].textureId = RLGL . State . defaultTextureId ;
1487
+ RLGL .currentBatch -> draws [RLGL .currentBatch -> drawCounter - 1 ].textureId = currentTexture ; // Preserve active texture
1485
1488
}
1486
1489
}
1487
1490
1488
1491
// Finish vertex providing
1489
1492
void rlEnd (void )
1490
1493
{
1494
+ // Reset texture to default
1495
+ rlSetTexture (RLGL .State .defaultTextureId );
1496
+
1491
1497
// NOTE: Depth increment is dependant on rlOrtho(): z-near and z-far values,
1492
1498
// as well as depth buffer bit-depth (16bit or 24bit or 32bit)
1493
1499
// Correct increment formula would be: depthInc = (zfar - znear)/pow(2, bits)
@@ -2526,11 +2532,11 @@ void rlLoadExtensions(void *loader)
2526
2532
2527
2533
// Check depth texture support
2528
2534
if (strcmp (extList [i ], (const char * )"GL_OES_depth_texture" ) == 0 ) RLGL .ExtSupported .texDepth = true;
2529
- if (strcmp (extList [i ], (const char * )"GL_WEBGL_depth_texture" ) == 0 ) RLGL .ExtSupported .texDepthWebGL = true; // WebGL requires unsized internal format
2535
+ if (strcmp (extList [i ], (const char * )"GL_WEBGL_depth_texture" ) == 0 ) RLGL .ExtSupported .texDepthWebGL = true; // WebGL requires unsized internal format
2530
2536
if (RLGL .ExtSupported .texDepthWebGL ) RLGL .ExtSupported .texDepth = true;
2531
2537
2532
- if (strcmp (extList [i ], (const char * )"GL_OES_depth24" ) == 0 ) RLGL .ExtSupported .maxDepthBits = 24 ; // Not available on WebGL
2533
- if (strcmp (extList [i ], (const char * )"GL_OES_depth32" ) == 0 ) RLGL .ExtSupported .maxDepthBits = 32 ; // Not available on WebGL
2538
+ if (strcmp (extList [i ], (const char * )"GL_OES_depth24" ) == 0 ) RLGL .ExtSupported .maxDepthBits = 24 ; // Not available on WebGL
2539
+ if (strcmp (extList [i ], (const char * )"GL_OES_depth32" ) == 0 ) RLGL .ExtSupported .maxDepthBits = 32 ; // Not available on WebGL
2534
2540
2535
2541
// Check texture compression support: DXT
2536
2542
if ((strcmp (extList [i ], (const char * )"GL_EXT_texture_compression_s3tc" ) == 0 ) ||
@@ -3055,7 +3061,7 @@ void rlDrawRenderBatch(rlRenderBatch *batch)
3055
3061
3056
3062
for (int i = 0 , vertexOffset = 0 ; i < batch -> drawCounter ; i ++ )
3057
3063
{
3058
- // 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
3059
3065
glBindTexture (GL_TEXTURE_2D , batch -> draws [i ].textureId );
3060
3066
3061
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