protected int LocateUniform(string uniformName, bool softFail = true)
        {
            int location = 0;

            if (UniformLocations.TryGetValue(uniformName, out location))
            {
                return(location);
            }

            location = GL.GetUniformLocation(Handle, uniformName);
            if (location == -1)
            {
                if (softFail)
                {
                    LogWarn($"Could not locate {uniformName}");
                }
                else
                {
                    throw new InvalidOperationException($"ShaderProgram.LocateUniform ({Name}): Could not locate {uniformName}");
                }
            }

            UniformLocations.Add(uniformName, location);

            return(location);
        }
Exemple #2
0
 private int GetUniformLocation(string name)
 {
     if (!UniformLocations.TryGetValue(name, out int location))
     {
         location = GL.GetUniformLocation(Handle, name);
         UniformLocations.Add(name, location);
     }
     return(location);
 }