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

@ -2524,27 +2524,36 @@ 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)
{
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)
{
if (locIndex > -1)
{
rlEnableShader(shader.id);
rlSetUniformMatrix(locIndex, mat);
//rlDisableShader();
}
}
// Set shader uniform value for texture
void SetShaderValueTexture(Shader shader, int locIndex, Texture2D texture)
{
if (locIndex > -1)
{
rlEnableShader(shader.id);
rlSetUniformSampler(locIndex, texture.id);
//rlDisableShader();
}
}
// Get a ray trace from mouse position
Ray GetMouseRay(Vector2 mouse, Camera camera)