![]() |
| Home | Introduction | Table of Contents | Updates | New Stuff | Links | About the Authors | Ordering | ||
IntroductionApplication development is one of the most rewarding, yet, frustrating fields to work in. It really is amazing how one profession can send you on such an emotional roller-coaster ride. One minute you're pulling your hair out, cursing the engineers at Microsoft. The next minute you're ready to pop open a bottle of champagne. Most of the time, however, you're staring at the progress of the compiler, waiting in anticipation as if the results will make or break you. And, when you do finally get things working, you realize that either you learned a great deal in the process, or you'll never again trust Microsoft's documentation.
Admit ithow many times have you read a cryptic explanation of a function or a technique and wasted so many hours simply because someone neglected to mention a common pitfall? It's completely frustrating! Unfortunately, it seems as if too many things are explained in hieroglyphicsall too often without code examples. (In many cases, I personally find examples more explanatory than the text itself.) Think about it for a moment. The ultimate goal of documentation is to exchange information; and, if you can't get this information across, what's the point? Would the TV Food Network be so popular if Emeril just sat in front of the camera reading from a cookbook? No, of course not! On the other hand, if Emeril is cooking, but you have your TV muted, you're still not going to know exactly what to do. Whatever the task at hand iswhether you're preparing a gourmet meal, solving a difficult equation, or, in our case, developing applicationsthe point is, your source of information must contain a good mix of background information and hands-on examples. Nowadayswith the increasing availability of high-end processing power and the rapid decrease in the cost of video-display componentsmore and more applications are including graphics-based content. This trend places a great demand on the contemporary developer, and makes a basic understanding of graphics programming a vital part of any curriculum. Though, perhaps more than any other programming interface, the Windows graphics API doesn't leave room for error; many of the techniques require a strict procedure that must be followed to the letter. Often, this scheme forces you to memorize a specific set of function calls that are easily forgotten. We've written Windows 2000 Graphics API Black Book with two primary goals in mind: First, as a definitive problem-solver, this text is designed to alleviate the chore of rote memorization. As you'll soon discover, many graphics-based techniques aren't at all difficultthere's certainly no rocket science or magic to it. The fact remains, however, that if you've forgotten which functions to call, or if you've never before attempted the solution, there's a good chance that you'll waste several hours just trying to get thisconceptually simpletechnique to work. Well, we've learned (from personal experience) that this is an all too common situation. As a result, each chapter of this text contains an "Immediate Solutions" section that provides systematic answers, or "recipes," that you can follow to get the task accomplished quickly. When you're in a bind, who cares about a lengthy explanationyou simply follow the recipe, learn from the example, cut and paste the code from the CD-ROM, and then move on to the next task. (Don't get us wrong, we're not trying to endorse bad habits, but we've all done our fair share of cutting and pasting.) Second, and perhaps more importantly, this text aims to answer the whys. "Why do I use function X instead of function Y? Why is this technique faster than the others? Why is this function named so and so?" To answer these questions, each chapter opens with a thorough "In Depth" section that provides the theory behind the solutions. In this way, Windows 2000 Graphics API Black Book serves as both a reference and an explanatory guide. Is This Book for You?Windows 2000 Graphics API Black Book was written with the intermediate or advanced user in mind. This book's topics include:
The companion CD-ROM contains a numerous set of code examples, demo applications, utility functions, and useful C++ classes that reinforce the concepts from the text. We've included projects for both Microsoft Visual C++ and Borland C++Builder. An Overview of Windows GraphicsBack in the command-line era, there was little need for any type of standard graphics interface. Most applications were completely text-based, and the idea of painting a control to the screen oftentimes seemed unnecessary or beyond the scope of an application. Those applications that did require a graphics-based display employed the use of a proprietary graphics interface. In the early 1990s, the release of Windows 3 necessitated the inclusion of a standard graphics interface. The idea was to provide a common means by which an application could render its controls so as to conform to the rest of the graphics environment. The Windows Graphics Device Interface, or GDI for short, filled this role and, at the same time, reduced most third-party interfaces to obsolescence. You can probably imagine the chaos that might result when separate interfaces attempt to simultaneously access the display device driver. Eliminating the developer's role of delegating these interfaces was a primary motivation for the GDI.
Conceptually, the GDI is nothing more than an abstract layer between the developer of a Windows-based application and a device driver. This statement lacks a device specification because the GDI can be used to render graphical representations to a whole slew of different devices. For example, you can use the GDI to produce graphical output on a plotter or printer, as well as on the display monitor. In fact, you rarely have to worry about the specifics of how the interface communicates with separate devices. Instead, you can think of the GDI as a common set of structures and functions that can be used for drawing and painting. There are, of course, some limitations to this rule; rarely is Microsoft technology so straightforward. Don't worry thoughI'll give you a heads up when things get nasty. And if the Windows GDI just isn't your cup of tea, you can quickly refer to a DirectDraw-based solution. DirectDraw was introduced in 1995 as part of the DirectX set of APIs. This set of APIs was developed to facilitate the creation of games and multimedia applications for the Microsoft Windows operating system. With the help of DirectX, Windows 95 soon replaced MS-DOS as the premier platform for PC games. However, you'll notice that DirectX is useful not only for games but for other applications as well. DirectDraw, as the 2D graphics component of DirectX, gives applications low-level access to the display hardware. With DirectDraw, it's possible to use special hardware features that are not exposed through the Windows GDI. DirectDraw was also designed to be compatible with the widest possible variety of display devices. DirectDraw is even capable of emulating features when the hardware does not support them directly. In the past few years, DirectDraw was under constant development. With version 7 of the DirectX runtime (DirectX 7 is an integral part of the Windows 2000 operating system), the DirectDraw API is finally complete. DirectX 8, which was released in November 2000, continues to support DirectDraw. This book is the complete guide to high-performance 2D graphics in Windows 2000 and future operating systems. We'll cover everything from DirectDraw initialization to setting up full-screen applications, taking advantage of hardware-acceleration, gaining direct access to the video memory, using stereo vision, and much more. Used by permission of The Coriolis Group, LLC. |
||
|
|
||
|
Copyright © 2001
The Coriolis Group. All Rights Reserved.
|
||