/// <summary> /// Draw the vertices in the bound buffer, using this buffer for the indices. /// </summary> /// <param name="buffer">Vertex buffer. Must be bound.</param> /// <param name="elements">Number of elements to draw</param> public void DrawIndexed(VertexArrayBuffer <T> buffer, int elements) { if (buffer == null) { throw new ArgumentNullException(nameof(buffer)); } if (elements <= 0) { throw new ArgumentOutOfRangeException(nameof(elements)); } Gl.DrawElements(buffer.Primitive, elements, DrawElementsType.UnsignedInt, null); }
/// <summary> /// Create a new vertex array object /// </summary> /// <param name="buffer">The buffer the metadata applies to. Does not need to be bound.</param> /// <param name="pipeline">The shader pipeline for the drawing operation.</param> /// <param name="attributes">Vertex attribute definitions</param> public VertexArrayObject(VertexArrayBuffer <T> buffer, ShaderPipeline pipeline, params VertexAttributeDescription[] attributes) { if (attributes == null || buffer == null || pipeline == null) { throw new ArgumentNullException(); } this.buffer = buffer; Handle = Gl.GenVertexArray(); Verify.VerifyResourceCreated(Handle); this.pipeline = pipeline; Bind(); buffer.Bind(); foreach (var attr in attributes) { SetAttribute(attr); } Unbind(); buffer.Unbind(); }