示例#1
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();
        }
示例#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();
        }
示例#3
0
 /// <summary>
 /// A smallest unit that can render somthing.
 /// </summary>
 /// <param name="program"></param>
 /// <param name="vao"></param>
 /// <param name="states"></param>
 public RenderMethod(ShaderProgram program, VertexArrayObject vao, params GLState[] states)
 {
     this.Program           = program;
     this.VertexArrayObject = vao;
     this.StateList         = new GLStateList();
     this.StateList.AddRange(states);
 }
示例#4
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();
        }
示例#5
0
        /// <summary>
        ///
        /// </summary>
        /// <param name="program"></param>
        /// <param name="vaos"></param>
        /// <param name="stateList"></param>
        public void Draw(ShaderProgram program, VertexArrayObject[] vaos, GLStateList stateList = null)
        {
            // 绑定shader
            program.Bind();
            program.PushUniforms(); // push new uniform values to GPU side.

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

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

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

            // 解绑shader
            program.Unbind();
        }
示例#6
0
 /// <summary>
 /// A smallest unit that can render somthing.
 /// </summary>
 /// <param name="program"></param>
 /// <param name="vao"></param>
 /// <param name="positionBuffer"></param>
 /// <param name="states"></param>
 public IPickableRenderUnit(ShaderProgram program, VertexArrayObject vao, VertexBuffer positionBuffer, params GLState[] states)
 {
     this.Program           = program;
     this.VertexArrayObject = vao;
     this.PositionBuffer    = positionBuffer;
     this.StateList         = new GLStateList();
     this.StateList.AddRange(states);
 }