/// <summary> /// Compiles a FragmentShader from a string. /// </summary> /// <param name="graphics">A handle to the GraphicsContext.</param> /// <param name="source">The source of the shader.</param> /// <returns></returns> public static FragmentShader Compile(GraphicsContext graphics, string source) { if (source == null) throw new ArgumentNullException("source"); FragmentShader shader = new FragmentShader(graphics); Shader.Compile<FragmentShader>(shader, source); return shader; }
public ShaderProgram(GraphicsContext graphics, VertexShader vertexShader, FragmentShader fragmentShader) : base(graphics) { if (vertexShader == null) throw new ArgumentNullException("vertexShader"); if (fragmentShader == null) throw new ArgumentNullException("fragmentShader"); this.Handle = this.Graphics.GL.CreateProgram(); this.vertexShader = vertexShader; this.Graphics.GL.AttachShader(this.Handle, this.vertexShader.Handle); this.fragmentShader = fragmentShader; this.Graphics.GL.AttachShader(this.Handle, this.fragmentShader.Handle); this.Graphics.GL.LinkProgram(this.Handle); this.uniformLocations = new Dictionary<string, int>(); }