/// <summary> /// Returns an array of <see cref="Vertex"/> based on the <see cref="Point"/>s contained by the <see cref="IEnumerable{T}"/> /// </summary> /// <param name="extended">The extended <see cref="IEnumerable{T}"/> of <see cref="Point"/></param> /// <returns>An array of <see cref="Vertex"/> based on the <see cref="Point"/>s contained by the <see cref="IEnumerable{T}"/></returns> public static Vertex[] ToVertexArray(this IEnumerable<Point> extended) { Vertex[] vertices; vertices = new Vertex[extended.Count()]; for(int index = 0; index < vertices.Length; index++) { vertices[index] = extended.ElementAt(index); } return vertices; }
/// <summary> /// Replaces the <see cref="Vertex"/> at the specified index by the specified <see cref="Vertex"/> /// </summary> /// <param name="vertexIndex">The index of the vertex to replace</param> /// <param name="vertex">The <see cref="Vertex"/> used to replace the <see cref="Vertex"/> at the specified index</param> public void SetVertex(int vertexIndex, Vertex vertex) { //Updates the local vertex buffer this.Vertices[vertexIndex] = vertex; //Binds the VertexBufferObject GL.BindBuffer(BufferTarget.ArrayBuffer, this.VertexBufferObjectId); //Updates the VertexBufferObject GL.BufferSubData(BufferTarget.ArrayBuffer, new IntPtr(vertexIndex * Vertex.Stride), new IntPtr(Vertex.Stride), new Vertex[] { vertex }); //Unbinds the VertexBufferObject GL.BindBuffer(BufferTarget.ArrayBuffer, 0); }
/// <summary> /// Sets the array of <see cref="Vertex"/> associated with the <see cref="VertexBufferObject"/> /// </summary> /// <param name="vertices">The array of <see cref="Vertex"/> to upload to the <see cref="VertexBufferObject"/></param> public void SetVertices(Vertex[] vertices) { //Updates the local vertex buffer this.Vertices = vertices; //Binds the VertexBufferObject GL.BindBuffer(BufferTarget.ArrayBuffer, this.VertexBufferObjectId); //Updates the VertexBufferObject GL.BufferSubData(BufferTarget.ArrayBuffer, (IntPtr)0, new IntPtr(vertices.Length * Vertex.Stride), vertices); //Unbinds the VertexBufferObject GL.BindBuffer(BufferTarget.ArrayBuffer, 0); }