Example #1
0
 /// <summary>
 /// Create a Geometry object.
 /// </summary>
 /// <param name="device">The graphics device to create the geometry on.</param>
 /// <param name="primitiveType">The type of primitive used to draw the geometry.</param>
 /// <param name="vertices">The vertices of the geometry.</param>
 public Geometry(GraphicsDevice device, PrimitiveType primitiveType, IVertices vertices)
 {
     XiHelper.ArgumentNullCheck(device, vertices);
     this.device = device;
     this.primitiveType = primitiveType;
     vertexSize = vertices.VertexSize;
     vertexCount = vertices.Length;
     vertexBuffer = new VertexBuffer(device, vertices.Length * vertices.VertexSize, BufferUsage.None);
     vertices.SetDataOfVertexBuffer(vertexBuffer);
     primitiveCount = primitiveType.GetPrimitiveCount(vertices.Length);
     vertexDeclaration = new ManagedVertexDeclaration(device, vertices.VertexElements);
 }
Example #2
0
 /// <summary>
 /// Create a Geometry object.
 /// </summary>
 /// <param name="device">The graphics device that the geometry will be created on.</param>
 /// <param name="vertexElements">The vertex elements that define the vertices that make up the geometry.</param>
 /// <param name="primitiveType">The type of primitive used to draw the geometry.</param>
 /// <param name="vertexBuffer">The vertex buffer that holds the geometry's vertices.</param>
 /// <param name="vertexSize">The size of each vertex in bytes.</param>
 /// <param name="vertexCount">The number of vertices in the vertex buffer.</param>
 public Geometry(
     GraphicsDevice device,
     VertexElement[] vertexElements,
     PrimitiveType primitiveType,
     VertexBuffer vertexBuffer,
     int vertexSize,
     int vertexCount)
 {
     XiHelper.ArgumentNullCheck(device, vertexElements, vertexBuffer);
     this.device = device;
     this.vertexBuffer = vertexBuffer;
     this.vertexSize = vertexSize;
     this.vertexCount = vertexCount;
     this.primitiveType = primitiveType;
     primitiveCount = primitiveType.GetPrimitiveCount(vertexCount);
     vertexDeclaration = new ManagedVertexDeclaration(device, vertexElements);
 }