예제 #1
0
            /// <summary>
            /// Create a shader object from this Object.
            /// </summary>
            /// <returns></returns>
            public ShaderObject Create()
            {
                ShaderObject shaderObject = new ShaderObject(Stage);

                // Load source
                shaderObject.LoadSource(Path);

                return(shaderObject);
            }
예제 #2
0
            /// <summary>
            /// Create a program from this Program.
            /// </summary>
            /// <param name="cctx"></param>
            /// <returns></returns>
            public ShaderProgram Create(ShaderCompilerContext cctx)
            {
                if (String.IsNullOrEmpty(Id))
                {
                    throw new InvalidOperationException("invalid program identifier");
                }
                if (cctx == null)
                {
                    throw new ArgumentNullException("cctx");
                }

                ShaderProgram shaderProgram = new ShaderProgram(Id);

                // Attach required objects
                foreach (Object shaderProgramObject in Objects)
                {
                    ShaderObject shaderObject = new ShaderObject(shaderProgramObject.Stage);

                    // Load source
                    shaderObject.LoadSource(shaderProgramObject.Path);
                    // Attach object
                    shaderProgram.AttachShader(shaderObject);
                }

                // Register attributes semantic
                foreach (Attribute attribute in Attributes)
                {
                    shaderProgram.SetAttributeSemantic(attribute.Name, attribute.Semantic);
                    if (attribute.Location >= 0)
                    {
                        shaderProgram.SetAttributeLocation(attribute.Name, attribute.Location);
                    }
                }

                // Register uniforms semantic
                foreach (Uniform uniform in Uniforms)
                {
                    shaderProgram.SetUniformSemantic(uniform.Name, uniform.Semantic);
                }

                shaderProgram.Create(cctx);

                return(shaderProgram);
            }