VertexElement.VertexDeclarationEnd Field

Language:

How Do I...?

Retrieves a VertexElement structure that is considered to be the end of vertex shader declaration.

Definition

Visual Basic Public Shared VertexDeclarationEnd As VertexElement
C# public static VertexElement VertexDeclarationEnd;
C++ public: static VertexElement VertexDeclarationEnd;
JScript public static var VertexDeclarationEnd : VertexElement

Field Value

Microsoft.DirectX.Direct3D.VertexElement
A VertexElement structure that marks the end of vertex shader declaration.

This field is read-only. 

Remarks

Vertex data is defined using an array of VertexElement structures. The size of the array includes the VertexDeclarationEnd field, which ends the declaration. The inclusion of this field means that the array count is actually higher than the number of valid vertex elements by one.

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);


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