/// <summary>
        ///
        /// </summary>
        /// <param name="program"></param>
        /// <param name="vaos"></param>
        /// <param name="switchList"></param>
        public void Draw(ShaderProgram program, VertexArrayObject[] vaos, GLSwitchList switchList = null)
        {
            // 绑定shader
            program.Bind();
            program.PushUniforms(); // push new uniform values to GPU side.

            if (switchList != null)
            {
                switchList.On();
            }

            this.Bind();
            foreach (var vao in vaos)
            {
                DrawMode mode = vao.DrawCommand.CurrentMode;
                this.Begin(mode);
                vao.Bind();
                this.Draw(mode);
                vao.Unbind();
                this.End();
            }
            this.Unbind();

            if (switchList != null)
            {
                switchList.Off();
            }

            // 解绑shader
            program.Unbind();
        }
Esempio n. 2
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="program"></param>
        /// <param name="vao"></param>
        /// <param name="stateList"></param>
        public void Draw(ShaderProgram program, VertexArrayObject vao, GLStateList stateList = null)
        {
            // 绑定shader
            program.Bind();
            program.PushUniforms(); // push new uniform values to GPU side.

            if (stateList != null)
            {
                stateList.On();
            }

            DrawMode mode = vao.IndexBuffer.Mode;

            this.Bind();
            this.Begin(mode);
            vao.Bind();
            this.Draw(mode);
            vao.Unbind();
            this.End();
            this.Unbind();

            if (stateList != null)
            {
                stateList.Off();
            }

            // 解绑shader
            program.Unbind();
        }
Esempio n. 3
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="controlMode">index buffer is accessable randomly or only by frame.</param>
        /// <param name="transformFeedbackObj"></param>
        public void Render(ControlMode controlMode, TransformFeedbackObject transformFeedbackObj)
        {
            ShaderProgram program   = this.Program;
            GLStateList   stateList = this.StateList;

            // 绑定shader
            program.Bind();
            program.PushUniforms(); // push new uniform values to GPU side.

            stateList.On();

            if (transformFeedbackObj != null)
            {
                transformFeedbackObj.Bind();
                foreach (var vao in this.VertexArrayObjects)
                {
                    transformFeedbackObj.Begin(vao.DrawCommand.Mode);
                    vao.Draw(controlMode);
                    transformFeedbackObj.End();
                }
                transformFeedbackObj.Unbind();
            }
            else
            {
                foreach (var vao in this.VertexArrayObjects)
                {
                    vao.Draw(controlMode);
                }
            }

            stateList.Off();

            // 解绑shader
            program.Unbind();
        }
Esempio n. 4
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="controlMode">index buffer is accessable randomly or only by frame.</param>
        /// <param name="transformFeedbackObj"></param>
        public void Render(IndexBuffer.ControlMode controlMode = IndexBuffer.ControlMode.ByFrame, TransformFeedbackObject transformFeedbackObj = null)
        {
            ShaderProgram program   = this.Program;
            GLStateList   stateList = this.StateList;

            // 绑定shader
            program.Bind();
            program.PushUniforms(); // push new uniform values to GPU side.

            stateList.On();

            if (transformFeedbackObj != null)
            {
                transformFeedbackObj.Bind();
                transformFeedbackObj.Begin(this.VertexArrayObject.IndexBuffer.Mode);
                this.VertexArrayObject.Draw(controlMode);
                transformFeedbackObj.End();
                transformFeedbackObj.Unbind();
            }
            else
            {
                this.VertexArrayObject.Draw(controlMode);
            }

            stateList.Off();

            // 解绑shader
            program.Unbind();
        }
Esempio n. 5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="transformFeedbackObj"></param>
        public void Render(TransformFeedbackObject transformFeedbackObj = null)
        {
            ShaderProgram program = this.Program;

            // 绑定shader
            program.Bind();
            program.PushUniforms();

            this.StateList.On();

            if (transformFeedbackObj != null)
            {
                transformFeedbackObj.Bind();
                transformFeedbackObj.Begin(this.VertexArrayObject.IndexBuffer.Mode);
            }
            this.VertexArrayObject.Draw();
            if (transformFeedbackObj != null)
            {
                transformFeedbackObj.End();
                transformFeedbackObj.Unbind();
            }

            this.StateList.Off();

            // 解绑shader
            program.Unbind();
        }