Search Tips Advanced Search |
| Delphi Graphics and Game Programming Exposed with DirectX 7.0 by John Ayres Wordware Publishing, Inc. ISBN: 1556226373 Pub Date: 12/01/99
Search this book:
Previous | Table of Contents | Next
#### Benefits and Drawbacks of DirectX Programming For the most part, DirectX delivers exceptionally on all of its promises. It does indeed give developers a high-performance interface to system-level hardware while maintaining the benefits of the Windows operating system. DirectX offers the game programmer many benefits over using GDI functions, indeed many benefits that weren’t even available under DOS. Even so, there are a few drawbacks to using DirectX over GDI, especially in the Delphi environment. While none of the drawbacks are truly serious, Delphi developers should be aware of both the advantages and disadvantages of using DirectX over traditional Windows programming techniques. Benefits Speed As we’ve already discussed, DirectX allows the game developer to squeeze the maximum performance out of applications. Performing just about any game application task is substantially faster than employing similar GDI functions. In fact, DirectX offers some functionality that would be very difficult and time consuming to emulate using the multimedia API. Greater Control DirectX gives applications incredible control over some things that would be impossible, impractical, or difficult under GDI. Such tasks as direct memory access to bitmapped graphics or audio data (in either hardware or system memory) and full control over the color palette (without the annoying GDI remapping of colors) are now possible through DirectX. Feature Emulation Many features for which hardware acceleration is unavailable are emulated in DirectX. This provides the developer with a certain minimal framework of functionality that is guaranteed to exist with or without hardware support. While this may result in some loss of performance, software emulation of hardware features is implemented using very low-level multimedia API functions and assembly language, and in many cases is almost as fast as the hardware implementation. Most of the standard features have a software emulation, such as copying image data from one memory area to another or mixing sound buffers on the fly. Drawbacks Difficult Debugging DirectX applications are simply harder to debug than traditional Windows applications. Most high-performance games are written in a full-screen video mode, and in a full-screen video mode, you can’t set breakpoints and step through your code. There are other debugging techniques you can use to get around this limitation, but once an application initializes a full- screen video mode, most of Delphi’s awesome debugging features are completely useless. Few Delphi Examples DirectX has, until recently, been solely the domain of C/C++ programmers. As such, most examples are written in C/C++. All of the DirectX documentation is certainly written for C/C++. Unfortunately, Delphi programmers may be required to learn at least a nominal amount of C/C++ before taking advantage of the DirectX documentation and numerous DirectX books and references that are available. Fortunately, several companies and individuals have written numerous DirectX libraries for Delphi, and there are several Delphi-specific DirectX programming web sites now available. Hopefully, this will result in an increase of DirectX documentation and references for the ambitious Delphi game programmer. Steep Learning Curve Even in its most recent incarnation, DirectX is still a fairly new API. As such, one must usually perform several steps in order to perform certain actions, especially when initializing many of the DirectX subsystems. The programmer is usually required to perform these steps in a very specific order, and unless the programmer is very familiar with how certain DirectX functionality is implemented, it may be very difficult to get things working initially. This, coupled with the fact that the DirectX API is huge and there are few Delphi examples, usually results in a rather step learning curve for first-time game programmers. #### The DirectX Architecture The DirectX API itself, in the form of various COM objects and their methods, acts as an interface into the DirectX drivers. On the back side, the DirectX drivers can be thought of as two separate systems: the hardware abstraction layer (HAL) and the hardware emulation layer (HEL).
| HAL: hardware abstraction layer; the DirectX drivers responsible for direct interface to hardware capabilities.
HEL: hardware emulation layer; the DirectX drivers responsible for emulating certain functionality if not present in hardware.
The HAL represents the hardware itself. When a DirectX object is created, it interrogates the HAL about hardware capabilities. The HEL, on the other hand, represents the software emulation of certain features. If an application asks a DirectX object to perform a certain task, it will be performed in hardware if the HAL indicates that the capability exists. Otherwise, the task will be performed in software if the HEL supports the emulated feature. Some features would be very slow to emulate in software, and thus may not be available in the HEL. These features will simply be unavailable to the application unless the HAL indicates they are present in the hardware. The HAL provides developers with hardware acceleration when available, and the HEL fills in where it can to provide a consistent, base set of features. It is important to note that, for the most part, this is completely transparent to developers. Unless a developer is using a feature that is specifically implemented in hardware and not emulated by the HEL (such as overlays), an application need not be concerned if hardware support is present or not. However, an application can query DirectX to see if specific features are implemented in hardware or are emulated. An application can then use this knowledge to optimize various game functions, taking advantage of those functions that are specifically supported by the hardware and using a different approach for those functions that are too slow when emulated. This allows game developers to write applications that take advantage of available hardware under various configurations while still functioning adequately under all configurations.
Previous | Table of Contents | Next

Products | Contact Us | About Us | Privacy | Ad Info | Home Use of this site is subject to certain Terms & Conditions, Copyright © 1996-2000 EarthWeb Inc. All rights reserved. Reproduction whole or in part in any form or medium without express written permission of EarthWeb is prohibited. Read EarthWeb's privacy statement.