Platform SDK: DirectX

Step 1: Create a DirectDraw Object

[Visual Basic]

The information in this section pertains only to applications written in C and C++. See DirectDraw Visual Basic Tutorials.

[C++]

To create an instance of a DirectDraw object, your application should use the DirectDrawCreateEx function as shown in the InitApp sample function of the DDEx1 program. DirectDrawCreateEx contains four parameters. The first parameter takes a globally unique identifier (GUID) that represents the display device. The GUID, in most cases, is set to NULL, which means DirectDraw uses the default display driver for the system. The second parameter contains the address of a pointer that identifies the location of the DirectDraw object if it is created. The third parameter is the reference identification for the IDirectDraw7 interface; this parameter must be set to IID_IDirectDraw7. The fourth parameter is always set to NULL and is included for future expansion.

The following example shows how to create the DirectDraw object and how to determine whether the creation was successful.

hRet = DirectDrawCreateEx(NULL, (VOID**)&g_pDD, IID_IDirectDraw7, NULL);
if(hRet == DD_OK) 
{ 
    // g_pDD is a valid DirectDraw object. 
} 
else 
{ 
    // The DirectDraw object could not be created. 
} 
 

Next: Step 2: Determine the Application's Behavior