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
89 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:

  Contents

 Introduction
 The Design
 CreateSurfaces()
 DestroySurfaces()
 The Game Loop
 Switching Modes
 While Running


 Get the demo!
 Printable version

 


  The Series

 Part 1
 Part 2

 

The Design

Many parts of DirectDraw initialization are different for windowed mode. The best way to do it is first to create the DirectDraw object when your program starts up. Second, you create all your surfaces, set the cooperative level, set the display mode, fill out any variables you need, etc. This second stage is where all the changes between exclusive mode and windowed mode are found. So, your functions are set up like this:

void CreateDirectDraw(); void DestroyDirectDraw();

and

void CreateSurfaces(bool bExclusive, int nWidth, int nHeight, int nBPP); void DestroySurfaces();

The first set (CreateDirectDraw and DestroyDirectDraw) create the DirectDraw object and destroy it, respectively. You should be able to fill those out yourself. The second set (CreateSurfaces and DestroySurfaces) handle everything else associated with setting up and shutting down DirectDraw. Looking at the parameter, bExclusive, you'll see that they create either the exclusive mode surfaces or the windowed mode surfaces, along with all the other objects necessary to use them. The width, height, and bpp parameters specify the display mode to use, if bExclusive is true.

We'll need to modify the game loop a little to handle windowed mode. We'll also need a function that handles switching modes that'll get it up and running:

void SwitchMode(bool bExclusive, int nWidth, int nHeight, int nBPP);

Read on for the implementation of these functions!


Next : CreateSurfaces()