Chapter 2 -- Windows Code for Direct3D Programs

[Previous] [Next]

Chapter 2

Microsoft Direct3D programs can be designed to run in full-screen mode or in windowed mode—or both. Full-screen mode, in which the program takes over the entire screen, is popular for many reasons. It gives your program the opportunity to switch to the screen resolution and color depth that makes the program work best on the current hardware. It provides a more immersive experience for the user. And by allowing page flipping and by removing the need to update the graphics of any other programs, it can usually provide the fastest performance. On the other hand, sometimes it's more appropriate to run a Direct3D program in windowed mode—generally when the user might want to see the output of other programs on the screen.

I've found that it's best to develop code for both windowed and full-screen execution and to allow the user to switch between modes. Although developing for both modes adds some time and complexity to your development efforts, it allows those who use your application to choose the environment they want to run in. More important, it allows for the fastest execution of your application on the widest range of acceleration hardware. If a user is running a system with two accelerators—one that supports windowed applications and one that supports full-screen mode only—your software can determine the capabilities of each accelerator and offer the user the choice of extra speed versus extra functionality. In addition, debugging is far easier in windowed mode. To debug effectively in full-screen mode, you need to have a second monitor attached or use a remote debugger.

You'll be much better off if you understand Microsoft Windows code development before you attempt to develop a Direct3D application. This chapter presents the Windows portion of the code necessary to produce a Direct3D application named RoadRage. RoadRage uses the Direct3D Framework described in Chapter 1 and supports both windowed mode and full-screen mode. You'll find the actual code for this chapter in the Chap2 subproject of the RoadRage workspace file, roadrage.dsw, on the companion CD. This code is encapsulated in the main CMyD3DApplication class as well as in several other C++ classes. It shows how to produce a window and its associated menu to control Direct3D parameters (such as fog and shading) for a Direct3D application. Throughout this book, you'll build on the RoadRage application. In Chapter 3, you'll add DirectDraw-based code that determines the target system's 2D capabilities and that lets you switch this application between windowed and full-screen mode (at various resolutions). In the remaining chapters, you'll add the code to enable the features provided in the menus (such as fog and textures) and to supply many other capabilities, including animated characters and network game play.



Inside Direct3D
Inside Direct3D (Dv-Mps Inside)
ISBN: 0735606137
EAN: 2147483647
Year: 1999
Pages: 131

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net