Upcoming Events
Unite 2010
11/10 - 11/12 @ Montréal, Canada

GDC China
12/5 - 12/7 @ Shanghai, China

Asia Game Show 2010
12/24 - 12/27  

GDC 2011
2/28 - 3/4 @ San Francisco, CA

More events...
Quick Stats
97 people currently visiting GDNet.
2406 articles in the reference section.

Help us fight cancer!
Join SETI Team GDNet!
Link to us Events 4 Gamers
Intel sponsors gamedev.net search:

by Nathan Davies from Alamar's Domain

  Contents

 Introduction
 Display Drivers
 Display Modes
 D3D Devices
 Cleanup and
 Conclusion


 Printable version

 


Enumerating Modes

To be able to enumerate the Display Modes, a valid DirectDraw object must already be created with DirectDrawCreateEx(). As you should know, the DirectDrawCreateEx() function takes the GUID of a Display Driver as it's first argument. If this GUID value is NULL, the primary Display Driver is assumed to be the Driver being created. Since the Display Mode and Devices are dependant on the Display Driver created, this is done for each Display Driver enumerated.

for( DisplayDriver* TheDD = DisplayDriverList; TheDD; TheDD = TheDD->Next ) { DirectDrawCreateEx( &( TheDD->Guid ), ( void** ) &pDirectDraw, IID_IDirectDraw7, NULL ); pDirectDraw->SetCooperativeLevel( hWnd, DDSCL_NORMAL ); // Enumerate Display Modes and D3D Devices // Release DirectDraw and Direct3D objects }

The call to enumerate Display Modes is EnumDisplayModes(). The paramters passed are: the flags, a DDSURFACEDESC2 value to check against, the pointer to any variable you wish to pass, and lastly, the pointer to the callback function For Example:

// Display Mode Enumeration Function pDirectDraw->EnumDisplayModes( 0, NULL, &( TheDD->DisplayModeList ), ( LPDDENUMMODESCALLBACK2 )EnumDisplayModes );

EnumDisplayModes will be called once for each Display Mode found. Notice that I passed the address of the current DisplayDriver's DisplayModeList variable. The code for EnumDisplayModes follows

Popup : EnumDisplayModes

In EnumDisplayModes, a variable is declared to refer to the DisplayModeList value passed. A new DisplayMode variable is then allocated. This structure is filled with the relevant information that was passed to this function. This information includes the Width, Height and Depth of the Mode Enumerated. Next, the Mode is added to the end of the DisplayModeList passed.


Next : D3D Devices