VertexDeclaration Class (Microsoft.DirectX.Direct3D)
How Do I...?
- Create a Vertex Declaration
Encapsulates the vertex shader declaration.
Definition
Visual Basic NotInheritable Public Class VertexDeclaration
Inherits MarshalByRefObject
Implements IDisposableC# public sealed class VertexDeclaration : MarshalByRefObject, IDisposable C++ public ref class VertexDeclaration sealed : MarshalByRefObject, IDisposable JScript public final class VertexDeclaration extends MarshalByRefObject implements IDisposable
Members Table
The following table lists the members exposed by the object.
Events
Event Description Disposing Occurs when the Dispose method is called or when the VertexDeclaration object is finalized and collected by the garbage collector of the .NET common language runtime. Methods
Method Description Dispose Immediately releases the unmanaged resources used by the VertexDeclaration object. Equals Returns a value that indicates whether the current instance is equal to a specified object. Finalize Allows the VertexDeclaration object to free resources before it is destroyed by the garbage collector. GetDeclaration Gets the vertex shader declaration. GetHashCode Returns the hash code for the current instance. GetObjectByValue This member supports the infrastructure for Microsoft DirectX 9.0 for Managed Code and is not intended to be used directly from your code. op_Equality Compares the current instance of a class to another instance to determine whether they are the same. op_Inequality Compares the current instance of a class to another instance to determine whether they are different. raise_Disposing Raises the Microsoft.DirectX.Direct3D.VertexDeclaration.Disposing event when called from within a derived class. UpdateUnmanagedPointer Updates the unmanaged pointer for this VertexDeclaration object. This method supports the Microsoft .NET Framework infrastructure and is not intended to be used directly in your code. VertexDeclaration Creates a new instance of the VertexDeclaration class. Properties
Property Description Device Retrieves the Device used to create the current vertex declaration. Disposed Gets a value that indicates whether the object is disposed. UnmanagedComPointer Returns the unmanaged Component Object Model (COM) IDirect3DVertexDeclaration9 interface pointer.
Inheritance Hierarchy
VertexDeclaration
Remarks
A vertex shader declaration is made up of an array of vertex elements.
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);
Class 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