Share via


VertexBuffer.VertexBuffer(Device,Int32,Usage,VertexFormats,Pool) Constructor (Microsoft.DirectX.Direct3D)

Creates a new instance of the VertexBuffer class.

Definition

Visual Basic Public Sub New( _
    ByVal device As Device, _
    ByVal sizeOfBufferInBytes As Integer, _
    ByVal usage As Usage, _
    ByVal vertexFormat As VertexFormats, _
    ByVal pool As Pool _
)
C# public VertexBuffer(
    Device device,
    int sizeOfBufferInBytes,
    Usage usage,
    VertexFormats vertexFormat,
    Pool pool
);
C++ public:
 VertexBuffer(
    Devicedevice,
    int sizeOfBufferInBytes,
    Usage usage,
    VertexFormats vertexFormat,
    Pool pool
);
JScript public function VertexBuffer(
    device : Device,
    sizeOfBufferInBytes : int,
    usage : Usage,
    vertexFormat : VertexFormats,
    pool : Pool
);

Parameters

device Microsoft.DirectX.Direct3D.Device
The Device object to associate with the vertex buffer.
sizeOfBufferInBytes System.Int32
Size of the vertex buffer in bytes. If param_VertexFormats_vertexFormat is set to 0, param_Int32_sizeOfBufferInBytes must be large enough to contain at least one vertex, but it need not be a multiple of the vertex size. If param_VertexFormats_vertexFormat is not set to 0, param_Int32_sizeOfBufferInBytes is not validated. See Remarks.
usage Microsoft.DirectX.Direct3D.Usage
Usage can be 0, which indicates no usage value. However, if usage is desired, use a combination of one or more Usage flags. It is good practice to match the usage parameter in the VertexBuffer constructor with the behavior flags in the Device constructor. See Remarks.
vertexFormat Microsoft.DirectX.Direct3D.VertexFormats
Combination of VertexFormats flags that describe the vertex format of the vertices in the buffer.
pool Microsoft.DirectX.Direct3D.Pool
Member of the Pool enumerated type that describes a valid memory class in which to place the resource.

Remarks

A vertex buffer can be used with either hardware or software vertex processing. The type of processing is determined by the way the device and the vertex buffer are created.

When a device is created, the Device constructor uses the behavior flag to determine whether to process vertices in hardware or software. The options are:

After the device is created, mixed-mode devices might need to switch between software and hardware processing (using Device.SoftwareVertexProcessing).

When a vertex buffer is created, the VertexBuffer constructor uses the param_Usage_usage parameter to determine whether to process vertices in hardware or software. The following rules apply.

To use a vertex buffer with a mixed-mode device, create one that can be used for both hardware and software processing. Use Device.SetStreamSource to set the current vertex buffer and Device.RenderState, if necessary, to change the device behavior to match. It is recommended that the vertex buffer usage match the device behavior. Note that a vertex buffer created for software processing cannot be located in video memory.

The Device object supports rendering of primitives using vertex data stored in vertex buffer objects. Vertex buffers are created from the Device, and are usable only with the Device object from which they are created.

Those VertexBuffer constructors that are created with the param_VertexFormats_vertexFormat parameter set to 0 can be used to interleave data during multipass or multitexture rendering in a single pass. To do this, one buffer contains geometry data and the others contain texture coordinates for each texture to render. When rendering, the buffer that contains the geometry data is interleaved with each of the buffers that contain the texture coordinates. If the param_VertexFormats_vertexFormat parameter is set to a non-zero value, each buffer must contain identical geometry data in addition to the texture coordinate data specific to each rendered texture. This results in either a speed or memory penalty, depending on the strategy used.

Exceptions

InvalidCallException

The method call is invalid. For example, a method's parameter might contain an invalid value.

OutOfVideoMemoryException

Microsoft Direct3D does not have enough display memory to perform the operation.

OutOfMemoryExceptionLeave Site

Direct3D could not allocate sufficient memory to complete the call.

See Also