Пример #1
0
        public void Create(string vertexPath, string fragmentPath)
        {
            if (_handle >= 0)
            {
                throw new InvalidOperationException("Shader is already loaded");
            }

            var vertexShader   = CreateShader(vertexPath, ShaderType.VertexShader);
            var fragmentShader = CreateShader(fragmentPath, ShaderType.FragmentShader);

            _handle = GL.CreateProgram();
            GL.AttachShader(_handle, vertexShader);
            GL.AttachShader(_handle, fragmentShader);

            GL.LinkProgram(_handle);

            GL.DetachShader(_handle, vertexShader);
            GL.DetachShader(_handle, fragmentShader);
            GL.DeleteShader(vertexShader);
            GL.DeleteShader(fragmentShader);
        }