Skip to content

Commit da8a080

Browse files
committed
Added some comments on latest change
1 parent 27af359 commit da8a080

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

src/rlgl.h

+6-2
Original file line numberDiff line numberDiff line change
@@ -1459,7 +1459,9 @@ void rlBegin(int mode)
14591459
// NOTE: In all three cases, vertex are accumulated over default internal vertex buffer
14601460
if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode != mode)
14611461
{
1462+
// Get current binded texture to preserve it between draw modes change (QUADS <--> TRIANGLES)
14621463
int currentTexture = RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId;
1464+
14631465
if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount > 0)
14641466
{
14651467
// Make sure current RLGL.currentBatch->draws[i].vertexCount is aligned a multiple of 4,
@@ -1482,14 +1484,16 @@ void rlBegin(int mode)
14821484

14831485
RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode = mode;
14841486
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
14861488
}
14871489
}
14881490

14891491
// Finish vertex providing
14901492
void rlEnd(void)
14911493
{
1494+
// Reset texture to default
14921495
rlSetTexture(RLGL.State.defaultTextureId);
1496+
14931497
// NOTE: Depth increment is dependant on rlOrtho(): z-near and z-far values,
14941498
// as well as depth buffer bit-depth (16bit or 24bit or 32bit)
14951499
// Correct increment formula would be: depthInc = (zfar - znear)/pow(2, bits)
@@ -3057,7 +3061,7 @@ void rlDrawRenderBatch(rlRenderBatch *batch)
30573061

30583062
for (int i = 0, vertexOffset = 0; i < batch->drawCounter; i++)
30593063
{
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
30613065
glBindTexture(GL_TEXTURE_2D, batch->draws[i].textureId);
30623066

30633067
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

Comments
 (0)