IDirect3DVertexBuffer::Lock

The IDirect3DVertexBuffer::Lock methods locks a vertex buffer and obtains a pointer to the vertex buffer memory.

HRESULT Lock(
  DWORD   dwFlags,
  LPVOID* lplpData,
  LPDWORD lpdwSize
);

Parameters

dwFlags
Flags indicating how the vertex buffer memory should be locked.
DDLOCK_EVENT
This flag is not currently implemented.
DDLOCK_NOSYSLOCK
If possible, do not take the Win16Mutex (also known as Win16Lock).
DDLOCK_READONLY
Indicates that the memory being locked will only be read from.
DDLOCK_SURFACEMEMORYPTR
Indicates that a valid memory pointer to the vertex buffer should be returned; this is the default.
DDLOCK_WAIT
If a lock cannot be obtained immediately, the method retries until a lock is obtained or another error occurs.
DDLOCK_WRITEONLY
Indicates that the memory being locked will only be written to.
lplpData
Address of a variable that will contain the address of the vertex buffer memory if the call succeeds.
lpdwSize
Address of a variable that will contain the size of the vertex buffer memory at lplpData. Set to NULL if the buffer size is unneeded.

Return Values

If the method succeeds, the return value is D3D_OK.

If the method fails, the return value may be one of the following values:

D3DERR_VERTEXBUFFEROPTIMIZED
DDERR_INVALIDPARAMS
DDERR_OUTOFMEMORY
DDERR_SURFACEBUSY
DDERR_SURFACELOST

Remarks

After locking the vertex buffer, you can access the memory until a corresponding call to IDirect3DVertexBuffer::Unlock.

You cannot render from a locked vertex buffer; calls to the IDirect3DDevice3::DrawIndexedPrimitiveVB or IDirect3DDevice3::DrawPrimitiveVB method using a locked buffer will fail, returning D3DERR_VERTEXBUFFERLOCKED.

This method often causes the system to hold the Win16Mutex until you call the IDirect3DVertexBuffer::Unlock method. GUI debuggers cannot operate while the Win16Mutex is held.

QuickInfo

  Windows NT/2000: Requires Windows 2000.
  Windows 95/98: Requires Windows 95 or later. Available as a redistributable for Windows 95.
  Header: Declared in d3d.h.
  Import Library: Use ddraw.lib.

See Also

IDirect3DVertexBuffer::Unlock, Accessing Vertex Buffer Memory