Platform SDK: DirectX

What Are DirectDraw Objects?

[C++]

The DirectDraw object is the heart of all DirectDraw applications and is an integral part of Direct3DŽ applications as well. It is the first object you create and, through it, you create all other related objects. For DirectX 7.0, a new method is introduced for creating the latest iteration of the DirectDraw object. The DirectDrawCreateEx function creates a DirectDraw object capable of exposing the newest set of Direct3D interfaces. In previous versions, you created a DirectDraw object by calling the DirectDrawCreate function, which returns an IDirectDraw interface. If you wanted to work with a different iteration of the interface (such as IDirectDraw7) to take advantage of new features it provides, you can query for it. (See Getting an IDirectDraw7 Interface.) In DirectX 7.0, you can still query for the IDirectDraw7 interface after creating the DirectDraw object using DirectDrawCreate, but it will not support the new set of features of Direct3D. To use the new functionality of Direct3D, you must return an IDirectDraw7 interface using the DirectDrawCreateEx function. Note that you can create multiple DirectDraw objects, one for each display device installed in a system.

[Visual Basic]

The DirectDraw object is the heart of all DirectDraw applications and is an integral part of Direct3DŽ applications as well. It is the first object you create and, through it, you create all other related objects. In Visual Basic, calling the DirectX7.DirectDrawCreate method creates a DirectDraw7 object capable of exposing the newest set of Direct3D interfaces.

The DirectDraw object represents the display device and makes use of hardware acceleration if the display device for which it was created supports hardware acceleration. Each unique DirectDraw object can manipulate the display device and create surfaces, palettes, and clipper objects that are dependent on (or are, "connected to") the object that created them. For example, to create surfaces, you call the IDirectDraw7::CreateSurface method in C++ or the DirectDraw7.CreateSurface method in Visual Basic. Or, if you need a palette object to apply to a surface, call the IDirectDraw7::CreatePalette method in C++ or the DirectDraw7.CreatePalette method in Visual Basic. Additionally, the IDirectDraw7 interface and DirectDraw7 object exposes similar methods to create clipper objects.

You can create more than one instance of a DirectDraw object at a time. The simplest example of this is using two monitors on a Windows 95 or Windows NT 4.0 and earlier system. Although these operating systems don't support dual monitors on their own, it is possible to write a DirectDraw HAL for each display device. The display device Windows and GDI recognizes is the one that will be used when you create the instance of the default DirectDraw object. The display device that Windows and GDI do not recognize can be addressed by another, independent DirectDraw object that must be created by using the second display device's globally unique identifier (GUID). This GUID can be obtained by using the DirectDrawEnumerate function in C++ or the DirectDrawEnum.GetGuid method in Visual Basic.

The DirectDraw object manages all of the objects it creates. It controls the default palette (if the primary surface is in 8-bits-per-pixel mode), the default color key, and the hardware display mode. It tracks what resources have been allocated and what resources remain to be allocated.