Step 1: Creating a DirectDraw Object
To create an instance of a DirectDraw object, your application should use the DirectDrawCreate function as shown in the doInit sample function of the DDEX1 program. DirectDrawCreate contains three 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 always set to NULL and is included for future expansion.
The following example shows how to create the DirectDraw object and how to determine if the creation was successful or not:
ddrval = DirectDrawCreate(NULL, &lpDD, NULL);
if(ddrval == DD_OK)
{
// lpDD is a valid DirectDraw object.
}
else
{
// The DirectDraw object could not be created.
}