public static GLShader FromSource(ShaderType shaderType, string source) { if (!shaderType.IsDefined()) { throw new ArgumentOutOfRangeException("shaderType", shaderType, "The specified shader type was not a defined OpenTK.Graphics.OpenGL.ShaderType value."); } if (source == null) { throw new ArgumentNullException("source"); } int id = GL.CreateShader(shaderType); GL.ShaderSource(id, source); GL.CompileShader(id); int compileResult; GL.GetShader(id, ShaderParameter.CompileStatus, out compileResult); if (compileResult != 1) { string infoLog = GL.GetShaderInfoLog(id); GL.DeleteShader(id); throw new ArgumentException(String.Format("The GLSL shader of type {0} failed to compile. The info log is:\n{1}", shaderType, infoLog), "source"); } return(new GLShader(id, shaderType, source)); }
public static glShader fromSource(ShaderType type, string source) { if (!type.IsDefined()) { throw new ArgumentOutOfRangeException("type", type, "The specified shader type was not a defined ShaderType value."); } if (source == null) { throw new ArgumentNullException("source"); } var id = GL.CreateShader(type); GL.ShaderSource(id, source); GL.CompileShader(id); int result; GL.GetShader(id, ShaderParameter.CompileStatus, out result); if (result != 1) { var log = GL.GetShaderInfoLog(id); GL.DeleteShader(id); throw new ArgumentException(String.Format("The GLSL shader of type {0} failed to compile. The info log is:\n{1}", type, log), "source"); } return(new glShader(id, type, source)); }
public GLShader this[ShaderType shaderType] { get { if (!shaderType.IsDefined()) { throw new ArgumentOutOfRangeException("shaderType", shaderType, "The specified shader type was not a defined OpenTK.Graphics.OpenGL.ShaderType value."); } return(attachedShaders.FirstOrDefault(shader => shader.Type == shaderType)); } }
public static GLShader FromSource(ShaderType shaderType, string source) { if (!shaderType.IsDefined()) { throw new ArgumentOutOfRangeException("shaderType", shaderType, "The specified shader type was not a defined OpenTK.Graphics.OpenGL.ShaderType value."); } if (source == null) { throw new ArgumentNullException("source"); } int id = GL.CreateShader(shaderType); GL.ShaderSource(id, source); GL.CompileShader(id); int compileResult; GL.GetShader(id, ShaderParameter.CompileStatus, out compileResult); if (compileResult != 1) { string infoLog = GL.GetShaderInfoLog(id); GL.DeleteShader(id); throw new ArgumentException(String.Format("The GLSL shader of type {0} failed to compile. The info log is:\n{1}", shaderType, infoLog), "source"); } return new GLShader(id, shaderType, source); }