Because Windows is a multithreaded operating system, it would be possible for a thread to address a surface that is already being modified by a different thread. When locked, the API returns a pointer to the surface memory. The surface memory pointer can also be dereferenced with the array operator to plot a single pixel. If a surface is already locked when the program requests a pointer, Direct Draw returns an error code and does not give the caller the pointer to surface memory. When the program is finished writing to the surface memory, the surface should be unlocked so other callers can write to it.
Memory is arranged linearly.
Assuming the color depth is one byte per pixel, each pixel is exactly one byte after the pixel to the left of it. In contrast to Mode 0x13 though, the first pixel on a scan line might not live exactly one byte behind the last pixel on the previous scan line. Like VBE, Direct Draw surfaces have a 'pitch' associated with them. Pitch is defined as the distance between bytes of the start of a raster line and the start of the next line. Now we'll see how to lock a Direct Draw surface and draw to it.