25 using SiliconStudio.Core;
27 namespace SiliconStudio.
Paradox.Graphics
69 var vertices = geometryMesh.Vertices;
70 var indices = geometryMesh.Indices;
73 ReverseWinding(vertices, indices);
75 if (indices.Length < 0xFFFF)
77 var indicesShort =
new ushort[indices.Length];
78 for (
int i = 0; i < indicesShort.Length; i++)
80 indicesShort[i] = (ushort)indices[i];
82 IndexBuffer = Buffer.Index.New(graphicsDevice, indicesShort).RecreateWith(indicesShort).DisposeBy(
this);
88 throw new InvalidOperationException(
"Cannot generate more than 65535 indices on feature level HW <= 9.3");
91 IndexBuffer = Buffer.Index.New(graphicsDevice, indices).RecreateWith(indices).DisposeBy(
this);
97 VertexBuffer = Buffer.Vertex.New(graphicsDevice, vertices).RecreateWith(vertices).DisposeBy(
this);
117 graphicsDevice.SetVertexArrayObject(vertexArrayObject);
120 graphicsDevice.DrawIndexed(PrimitiveType.TriangleList, IndexBuffer.ElementCount);
129 private void ReverseWinding<TIndex>(T[] vertices, TIndex[] indices)
131 for (
int i = 0; i < indices.Length; i += 3)
133 Utilities.Swap(ref indices[i], ref indices[i + 2]);
136 for (
int i = 0; i < vertices.Length; i++)
138 vertices[i].FlipWinding();
146 public partial class GeometricPrimitive : GeometricPrimitive<VertexPositionNormalTexture>
readonly GraphicsDevice GraphicsDevice
The default graphics device.
void Draw(GraphicsDevice graphicsDevice)
Draws this GeometricPrimitive.
A geometric primitive. Use Cube, Cylinder, GeoSphere, Plane, Sphere, Teapot, Torus. See Draw+vertices to learn how to use it.
readonly bool IsIndex32Bits
True if the index buffer is a 32 bit index buffer.
Base class for a framework component.
All-in-One Buffer class linked SharpDX.Direct3D11.Buffer.
Performs primitive-based rendering, creates resources, handles system-level variables, adjusts gamma ramp levels, and creates shaders. See The+GraphicsDevice+class to learn more about the class.
readonly Buffer VertexBuffer
The vertex buffer used by this geometric primitive.
GeometricPrimitive(GraphicsDevice graphicsDevice, GeometricMeshData< T > geometryMesh)
Initializes a new instance of the GeometricPrimitive{T} class.
GraphicsDeviceFeatures Features
Gets the features supported by this graphics device.
bool IsLeftHanded
Gets or sets a value indicating whether this instance is left handed.
readonly Buffer IndexBuffer
The index buffer used by this geometric primitive.
void Draw()
Draws this GeometricPrimitive.
GraphicsProfile
Identifies the set of supported devices for the demo based on device capabilities.
The base interface for all the vertex data structure.
GeometricPrimitive(GraphicsDevice graphicsDevice, GeometricMeshData< VertexPositionNormalTexture > geometryMesh)
Binding structure that specifies a vertex buffer and other per-vertex parameters (such as offset and ...
GraphicsProfile Profile
Features level of the current device.