Open
Description
Chapter2/6-MultipleLights sample are crash for me (I'm run it on Intel HD 4600 video, if it matters at all, doesn't sure, i'm completely newbie in OpenGL).
The issue is what Shader.cs fills _uniformLocations by using call GL.GetProgram(Handle, GetProgramParameterName.ActiveUniforms, out var numberOfUniforms);
. However this call doesn't report all locations.
I'm checked LearnOpenGL example, and it uses bit different way, so i'm put few changes:
diff --git a/Common/Shader.cs b/Common/Shader.cs
index 1ff74d2..3ec0c16 100644
--- a/Common/Shader.cs
+++ b/Common/Shader.cs
@@ -155,8 +155,9 @@ namespace LearnOpenTK.Common
/// <param name="data">The data to set</param>
public void SetFloat(string name, float data)
{
+ var uniformLocation = GL.GetUniformLocation(Handle, name);
GL.UseProgram(Handle);
- GL.Uniform1(_uniformLocations[name], data);
+ GL.Uniform1(uniformLocation, data);
}
/// <summary>
@@ -182,8 +183,9 @@ namespace LearnOpenTK.Common
/// <param name="data">The data to set</param>
public void SetVector3(string name, Vector3 data)
{
+ var uniformLocation = GL.GetUniformLocation(Handle, name);
GL.UseProgram(Handle);
- GL.Uniform3(_uniformLocations[name], data);
+ GL.Uniform3(uniformLocation, data);
}
}
}
And that's makes example to run. Surely, this requires more accurate fix.
Metadata
Metadata
Assignees
Labels
No labels