Browse Source

Avoid trying to setup uniform for invalid locations

pull/2853/head
Ray 2 years ago
parent
commit
73234d2a28
1 changed files with 18 additions and 9 deletions
  1. +18
    -9
      src/rcore.c

+ 18
- 9
src/rcore.c View File

@ -2525,25 +2525,34 @@ void SetShaderValue(Shader shader, int locIndex, const void *value, int uniformT
// Set shader uniform value vector
void SetShaderValueV(Shader shader, int locIndex, const void *value, int uniformType, int count)
{
rlEnableShader(shader.id);
rlSetUniform(locIndex, value, uniformType, count);
//rlDisableShader(); // Avoid reseting current shader program, in case other uniforms are set
if (locIndex > -1)
{
rlEnableShader(shader.id);
rlSetUniform(locIndex, value, uniformType, count);
//rlDisableShader(); // Avoid reseting current shader program, in case other uniforms are set
}
}
// Set shader uniform value (matrix 4x4)
void SetShaderValueMatrix(Shader shader, int locIndex, Matrix mat)
{
rlEnableShader(shader.id);
rlSetUniformMatrix(locIndex, mat);
//rlDisableShader();
if (locIndex > -1)
{
rlEnableShader(shader.id);
rlSetUniformMatrix(locIndex, mat);
//rlDisableShader();
}
}
// Set shader uniform value for texture
void SetShaderValueTexture(Shader shader, int locIndex, Texture2D texture)
{
rlEnableShader(shader.id);
rlSetUniformSampler(locIndex, texture.id);
//rlDisableShader();
if (locIndex > -1)
{
rlEnableShader(shader.id);
rlSetUniformSampler(locIndex, texture.id);
//rlDisableShader();
}
}
// Get a ray trace from mouse position

||||||
x
 
000:0
Loading…
Cancel
Save