public void AddSource(string path, ShaderType type) { ShaderCompilation comp = Compilations.FirstOrDefault(c => c.Type == type); if (comp == null) { Compilations.Add(comp = new ShaderCompilation { Type = type }); } comp.Sources.Add(new ShaderSource { Path = path, Compilation = comp, }); comp.SetOrdinals(); }
private static void CompileShader(ShaderCompilation comp) { var shader = comp.Handle; // Try to compile the shader GL.CompileShader(shader); // Check for compilation errors GL.GetShader(shader, ShaderParameter.CompileStatus, out var code); if (code != (int)All.True) { // We can use `GL.GetShaderInfoLog(shader)` to get information about the error. var msg = GL.GetShaderInfoLog(shader); Console.WriteLine(msg); File.WriteAllText(Path.Combine(AssetManager.GlobalCacheDir, "error.glsl"), comp.AllSources()); throw new Exception($"Error occurred whilst compiling Shader({shader}): {msg}"); } ObjectManager.SetLabel(comp); }