summaryrefslogtreecommitdiffhomepage
diff options
context:
space:
mode:
authorRay <[email protected]>2023-01-03 17:44:06 +0100
committerRay <[email protected]>2023-01-03 17:44:06 +0100
commit73234d2a28166ca65cd10c01b0233a667e5290c1 (patch)
treeba0f5705607b6e17602b17a0b421faa3f4df5205
parent39f9045703268f0b844916b07643d3801d2212cf (diff)
downloadraylib-73234d2a28166ca65cd10c01b0233a667e5290c1.tar.gz
raylib-73234d2a28166ca65cd10c01b0233a667e5290c1.zip
Avoid trying to setup uniform for invalid locations
-rw-r--r--src/rcore.c27
1 files changed, 18 insertions, 9 deletions
diff --git a/src/rcore.c b/src/rcore.c
index 0e9aa76e..d1763294 100644
--- a/src/rcore.c
+++ b/src/rcore.c
@@ -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