Create a Vertex Declaration |
Language: |
This example demonstrates how to create a vertex declaration.
[C#]As shown in the following C# code example, first declare a VertexElement array to hold the vertex shader declaration. The declaration array must end with VertexElement.VertexDeclarationEnd as the last element (the size of the vertex element array will be one more than the number of actual vertex elements).
Create a VertexDeclaration instance using the Device and VertexElement array previously created.
// Create the vertex element array. VertexElement[] elements = new VertexElement[] { new VertexElement(0, 0, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Position, 0), new VertexElement(0, 12, DeclarationType.Float3, DeclarationMethod.Default, DeclarationUsage.Normal, 0), new VertexElement(0, 24, DeclarationType.Float2, DeclarationMethod.Default, DeclarationUsage.TextureCoordinate, 0), VertexElement.VertexDeclarationEnd }; // Use the vertex element array to create a vertex declaration. VertexDeclaration decl = new VertexDeclaration(device, elements);
Send comments about this topic to Microsoft. © Microsoft Corporation. All rights reserved.
Feedback? Please provide us with your comments on this topic.
For more help, visit the DirectX Developer Center