IDirect3DVertexBuffer8::Lock
This method locks a range of vertex data and obtains a pointer to the vertex buffer memory.
HRESULT Lock(
UINT OffsetToLock,
UINT SizeToLock,
BYTE** ppbData,
DWORD Flags
);
Parameters
- OffsetToLock
[in] Offset into the vertex data to lock, in bytes. - SizeToLock
[in] Size of the vertex data to lock, in bytes. Specify 0 to lock the entire vertex buffer. - ppbData
[out] Address of a pointer to an array of BYTE values, filled with the returned vertex data. - Flags
[in] Combination of zero or more locking flags, indicating how the vertex buffer memory should be locked.Value Description D3DLOCK_DISCARD The application overwrites the entire vertex buffer with a write-only operation. This enables Direct3D to return a pointer to a new memory area so that the dynamic memory access (DMA) and rendering from the old area do not stall. See Remarks. D3DLOCK_NOOVERWRITE Indicates that no vertices that were referred to in drawing calls since the start of the frame or the last lock without this flag will be modified during the lock. This can enable optimizations when the application is appending data only to the vertex buffer. See Remarks. D3DLOCK_NOSYSLOCK The default behavior of a video memory lock is to reserve a system-wide critical section, guaranteeing that no display mode changes will occur for the duration of the lock. This flag causes the system-wide critical section not to be held for the duration of the lock. The lock operation is slightly more expensive, but can enable the system to perform other duties, such as moving the mouse cursor. This flag is useful for long-duration locks, such as the lock of the back buffer for software rendering that would otherwise adversely affect system responsiveness.
D3DLOCK_READONLY The application will not write to the buffer. This enables some optimizations. D3DLOCK_READONLY cannot be specified with D3DLOCK_DISCARD, nor can it be specified on a vertex buffer created with D3DUSAGE_WRITEONLY.
Return Values
If the method succeeds, the return value is D3D_OK.
If the method fails, the return value can be D3DERR_INVALIDCALL.
Remarks
When working with vertex buffers, you are allowed to 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.
The D3DLOCK_DISCARD and D3DLOCK_NOOVERWRITE flags are valid only on buffers created with D3DUSAGE_DYNAMIC.
See Using Dynamic Vertex and Index Buffers for information on using D3DLOCK_DISCARD or D3DLOCK_NOOVERWRITE for the Flags parameter of the Lock method.
Requirements
OS Versions: Windows CE .NET 4.0 and later.
Header: D3d8.h.
Link Library: D3d8.lib.
See Also
Using Dynamic Vertex and Index Buffers | IDirect3DVertexBuffer8::Unlock | IDirect3DVertexBuffer8
Last updated on Thursday, April 08, 2004
© 1992-2003 Microsoft Corporation. All rights reserved.