VertexElement Structure |
Language: |
Defines input vertex data to the pipeline.
Visual Basic Public Structure VertexElement C# public struct VertexElement C++ public value class VertexElement sealed JScript In JScript, you can use structures, but you cannot define your own.
Create a Vertex Declaration
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.
Note: The offset parameter of each element is the cumulative offset of the elements from the start of the declaration. For example, the second element is offset 12 bytes, since it is three floats of four bytes each, or (3 * sizeof(float) = 12).// 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);
Namespace Microsoft.DirectX.Direct3D Assembly Microsoft.DirectX.Direct3D (microsoft.directx.direct3d.dll) Strong Name Microsoft.DirectX.Direct3D, Version=1.0.900.0, Culture=neutral, PublicKeyToken=d3231b57b74a1492
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