/// <summary> /// Copy this array buffer object to another one, but having a different array item type. /// </summary> /// <param name="vertexArrayType"> /// A <see cref="ArrayBufferItemType"/> that specify the returned <see cref="ArrayBufferObject"/> item type. /// </param> /// <returns> /// It returns a copy of this ArrayBufferObject, but having a different array item. The returned instance is actually /// a <see cref="ArrayBufferObject"/>. /// </returns> /// <exception cref="ArgumentException"> /// Exception thrown if the array base type of this ArrayBufferObject (<see cref="ArrayBaseType"/>) is different to the one /// derived from <paramref name="vertexArrayType"/>. /// </exception> /// <exception cref="InvalidOperationException"> /// Exception thrown if the number of base components of this ArrayBufferObject cannot be mapped into the base components /// count derived from <paramref name="vertexArrayType"/>. /// </exception> public ArrayBufferObject ConvertItemType(ArrayBufferItemType vertexArrayType) { if (ArrayBufferItem.GetArrayBaseType(_ArrayType) != ArrayBufferItem.GetArrayBaseType(vertexArrayType)) { throw new ArgumentException("base type mismatch", "vertexArrayType"); } uint componentsCount = ItemCount * ArrayBufferItem.GetArrayLength(ArrayType) * ArrayBufferItem.GetArrayRank(ArrayType); uint convComponentsCount = ArrayBufferItem.GetArrayLength(vertexArrayType) * ArrayBufferItem.GetArrayRank(vertexArrayType); Debug.Assert(componentsCount >= convComponentsCount); if ((componentsCount % convComponentsCount) != 0) { throw new InvalidOperationException("components length incompatibility"); } ArrayBufferObject arrayObject = CreateArrayObject(vertexArrayType, Hint); // Different item count due different lengths arrayObject.Create(componentsCount / convComponentsCount); // Memory is copied Memory.MemoryCopy(arrayObject.ClientBufferAddress, ClientBufferAddress, ClientBufferSize); return(arrayObject); }
private void DrawLines2f_GL_3_2(Vertex2f[] vertices) { // Define geometry buffer _DrawArrayBuffer.Create(this, vertices); // Define geometry arrays _VertexArray.SetArray(_DrawArrayBuffer, VertexArraySemantic.Position); // Draw arrays _VertexArray.Draw(this, null); }