Standby() public method

在使用VertexArrayObject后,此方法只会执行一次。 This method will only be invoked once when using VertexArrayObject.
public Standby ( ShaderProgram shaderProgram ) : void
shaderProgram ShaderProgram
return void
        /// <summary>
        /// VAO是用来管理VBO的。可以进一步减少DrawCall。
        /// <para>VAO is used to reduce draw-call.</para>
        /// </summary>
        /// <param name="drawCommand">index buffer pointer that used to invoke draw command.</param>
        /// <param name="shaderProgram">shader program that <paramref name="vertexAttributes"/> bind to.</param>
        /// <param name="vertexAttributes">给出此VAO要管理的所有VBO。<para>All VBOs that are managed by this VAO.</para></param>
        public VertexArrayObject(IDrawCommand drawCommand, ShaderProgram shaderProgram, params VertexShaderAttribute[] vertexAttributes)
        {
            if (drawCommand == null)
            {
                throw new ArgumentNullException("drawCommand");
            }
            // Zero vertex attribute is allowed in GLSL.
            //if (vertexAttributeBuffers == null || vertexAttributeBuffers.Length == 0)
            //{
            //    throw new ArgumentNullException("vertexAttributeBuffers");
            //}

            this.DrawCommand      = drawCommand;
            this.VertexAttributes = vertexAttributes;

            glGenVertexArrays(1, ids);

            glBindVertexArray(this.Id); // this vertex array object will record all stand-by actions.

            foreach (var item in vertexAttributes)
            {
                VertexBuffer buffer = item.Buffer;
                buffer.Standby(shaderProgram, item.VarNameInVertexShader);
            }

            glBindVertexArray(0); // this vertex array object has recorded all stand-by actions.
        }