Skip to content

Commit

Permalink
Fix rlSetUniformSampler
Browse files Browse the repository at this point in the history
Fix rlSetUniformSampler not setting sampler uniform if the same texture was already passed to a different sampler uniform
  • Loading branch information
veins1 authored Jan 24, 2024
1 parent 40f3df5 commit 0cc8a31
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/rlgl.h
Original file line number Diff line number Diff line change
Expand Up @@ -4135,7 +4135,14 @@ void rlSetUniformSampler(int locIndex, unsigned int textureId)
{
#if defined(GRAPHICS_API_OPENGL_33) || defined(GRAPHICS_API_OPENGL_ES2)
// Check if texture is already active
for (int i = 0; i < RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS; i++) if (RLGL.State.activeTextureId[i] == textureId) return;
for (int i = 0; i < RL_DEFAULT_BATCH_MAX_TEXTURE_UNITS; i++)
{
if (RLGL.State.activeTextureId[i] == textureId)
{
glUniform1i(locIndex, 1 + i);
return;
}
}

// Register a new active texture for the internal batch system
// NOTE: Default texture is always activated as GL_TEXTURE0
Expand Down

0 comments on commit 0cc8a31

Please sign in to comment.