コード例 #1
0
        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);
        }
コード例 #2
0
        private Shader(ShaderStrings shaderPaths)
        {
            ShaderStrings shaderSources = ReadShaders(shaderPaths);

            ShaderInts shaders = CompileShaders(shaderSources);

            _handle = CreateProgram(shaders);
        }
コード例 #3
0
        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);
        }