Microsoft DirectX 8.1 (Visual Basic)

Direct3DVertexBuffer8.Lock

Locks a range of vertex data and obtains access to the vertex buffer memory.

object.Lock( _ 
    OffsetToLock As Long, _ 
    SizeToLock As Long, _ 
    Data As Long, _ 
    Flags As Long)

Parts

object
Object expression that resolves to a Direct3DVertexBuffer8 object.
OffsetToLock
Offset into the vertex data to lock, in bytes. To lock the entire vertex buffer, specify 0 for both parameters, SizeToLock and OffsetToLock.
SizeToLock
Size of the vertex data to lock, in bytes. To lock the entire vertex buffer, specify 0 for both parameters, SizeToLock and OffsetToLock.
Data
First element of an array of Long values, filled with the returned vertex data.
Flags
Combination of zero or more valid locking flags defined by the CONST_D3DLOCKFLAGS enumeration, describing how the vertex buffer memory should be locked.

Error Codes

If the method fails, an error is raised and Err.Number can be set to D3DERR_INVALIDCALL.

For information on trapping errors, see the Microsoft® Visual Basic® Error Handling topic.

Remarks

To lock, read, and unlock vertex data with a single function call, use D3DVertexBuffer8GetData.

To lock fill, and unlock vertex data with a single function call, use D3DVertexBuffer8SetData.

When working with vertex buffers, you can make multiple lock calls; however, you must ensure that the number of lock calls match the number of unlock calls. DrawPrimitive calls will not succeed with any outstanding lock count on any currently set vertex buffer.

See Using Dynamic Vertex and Index Buffers for information on using D3DLOCK_DISCARD or D3DLOCK_NOOVERWRITE for the Flags parameter of the Lock method.

See Also

Direct3DVertexBuffer8.Unlock, D3DVertexBuffer8GetData, D3DVertexBuffer8SetData