@@ -1067,6 +1067,7 @@ typedef struct rlglData {
10671067 Matrix stack [RL_MAX_MATRIX_STACK_SIZE ];// Matrix stack for push/pop
10681068 int stackCounter ; // Matrix stack counter
10691069
1070+ unsigned int currentTextureId ; // Current texture id to be used on glBegin
10701071 unsigned int defaultTextureId ; // Default texture used on shapes/poly drawing (required by shader)
10711072 unsigned int activeTextureId [RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS ]; // Active texture ids to be enabled on batch drawing (0 active by default)
10721073 unsigned int defaultVShaderId ; // Default vertex shader id (used by default shader program)
@@ -1483,7 +1484,8 @@ void rlBegin(int mode)
14831484 }
14841485
14851486 if (RLGL .currentBatch -> drawCounter >= RL_DEFAULT_BATCH_DRAWCALLS ) rlDrawRenderBatch (RLGL .currentBatch );
1486-
1487+ RLGL .currentBatch -> draws [RLGL .currentBatch -> drawCounter - 1 ].textureId = RLGL .State .currentTextureId ;
1488+ RLGL .State .currentTextureId = RLGL .State .defaultTextureId ;
14871489 RLGL .currentBatch -> draws [RLGL .currentBatch -> drawCounter - 1 ].mode = mode ;
14881490 }
14891491}
@@ -1656,6 +1658,7 @@ void rlSetTexture(unsigned int id)
16561658#if defined(GRAPHICS_API_OPENGL_11 )
16571659 rlEnableTexture (id );
16581660#else
1661+ RLGL .State .currentTextureId = id ;
16591662 if (RLGL .currentBatch -> draws [RLGL .currentBatch -> drawCounter - 1 ].textureId != id )
16601663 {
16611664 if (RLGL .currentBatch -> draws [RLGL .currentBatch -> drawCounter - 1 ].vertexCount > 0 )
@@ -2258,6 +2261,7 @@ void rlglInit(int width, int height)
22582261 // Init default white texture
22592262 unsigned char pixels [4 ] = { 255 , 255 , 255 , 255 }; // 1 pixel RGBA (4 bytes)
22602263 RLGL .State .defaultTextureId = rlLoadTexture (pixels , 1 , 1 , RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8 , 1 );
2264+ RLGL .State .currentTextureId = RLGL .State .defaultTextureId ;
22612265
22622266 if (RLGL .State .defaultTextureId != 0 ) TRACELOG (RL_LOG_INFO , "TEXTURE: [ID %i] Default texture loaded successfully" , RLGL .State .defaultTextureId );
22632267 else TRACELOG (RL_LOG_WARNING , "TEXTURE: Failed to load default texture" );
0 commit comments