@@ -1067,6 +1067,7 @@ typedef struct rlglData {
1067
1067
Matrix stack [RL_MAX_MATRIX_STACK_SIZE ];// Matrix stack for push/pop
1068
1068
int stackCounter ; // Matrix stack counter
1069
1069
1070
+ unsigned int currentTextureId ; // Current texture id to be used on glBegin
1070
1071
unsigned int defaultTextureId ; // Default texture used on shapes/poly drawing (required by shader)
1071
1072
unsigned int activeTextureId [RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS ]; // Active texture ids to be enabled on batch drawing (0 active by default)
1072
1073
unsigned int defaultVShaderId ; // Default vertex shader id (used by default shader program)
@@ -1485,8 +1486,8 @@ void rlBegin(int mode)
1485
1486
if (RLGL .currentBatch -> drawCounter >= RL_DEFAULT_BATCH_DRAWCALLS ) rlDrawRenderBatch (RLGL .currentBatch );
1486
1487
1487
1488
RLGL .currentBatch -> draws [RLGL .currentBatch -> drawCounter - 1 ].mode = mode ;
1488
- RLGL .currentBatch -> draws [RLGL .currentBatch -> drawCounter - 1 ].vertexCount = 0 ;
1489
- RLGL .currentBatch -> draws [ RLGL . currentBatch -> drawCounter - 1 ]. textureId = RLGL .State .defaultTextureId ;
1489
+ RLGL .currentBatch -> draws [RLGL .currentBatch -> drawCounter - 1 ].textureId = RLGL . State . currentTextureId ;
1490
+ RLGL .State . currentTextureId = RLGL .State .defaultTextureId ;
1490
1491
}
1491
1492
}
1492
1493
@@ -1651,13 +1652,15 @@ void rlSetTexture(unsigned int id)
1651
1652
{
1652
1653
rlDrawRenderBatch (RLGL .currentBatch );
1653
1654
}
1655
+ RLGL .State .currentTextureId = RLGL .State .defaultTextureId ;
1654
1656
#endif
1655
1657
}
1656
1658
else
1657
1659
{
1658
1660
#if defined(GRAPHICS_API_OPENGL_11 )
1659
1661
rlEnableTexture (id );
1660
1662
#else
1663
+ RLGL .State .currentTextureId = id ;
1661
1664
if (RLGL .currentBatch -> draws [RLGL .currentBatch -> drawCounter - 1 ].textureId != id )
1662
1665
{
1663
1666
if (RLGL .currentBatch -> draws [RLGL .currentBatch -> drawCounter - 1 ].vertexCount > 0 )
@@ -1676,6 +1679,9 @@ void rlSetTexture(unsigned int id)
1676
1679
RLGL .State .vertexCounter += RLGL .currentBatch -> draws [RLGL .currentBatch -> drawCounter - 1 ].vertexAlignment ;
1677
1680
1678
1681
RLGL .currentBatch -> drawCounter ++ ;
1682
+
1683
+ RLGL .currentBatch -> draws [RLGL .currentBatch -> drawCounter - 1 ].mode = RLGL .currentBatch -> draws [RLGL .currentBatch -> drawCounter - 2 ].mode ;
1684
+
1679
1685
}
1680
1686
}
1681
1687
@@ -2257,6 +2263,7 @@ void rlglInit(int width, int height)
2257
2263
// Init default white texture
2258
2264
unsigned char pixels [4 ] = { 255 , 255 , 255 , 255 }; // 1 pixel RGBA (4 bytes)
2259
2265
RLGL .State .defaultTextureId = rlLoadTexture (pixels , 1 , 1 , RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 , 1 );
2266
+ RLGL .State .currentTextureId = RLGL .State .defaultTextureId ;
2260
2267
2261
2268
if (RLGL .State .defaultTextureId != 0 ) TRACELOG (RL_LOG_INFO , "TEXTURE: [ID %i] Default texture loaded successfully" , RLGL .State .defaultTextureId );
2262
2269
else TRACELOG (RL_LOG_WARNING , "TEXTURE: Failed to load default texture" );
0 commit comments