03 01


Delphi Graphics and Game Programming Exposed! with DirectX For versions 5.0-7.0:Basic Graphics Programming                       Search Tips   Advanced Search        Title Author Publisher ISBN    Please Select ----------- Artificial Intel Business & Mgmt Components Content Mgmt Certification Databases Enterprise Mgmt Fun/Games Groupware Hardware IBM Redbooks Intranet Dev Middleware Multimedia Networks OS Productivity Apps Programming Langs Security Soft Engineering UI Web Services Webmaster Y2K ----------- New Arrivals









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 CHAPTER 3Basic Graphics Programming This chapter covers the following topics: •  Graphical elements, such as pixels, lines, and polygons •  Video mode resolutions and color depth, and the difference between palettized and non-palettized video modes •  Device contexts and their use •  Using the TCanvas object for graphical output •  Essential bitmap techniques •  Color palettes Like other industries, the computer industry has matured to the point that it can be thought of in terms of specialties. There are specialists in hardware installation, technical support, client/server architecture, etc. Some fields, such as programming, are further divided. Programming offers many areas of specialization, including database programming, speech recognition, or even communications. Of these, graphics programming is one of the most fun, rewarding, and sought-after specialties. All client-side applications that interact directly with the user make some use of graphics programming techniques, be they simple GDI commands for drawing basic Windows interface elements or full-fledged, 3-D rendered landscapes in games. At some point, any programmer working on an application to be used by end users will need to have some knowledge of graphical programming techniques. This book’s primary focus is on high-performance graphics and games programming using DirectX. Although the techniques discussed throughout the book are advanced by their very nature, the neophyte to graphics programming should not be ignored. Many people have used Delphi solely for client/server database applications or business related programs, and are just now experimenting with its broader range of functionality. There have been several shareware games written in Delphi, and retail games created with Delphi, while rare, are starting to emerge. Thus, many readers of this book are probably new to graphics programming, and may be a little fearful of the advanced topics presented in the coming chapters. To this end, this chapter has been dedicated to acclimating the Delphi programmer to terms and concepts common in graphics programming. Although no one concept is discussed in any great depth, after reading this chapter, the casual Delphi programmer will be familiar with many of the terms and concepts that will be expounded upon in later chapters. This should give Delphi programmers a good base of knowledge to prepare them for the graphics programming techniques to come. Readers who are familiar with basic graphics programming topics, such as pixels, lines, polygons, bitmaps, and using the TCanvas object, may want to skip ahead to the next chapter, which introduces DirectX. However, if you’re not familiar with these topics, read on. The Graphical Device Interface One of the fundamental pieces of Windows is the Graphical Device Interface, or the GDI. This important subsystem is responsible for all of the graphical output displayed to the screen during a Windows session. The GDI subsystem is accessed through a wide variety of functions and procedures. Buttons, lines, scroll bars, application windows themselves, even text, are all drawn by these GDI functions and procedures. Graphical Device Interface (GDI): The Windows subsystem responsible for all graphical output during a Windows session. One of Window’s strongest attributes is its device independence, or its ability to be run on a wide variety of hardware combinations. Due to this requirement, the GDI’s primary purpose is to provide a mechanism by which an application can output graphical content without the programmer being concerned about what type of hardware upon which the application will be running. It accomplishes this goal superbly; it is incredibly easy to draw lines, buttons, bitmaps, etc., without being concerned with hardware. Unfortunately, as a direct consequence of this device independence, the GDI is notorious for its slow performance. Even with this reputation, the GDI is very useful when creating tools for games. While most games today are written in DirectX, it is very common for the game programmers to write tools under regular Windows using the GDI. Strictly speaking, while games run faster under DirectX, it’s usually quicker to write the tools used to build the game using good ol’ Windows and the GDI. The tools themselves rarely need the performance achievable with DirectX, and the incredible richness of the GDI API makes it simple and quick to produce the tools. It is now common for games to include some of the tools used in its creation, such as level editors. However, today’s incredibly fast processors and Windows accelerated video cards are making this speed issue less of a problem. Although many would argue that a commercial quality game could not be accomplished using standard GDI techniques, several commercial and shareware games have been successfully created using nothing more than an intelligent application of GDI programming techniques. Figure 3-1:  Games using GDI techniques Earthworm Jim for Windows 95 by Activision Pitfall: The Mayan Adventure by Activision Mission:Moon by Beckett Interactive Later in the chapter, we’ll explore how Delphi and the TCanvas class unlock the power of the GDI and make it incredibly easy for the application developer to take advantage of some very powerful graphics programming techniques. First, however, we need to cover a number of concepts that are critical to understanding graphics programming. Graphical Elements To begin exploring the topic of graphics programming, one must be familiar with a number of terms that describe various graphical elements. Like any specialty, graphics programming has its share of jargon, much of which will be discovered throughout the pages of this book. However, there are several terms that describe concepts in just about every application of graphics programming. These are: the pixel, the line, polygons, and bitmaps. Pixels When the GDI displays an image to the screen, whether it’s an application window, a button, text, etc., it draws the graphic in a series of different colored dots. As these dots are drawn to the screen, they eventually form an image that is recognizable to the user. This dot is called a pixel, and it is the smallest graphic that can be drawn to the screen. This action of “drawing” individual colored dots to the computer screen happens so fast (usually) that it appears instantaneous to the viewer. pixel: The smallest, single element in a graphical image or on the display surface. The entire computer screen can be thought of as a grid of dots, or pixels. The size of this grid determines the video mode resolution, and the number of colors in which an individual pixel can be drawn determines the color depth (more on this later). Figure 3-2:  The screen is composed of dots, or pixels 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.

Wyszukiwarka

Podobne podstrony:
TI 03 01 22 T pl(1)
ZL1 03 01
514[03] 01 121 Karta pracy egzaminacyjnej
514[03] 01 121 Arkusz egzaminacyjny
Profilaktyka uzalenien w szkole (03 01 2011)
2016 03 01 zm listy 160301(1)
2007 03 01
TI 03 01 23 T B pl(1)
03 01 W
03 01 2013
PM4 03 01
TI 03 01 10 B pl(1)
pdme 2016 03 01
03 01 25 pra

więcej podobnych podstron