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

 

Switching Modes While Running

Ah, we finally get to switching modes…

Well, we'll use a single function to switch modes. It'll be capable of changing between exclusive and windowed, and setting the display mode (while in exclusive mode). Here it is:

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

Kind of simple, isn't it? No, well…I'll explain it a little. When you want to switch from exclusive mode to windowed mode, you call it like this:

ChangeDisplayMode(false, 0, 0, 0); // windowed

When you want to switch to exclusive mode, or just change between resolutions and color depths, you call it like this:

ChangeDisplayMode(true, 640, 480, 16); // 640x480x16 exclusive ChangeDisplayMode(true, 800, 600, 32); // 800x600x32 exclusive

Not bad, huh? Ok, let's flesh it out a little. Here's the whole function:

ChangeDisplayMode(bool bExclusive, int nWidth, int nHeight, int nBPP) { // destroy any existing surfaces and clippers. DestroySurfaces(); // create new surfaces and change the // cooperative level and display mode CreateSurfaces(bExclusive, int nWidth, int nHeight, int nBPP); }

That's it for switching modes!

There are lots of ways to wring more performance out of a windowed mode DirectX app. There are also a few ways to make it easier for the end user to use. We'll try to achieve a blend of both. You'll have to wait for the next article for those tips though!

Good Luck!

- null_pointer
e-mail: ratt96963@aol.com
web site: http://www.freeyellow.com/members8/nullpointer
site name: Sabre Multimedia