VertexBuffer.VertexBuffer(IDirect3DVertexBuffer9,Device,Usage,VertexFormats,Pool) Constructor (Microsoft.DirectX.Direct3D)
Creates a new instance of the VertexBuffer class.
Definition
Visual Basic Public Sub New( _
ByVal lp As IDirect3DVertexBuffer9, _
ByVal device As Device, _
ByVal usage As Usage, _
ByVal vertexFormat As VertexFormats, _
ByVal pool As Pool _
)C# public VertexBuffer(
IDirect3DVertexBuffer9 lp,
Device device,
Usage usage,
VertexFormats vertexFormat,
Pool pool
);C++ public:
VertexBuffer(
IDirect3DVertexBuffer9 lp,
Device^ device,
Usage usage,
VertexFormats vertexFormat,
Pool pool
);JScript public function VertexBuffer(
lp : IDirect3DVertexBuffer9,
device : Device,
usage : Usage,
vertexFormat : VertexFormats,
pool : Pool
);
Parameters
lp Microsoft.DirectX.PrivateImplementationDetails.IDirect3DVertexBuffer9
Unmanaged Component Object Model (COM) IDirect3DVertexBuffer9 interface pointer.device Microsoft.DirectX.Direct3D.Device
The Device object to associate with the vertex buffer.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:
- Process vertices in hardware by setting HardwareVertexProcessing.
- Process vertices in software by setting SoftwareVertexProcessing.
- Process vertices in either hardware or software by setting MixedVertexProcessing.
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.
- If the Device constructor uses HardwareVertexProcessing, the VertexBuffer constructor must use 0.
- If the Device constructor uses SoftwareVertexProcessing, the VertexBuffer constructor must use either 0 or SoftwareVertexProcessing. For either value, vertices are processed in software.
- If the Device constructor uses MixedVertexProcessing, the VertexBuffer constructor can use either 0 or SoftwareVertexProcessing.
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
The method call is invalid. For example, a method's parameter might contain an invalid value.
Microsoft Direct3D does not have enough display memory to perform the operation.
Direct3D could not allocate sufficient memory to complete the call.
See Also