DirectX SDK |
A surface, or DirectDrawSurface object, represents a linear area of display memory. A surface usually resides in the display memory of the display card, although surfaces can exist in system memory. Unless specifically instructed otherwise during the creation of the DirectDrawSurface object, DirectDraw object will put the DirectDrawSurface object wherever the best performance can be achieved given the requested capabilities. DirectDrawSurface objects can take advantage of specialized processors on display cards, not only to perform certain tasks faster, but to perform some tasks in parallel with the system CPU.
Using the IDirectDraw7::CreateSurface method, you can create a single surface object, complex surface-flipping chains, or three-dimensional surfaces. The CreateSurface method creates the requested surface or flipping chain and retrieves a pointer to the primary surface's IDirectDrawSurface7 interface through which the object exposes its functionality.
The IDirectDrawSurface7 interface enables you to indirectly access memory through blit methods, such as IDirectDrawSurface7::BltFast. The surface object can provide a device context to the display that you can use with GDI functions. Additionally, you can use IDirectDrawSurface7 methods to directly access display memory. For example, you can use the IDirectDrawSurface7::Lock method to lock the display memory and retrieve the address corresponding to that surface. Addresses of display memory might point to visible frame buffer memory (primary surface) or to nonvisible buffers (off-screen or overlay surfaces). Nonvisible buffers usually reside in display memory, but can be created in system memory if required by hardware limitations or if DirectDraw is performing software emulation. In addition, the IDirectDrawSurface7 interface extends other methods that you can use to set or retrieve palettes, or to work with specific types or surfaces, like flipping chains or overlays.
Using the DirectDraw7.CreateSurface method, you can create a single surface object, complex surface-flipping chains, or three-dimensional surfaces. The CreateSurface method creates the requested surface or flipping chain and retrieves a pointer to the primary surface's DirectDrawSurface7 object through which it exposes its functionality.
The DirectDrawSurface7 object enables you to indirectly access memory through blit methods, such as DirectDrawSurface7.BltFast. The surface object can provide a device context to the display that you can use with GDI functions. Additionally, you can use DirectDrawSurface7 methods to directly access display memory. For example, you can use the DirectDrawSurface7.Lock method to lock the display memory and retrieve the address corresponding to that surface. Addresses of display memory might point to visible frame buffer memory (primary surface) or to nonvisible buffers (off-screen or overlay surfaces). Nonvisible buffers usually reside in display memory, but can be created in system memory if required by hardware limitations or if DirectDraw is performing software emulation. In addition, the DirectDrawSurface7 class extends other methods that you can use to set or retrieve palettes, or to work with specific types or surfaces, like flipping chains or overlays.
From this illustration, you can see that all surface are created by a DirectDraw object and are often used closely with palettes. Although each surface object can be assigned a palette, palettes aren't required for anything but primary surfaces that use pixel formats of 8-bits in depth or less.