Direct3DVertexBuffer7.Lock
The Direct3DVertexBuffer7.Lock methods locks a vertex buffer.
object.Lock(flags As CONST_DDLOCKFLAGS)
Parameters
- object
- Object expression that resolves to a Direct3DVertexBuffer7 object.
- flags
- One of the following constants from the CONST_DDLOCKFLAGS enumeration indicating how the vertex buffer memory should be locked.
- 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_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.
- DDLOCK_DISCARDCONTENTS
- Used only with Direct3D vertex-buffer locks. Indicates that no assumptions are made about the contents of the vertex buffer during this lock. This enables Direct3D or the driver to provide an alternative memory area as the vertex buffer. This is useful when you plan to clear the contents of the vertex buffer and fill in new data.
- DDLOCK_NOOVERWRITE
- Used only with Direct3D vertex-buffer locks. Indicates that no vertices that were referred to in vertex-buffer DrawPrimitive calls since the start of the frame (or the last lock without this flag) are modified during the lock. This can be useful when you want only to append data to the vertex buffer.
Error Codes
If the method fails, an error is raised and Err.Number may be set to one of the following values:
For information on trapping errors, see the Visual Basic Error Trapping topic.
Remarks
While the vertex buffer is locked, you can manipulate the data within it by calling the Direct3DVertexBuffer7.GetVertices and Direct3DVertexBuffer7.SetVertices methods. After locking the vertex buffer, you can access the memory until a corresponding call to Direct3DVertexBuffer7.Unlock.
You cannot render from a locked vertex buffer; calls to the Direct3DDevice7.DrawIndexedPrimitiveVB or Direct3DDevice7.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 Direct3DVertexBuffer7.Unlock method. GUI debuggers cannot operate while the Win16Mutex is held.
See Also
Direct3DVertexBuffer7.Unlock, Accessing the Contents of a Vertex Buffer