The DirectX APIs

[Previous] [Next]

DirectX is composed of several APIs that are designed to work together to help you develop 3D multimedia games and simulations (as well as many other non-3D applications). It provides libraries of functions to perform 2D and 3D rendering; standard and 3D sound; music; support for keyboards, joysticks, and many other types of input devices, including force-feedback-capable hardware; and network game play. These interfaces mesh to provide you with a powerful, integrated library of commands that you can use to efficiently create superb games and simulations.

The APIs currently implemented in DirectX are DirectDraw, Direct3D, DirectMusic, DirectSound, DirectPlay, DirectInput, and DirectSetup. Throughout this book and in the code on the companion CD, I show you how to integrate several of these APIs—DirectDraw, Direct3D, DirectSound, DirectPlay, and DirectInput—into a 3D application aimed at the first-person-perspective 3D gaming market.

DirectDraw

The DirectDraw API provides display device handling, control of bitmap data and off-screen memory, and fast access to other hardware features such as blitting and page flipping. It is also the foundation on which Direct3D is built. In Chapter 3, I'll be covering all the aspects of DirectDraw that you need to understand to create a Direct3D application. You can use the code there as the basis for all your 3D games. If you want to, you can also use DirectDraw by itself to develop 2D games; however, I won't be describing how to use DirectDraw for 2D games in this book since the focus is on developing 3D games.

Direct3D

Direct3D, the main focus of this book, is an API that can be used to write programs that use 3D graphics and take advantage of hardware acceleration of 3D operations. Almost all graphics cards now being sold support 3D acceleration, and the innovation taking place in the field of 3D graphics on PCs is tremendous. Most 3D games now available for Windows were implemented using Direct3D.

When Direct3D was first introduced, it provided two APIs: Immediate Mode and Retained Mode. Immediate Mode (so named because rendering of objects took place immediately upon the programmer's request) was difficult to use, but it was the most flexible, low-level API for writing games that ran as efficiently as possible. Retained Mode (so named because the API retained the scene database and rendered it all at once) was built as a layer on top of Immediate Mode that provided additional services, such as texture management, object file loading, a frame hierarchy, and animation. Retained Mode was easier to learn and use than Immediate Mode, but ultimately, programmers wanted the added performance and flexibility that Immediate Mode provided. Development of the Retained Mode API stopped with the release of DirectX 6, and the Direct3D team has focused on improving both the power and the ease of use of the Immediate Mode API. Retained Mode doesn't support important new technologies such as multitexturing, bump mapping, or hardware transformation and lighting. All future 3D programs should be written using Immediate Mode, and this book is exclusively devoted to the Immediate Mode API. By the time you've finished reading this book, you'll have a solid understanding of the nuances of Immediate Mode and you'll know how to integrate it with the other portions of DirectX to create powerful 3D games.

DirectMusic

This API of DirectX works with message-based musical data that is converted to wave samples using a hardware or software synthesizer. The default software implementation uses the Microsoft Software Synthesizer to create wave samples that are streamed to DirectSound. The instrument voices used are synthesized from samples according to the Downloadable Sounds (DLS) Standard. DirectMusic also has a composition engine that can compose music on the fly based on certain rules that you provide.

DirectSound

This API provides efficient stereo and 3D sound handling, including memory management and hardware sound mixing. DirectSound is designed to take advantage of whatever hardware is on the target system. Integrating 3D sound into any game or simulation you develop is a good idea because of the level of realism it adds to your applications. Hearing sounds coming from your left, your right, above you—essentially from all over—can make an environment much more intriguing, especially when you're playing against an opponent using DirectPlay.

DirectPlay

DirectPlay launches multiplayer games and enables transport-independent connection and messaging services. Gamers have begun to expect that any good first-person-perspective game will support network play, modem play, or both. Many of the most popular games today provide these features, and gamers have realized that multiplayer gaming (head-to-head play) is much more fun than playing alone or against the computer. (Many businesses have learned this fact the hard way—after their networks became tied up and they had to introduce policies forbidding people to play these games at the office!) I recommend that you implement network play for any first-person-perspective game you design if you want it to compete successfully in the gaming market. In Chapter 15, I'll show you all the DirectPlay code that a game needs to connect to a host via the network, over the Internet, or using a modem.

DirectInput

This DirectX API supplies low-latency input support for almost every input device. DirectX 7 integrates force-feedback support for every type of device, including steering wheels and joysticks. Force-feedback devices can simulate sensations such as bumps in the road, gun recoil when firing, wind shear when flying, and wave motion on a boat.

DirectSetup

This API handles the automated installation of DirectX. Most systems today have DirectX installed, but for those that don't, DirectSetup provides an automated way to install the DirectX run-time components that an application needs. Because Microsoft allows DirectX to be distributed free of charge, developers can configure their software to always install DirectX if it isn't present or if it's an older version.

Microsoft provides the DirectX run-time components in the DXF\redist directory of the DirectX 7 SDK, which is included on the companion CD for this book. Also be aware that the DirectX run-time components are subject to the End-User License Agreement terms found in DXF\redist\license\directx end user eula.txt.



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