Esempio n. 1
0
        /// <summary>
        ///     Loads the shader to the GPU.
        /// </summary>
        public void Load()
        {
            _id      = GL.CreateProgram();
            Uniforms = new UniformCollection {
                ParentShader = this
            };

            ErrorInShader = !ShaderFiles.Append(this);
            if (ErrorInShader)
            {
                GL.DeleteProgram(_id);
                return;
            }
            GL.LinkProgram(_id);
            ShaderFiles.Detach(this);

            Uniforms.Import(this);

            GLDebugging.CheckGLErrors($"A error occured at shader creation for '{GetType()}': %code%");
        }
        /// <summary>
        ///     Removes the files form the shader.
        /// </summary>
        /// <param name="shader"></param>
        internal void Detach(GenericShader shader)
        {
            foreach (ShaderFile file in Vertex)
            {
                GL.DetachShader(shader, file);
            }

            if (Geometry != null)
            {
                foreach (ShaderFile file in Geometry)
                {
                    GL.DetachShader(shader, file);
                }
            }

            foreach (ShaderFile file in Fragment)
            {
                GL.DetachShader(shader, file);
            }

            GLDebugging.CheckGLErrors($"Error at detaching '{shader.GetType()}': %code%");
        }