Microsoft DirectX 8.1 (Visual Basic)

Accessing Surface Memory Directly

You can directly access the surface memory by using the Direct3DSurface8.LockRect method. When you call this method, the RECT parameter is a RECT type that describes the rectangle on the surface to access directly. To request that the entire surface be locked, set RECT to Nothing. Also, you can specify a RECT that covers only a portion of the surface. Providing that no two rectangles overlap, two threads or processes can simultaneously lock multiple rectangles in a surface. Note that a multisample back buffer cannot be locked.

The LockRect method fills a D3DLOCKED_RECT type with all the information to properly access the surface memory. The structure includes information about the pitch and has the locked bits. When you finish accessing the surface memory, call the Direct3DSurface8.UnlockRect method to unlock it.

While you have a surface locked, you can directly manipulate the contents. The following list describes some tips for avoiding common problems with directly rendering surface memory.