Exemple #1
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();
        }
Exemple #2
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();
        }
Exemple #3
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();
        }