Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 9 additions & 2 deletions src/rlgl.h
Original file line number Diff line number Diff line change
Expand Up @@ -1067,6 +1067,7 @@ typedef struct rlglData {
Matrix stack[RL_MAX_MATRIX_STACK_SIZE];// Matrix stack for push/pop
int stackCounter; // Matrix stack counter

unsigned int currentTextureId; // Current texture id to be used on glBegin
unsigned int defaultTextureId; // Default texture used on shapes/poly drawing (required by shader)
unsigned int activeTextureId[RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS]; // Active texture ids to be enabled on batch drawing (0 active by default)
unsigned int defaultVShaderId; // Default vertex shader id (used by default shader program)
Expand Down Expand Up @@ -1485,8 +1486,8 @@ void rlBegin(int mode)
if (RLGL.currentBatch->drawCounter >= RL_DEFAULT_BATCH_DRAWCALLS) rlDrawRenderBatch(RLGL.currentBatch);

RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode = mode;
RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount = 0;
RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId = RLGL.State.defaultTextureId;
RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId = RLGL.State.currentTextureId;
RLGL.State.currentTextureId = RLGL.State.defaultTextureId;
}
}

Expand Down Expand Up @@ -1651,13 +1652,15 @@ void rlSetTexture(unsigned int id)
{
rlDrawRenderBatch(RLGL.currentBatch);
}
RLGL.State.currentTextureId = RLGL.State.defaultTextureId;
#endif
}
else
{
#if defined(GRAPHICS_API_OPENGL_11)
rlEnableTexture(id);
#else
RLGL.State.currentTextureId = id;
if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].textureId != id)
{
if (RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexCount > 0)
Expand All @@ -1676,6 +1679,9 @@ void rlSetTexture(unsigned int id)
RLGL.State.vertexCounter += RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].vertexAlignment;

RLGL.currentBatch->drawCounter++;

RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 1].mode = RLGL.currentBatch->draws[RLGL.currentBatch->drawCounter - 2].mode;

}
}

Expand Down Expand Up @@ -2257,6 +2263,7 @@ void rlglInit(int width, int height)
// Init default white texture
unsigned char pixels[4] = { 255, 255, 255, 255 }; // 1 pixel RGBA (4 bytes)
RLGL.State.defaultTextureId = rlLoadTexture(pixels, 1, 1, RL_PIXELFORMAT_UNCOMPRESSED_R8G8B8A8, 1);
RLGL.State.currentTextureId = RLGL.State.defaultTextureId;

if (RLGL.State.defaultTextureId != 0) TRACELOG(RL_LOG_INFO, "TEXTURE: [ID %i] Default texture loaded successfully", RLGL.State.defaultTextureId);
else TRACELOG(RL_LOG_WARNING, "TEXTURE: Failed to load default texture");
Expand Down
Loading