Share via


Locking Direct3D Mobile Resources (Windows Embedded CE 6.0)

1/6/2010

You must lock a resource to obtain a pointer to the actual memory buffer for that resource. Locking gives you exclusive control of that resource and prevents it from being used in any other operations.

All interfaces to resource objects contain a Lock (or LockRect) method that is used to retrieve the pointer, as well as an Unlock (or UnlockRect) method, which allows the resource to be used in other operations again. The pointer retrieved when locking a resource is not valid after the resource has been unlocked. The result of reading from a pointer that has been unlocked is undefined.

Driver support for locking resources may vary. Direct3D Mobile requires that drivers allow vertex buffers, index buffers, and image surfaces to be locked. It is desirable for drivers to support locking of front, back, and depth buffers and texture map levels but this support is not required.

When locking a vertex or index buffer the Direct3D Mobile middleware will pass a byte offset as a parameter to determine the buffers that will be locked. By passing a byte offset it is possible to provide an offset value that is not aligned on a particular vertex or index buffer boundary. If a lock is performed on a non-buffer boundary, the Direct3D Mobile middleware allow the lock but also generate a debug message for the condition.

See Also

Concepts

Using Direct3D Mobile Resources