/// <summary> /// OGL2 does not support VAOs, and instead must bind the VBOs to their attributes manually. /// </summary> private void DrawOGL2() { if (VertexCount == 0) { return; } BindAttributes(Program); Gl.DrawElements(DrawMode, VertexCount, DrawElementsType.UnsignedInt, IntPtr.Zero); }
/// <summary> /// OGL2 does not support VAOs, and instead must bind the VBOs to their attributes manually. /// </summary> private void DrawOGL2() { if (VertexCount == 0) { return; } BindAttributes(Program); Gl.DrawElements(DrawMode, VertexCount, elementType, offsetInBytes); }
/// <summary> /// Draw the elements indices. /// </summary> /// <param name="ctx"> /// The <see cref="GraphicsContext"/> used for drawing. /// </param> protected virtual void DrawElements(GraphicsContext ctx, IntPtr pointer) { uint count = (ElementCount == 0) ? ArrayIndices.ItemCount : ElementCount; Debug.Assert(count - ElementOffset <= ArrayIndices.ItemCount, "element indices array out of bounds"); // Draw elements as usual Gl.DrawElements(ElementsMode, (int)count, ArrayIndices.ElementsType, pointer); }
/// <summary> /// OGL3 method uses a vertex array object for quickly binding the VBOs to their attributes. /// </summary> private void DrawOGL3() { if (vaoID == 0 || VertexCount == 0) { return; } Gl.BindVertexArray(vaoID); Gl.DrawElements(DrawMode, VertexCount, DrawElementsType.UnsignedInt, IntPtr.Zero); Gl.BindVertexArray(0); }
/// <summary> /// OGL3 method uses a vertex array object for quickly binding the VBOs to their attributes. /// </summary> private void DrawOGL3() { if (ID == 0 || VertexCount == 0) { return; } Gl.BindVertexArray(ID); Gl.DrawElements(DrawMode, VertexCount, elementType, offsetInBytes); Gl.BindVertexArray(0); }
/// <summary> /// Draw the elements. /// </summary> /// <param name="ctx"> /// The <see cref="GraphicsContext"/> used for drawing. /// </param> public override void Draw(GraphicsContext ctx) { if (ctx == null) { throw new ArgumentNullException("ctx"); } if (ctx.IsCurrent == false) { throw new ArgumentException("not current", "ctx"); } ArrayBufferObjectBase.IArraySection arraySection = ArrayIndices.GetArraySection(0); Debug.Assert(arraySection != null); // Element array must be (re)bound ArrayIndices.Bind(ctx); // Enable restart primitive? if (ArrayIndices.RestartIndexEnabled) { Debug.Assert(ElementCount != 0, "specified ElementCount but primitive restart enabled"); if (PrimitiveRestart.IsPrimitiveRestartSupported(ctx)) { // Enable primitive restart PrimitiveRestart.EnablePrimitiveRestart(ctx, ArrayIndices.ElementsType); // Draw elements as usual Gl.DrawElements(ElementsMode, (int)ElementCount, ArrayIndices.ElementsType, arraySection.Pointer); // Disable primitive restart PrimitiveRestart.DisablePrimitiveRestart(ctx); } else { // Note: uses MultiDrawElements to emulate the primitive restart feature; PrimitiveRestartOffsets and // PrimitiveRestartCounts are computed at element buffer creation time Gl.MultiDrawElements(ElementsMode, ArrayIndices.PrimitiveRestartOffsets, ArrayIndices.ElementsType, ArrayIndices.PrimitiveRestartCounts, ArrayIndices.PrimitiveRestartOffsets.Length); } } else { uint count = (ElementCount == 0) ? ArrayIndices.ItemCount : ElementCount; Debug.Assert(count - ElementOffset <= ArrayIndices.ItemCount, "element indices array out of bounds"); // Draw vertex arrays by indices Gl.DrawElements(ElementsMode, (int)count, ArrayIndices.ElementsType, arraySection.Pointer); } }
/// <summary> /// Performs the draw routine with a custom shader program. /// </summary> /// <param name="program"></param> public void DrawProgram(ShaderProgram program) { BindAttributes(program); Gl.DrawElements(DrawMode, VertexCount, DrawElementsType.UnsignedInt, IntPtr.Zero); }
/// <summary> /// OGL2 does not support VAOs, and instead must bind the VBOs to their attributes manually. /// </summary> private void DrawOGL2() { BindAttributes(this.Program); Gl.DrawElements(DrawMode, VertexCount, DrawElementsType.UnsignedInt, IntPtr.Zero); }
/// <summary> /// Performs the draw routine with a custom shader program. /// </summary> /// <param name="program"></param> public void DrawProgram(ShaderProgram program) { BindAttributes(program); Gl.DrawElements(DrawMode, VertexCount, elementType, offsetInBytes); }