/// <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(); }
/// <summary> /// /// </summary> /// <param name="transformFeedbackObj"></param> public void Render(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(); transformFeedbackObj.End(); transformFeedbackObj.Unbind(); } else { this.VertexArrayObject.Draw(); } stateList.Off(); // 解绑shader program.Unbind(); }
/// <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(); }
/// <summary> /// /// </summary> /// <param name="index"></param> /// <param name="transformFeedbackObj"></param> public void Render(int index, TransformFeedbackObject transformFeedbackObj = null) { if (index < 0 || this.Methods.Length <= index) { throw new System.IndexOutOfRangeException(); } this.Methods[index].Render(transformFeedbackObj); }
/// <summary> /// /// </summary> /// <param name="transformFeedbackObj"></param> /// <param name="unit"></param> public static void Draw(this TransformFeedbackObject transformFeedbackObj, RenderUnit unit) { if (transformFeedbackObj == null || unit == null) { throw new ArgumentNullException(); } transformFeedbackObj.Draw(unit.Program, unit.VertexArrayObject, unit.StateList); }
/// <summary> /// /// </summary> /// <param name="transformFeedbackObj"></param> public void Render(TransformFeedbackObject transformFeedbackObj) { this.Render(ControlMode.ByFrame, transformFeedbackObj); }
/// <summary> /// /// </summary> /// <param name="transformFeedbackObj"></param> public void Render(TransformFeedbackObject transformFeedbackObj) { this.Render(IndexAccessMode.ByFrame, transformFeedbackObj); }