public static WebGLProgram InitializeShaders( this WebGLRenderingContextBase gl, string vertexShaderCode, string fragmentShaderCode) { var shaderProgram = gl.CreateProgram(); var vertexShader = GetShader(gl, vertexShaderCode, WebGLRenderingContextBase.VERTEX_SHADER); var fragmentShader = GetShader(gl, fragmentShaderCode, WebGLRenderingContextBase.FRAGMENT_SHADER); gl.AttachShader(shaderProgram, vertexShader); gl.AttachShader(shaderProgram, fragmentShader); gl.LinkProgram(shaderProgram); gl.UseProgram(shaderProgram); return(shaderProgram); }
protected WebGLProgram SetUpProgram( WebGLRenderingContextBase gl, string vertexShaderSource = "void main() {}", string fragmentShaderSource = "void main() {}") { var vertexShader = gl.CreateShader(WebGLRenderingContextBase.VERTEX_SHADER); gl.ShaderSource(vertexShader, vertexShaderSource); gl.CompileShader(vertexShader); var fragmentShader = gl.CreateShader(WebGLRenderingContextBase.FRAGMENT_SHADER); gl.ShaderSource(fragmentShader, fragmentShaderSource); gl.CompileShader(fragmentShader); var program = gl.CreateProgram(); gl.AttachShader(program, vertexShader); gl.AttachShader(program, fragmentShader); gl.LinkProgram(program); return(program); }