/// <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(); }
/// <summary> /// /// </summary> /// <param name="indexAccessMode">index buffer is accessable randomly or only by frame.</param> /// <param name="transformFeedbackObj"></param> public void Render(IndexAccessMode indexAccessMode, TransformFeedbackObject transformFeedbackObj) { ShaderProgram program = this.Program; GLSwitchList switchList = this.SwitchList; // 绑定shader program.Bind(); program.PushUniforms(); // push new uniform values to GPU side. switchList.On(); if (transformFeedbackObj != null) { transformFeedbackObj.Bind(); foreach (var vao in this.VertexArrayObjects) { transformFeedbackObj.Begin(vao.DrawCommand.Mode); vao.Draw(indexAccessMode); transformFeedbackObj.End(); } transformFeedbackObj.Unbind(); } else { foreach (var vao in this.VertexArrayObjects) { vao.Draw(indexAccessMode); } } switchList.Off(); // 解绑shader program.Unbind(); }