using System; using System.IO; using OpenTK.Graphics.OpenGL; namespace nhengine { public class Shader { private int id; private ShaderType shaderType; private String source; public Shader(ShaderType shaderType, String source) { this.id = GL.CreateShader(shaderType); this.shaderType = shaderType; this.source = source; compile(); } public int ID { get { return this.id; } } public Shader(ShaderType shaderType, FileStream file) { this.id = GL.CreateShader(shaderType); this.shaderType = shaderType; StreamReader sr = new StreamReader(file); this.source = sr.ReadToEnd(); compile(); } private void compile() { GL.ShaderSource(this.id, source); GL.CompileShader(this.id); string msg = GL.GetShaderInfoLog((int)this.id); Console.WriteLine("Supported Shader Version: {0}", GL.GetString(StringName.ShadingLanguageVersion)); Console.WriteLine("Shader Compiled: {0}", msg); } public ShaderType ShaderType { get { return this.shaderType; } } } }