VertexElement Structure (Microsoft.DirectX.Direct3D)
How Do I...?
- Create a Vertex Declaration
Defines input vertex data to the pipeline.
Definition
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.
Members Table
The following table lists the members exposed by the object.
Fields
Field Description VertexDeclarationEnd Retrieves a VertexElement structure that is considered to be the end of vertex shader declaration. Methods
Method Description ToString Obtains a string representation of the current instance. VertexElement Initializes a new instance of the VertexElement class. Properties
Property Description DeclarationMethod Retrieves or sets the tessellator processing method. DeclarationType Retrieves or sets the data type that defines the data size for the vertex element. DeclarationUsage Retrieves or sets one or more usage values that define the intended use of the vertex data. Offset Retrieves or sets the offset (if any) from the beginning of the stream to the beginning of the vertex data. Stream Retrieves or sets the stream number (or index) to use. UsageIndex Modifies the usage data to allow the user to specify multiple usage types.
How Do I...?
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);
Structure Information
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