private static ShaderInts CompileShaders(ShaderStrings shaderSources) { ShaderInts shaders = new ShaderInts(); shaders.Vertex = CompileShader(shaderSources.Vertex, ShaderType.VertexShader); shaders.Fragment = CompileShader(shaderSources.Fragment, ShaderType.FragmentShader); return(shaders); }
private Shader(ShaderStrings shaderPaths) { ShaderStrings shaderSources = ReadShaders(shaderPaths); ShaderInts shaders = CompileShaders(shaderSources); _handle = CreateProgram(shaders); }
private static int CreateProgram(ShaderInts shaders) { var program = GL.CreateProgram(); GL.AttachShader(program, shaders.Vertex); GL.AttachShader(program, shaders.Fragment); GL.LinkProgram(program); //Clean up the shaders GL.DetachShader(program, shaders.Vertex); GL.DetachShader(program, shaders.Fragment); GL.DeleteShader(shaders.Vertex); GL.DeleteShader(shaders.Fragment); return(program); }