Share via


VertexBuffer.VertexBuffer Constructor ()

Creates a new instance of the VertexBuffer class.

Overload List

public VertexBuffer(Device, int, Usage, VertexFormats, Pool);
public VertexBuffer(IDirect3DVertexBuffer9);
public VertexBuffer(IDirect3DVertexBuffer9, Device, Usage, VertexFormats, Pool);
public VertexBuffer(IDirect3DVertexBuffer9, Type, int, Device, Usage, VertexFormats, Pool);
public VertexBuffer(IntPtr);
public VertexBuffer(Type, int, Device, Usage, VertexFormats, Pool);

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