Avoid trying to setup uniform for invalid locations

This commit is contained in:
Ray 2023-01-03 17:44:06 +01:00
parent 39f9045703
commit 73234d2a28

View file

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