EBOOK - Beginning DirectX 9 (Wendy Jones - Vngamedev)
Game programming is an exciting job in the computing world. Where else do you get the chance to create virtual worlds that encompass creatures or places normally found only in dreams? You give people the ability to become anyone they want, and provide them with environments that bring their fantasies to life.
The game industry is growing by leaps and bounds, and the technology is expanding right along with it. Just a few years ago, video cards with 3D hardware on the consumer level were unheard of. Only expensive SGI workstations were capable of real-time 3D, and OpenGL were in its infancy. As PCs became more popular, OpenGL was ported to this expanding platform, bringing 3D rendering to the masses for the first time.
Windows was still an unpopular platform for games, but that began to change when Microsoft introduced DirectX. DirectX slowly gained popularity until it surpassed OpenGL as the standard way to create 3D graphics under Windows. Today, most PC games on the market are built on DirectX, enabling gamers to experience the latest graphics technologies and the most realistic worlds.
CONTENTS:
Part I Getting Down the Basics . . . . . . . . . . . . .1
Chapter 1
The What, Why, and How of DirectX. . . . . . . . . . . . . . . . . .3
Chapter 2
Your First DirectX Program. . . . . . . . . . . . . . . . . . . . . . . . . .9
What Is DirectX? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .3
The Components . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4
Why Is DirectX Needed?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .4
How Is DirectX Put Together? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .5
The Component Object Model . . . . . . . . . . . . . . . . . . . . . . . . . . . .6
The Architecture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .6
Chapter Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .7
Creating the Project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .9
Adding the Windows Code . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .11
WinMain .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .12
InitWindow .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .13
WndProc .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .14
Time for DirectX. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16
The Direct3D Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .16
Creating the Rendering Device . . . . . . . . . . . . . . . . . . . . . . . . . . .17
Clearing the Screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .19
Displaying the Scene . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .20
Cleaning Up. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .21
viii
ix Contents
Updating the Code. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .22
Changing the Message Loop. . . . . . . . . . . . . . . . . . . . . . . . . . . .22
The Init Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .23
The Render Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .24
The cleanUp Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25
Adding the DirectX Libraries . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .25
Taking the Game Full Screen . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .27
Video Modes and Formats. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .29
Gathering Video Adapter and Driver Information . . . . . . . . . . . .29
Getting the Display Modes for an Adapter. . . . . . . . . . . . . . . . .30
ACode Example for Querying the Video Adapter . . . . . . . . . . . .32
Chapter Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .34
Chapter 3 Surfaces, Sprites, and Salmon . . . . . . . . . . . . . . . . . . . . . . .35
You’ve Just Touched the Surface . . . . . . . . . . . . . . . . . . . . . . . . . . . . .35
The Display Buffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .36
Offscreen Surfaces. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .36
Loading a Bitmap to a Surface . . . . . . . . . . . . . . . . . . . . . . . . . . .37
Using DirectX to Render a Bitmap. . . . . . . . . . . . . . . . . . . . . . . .39
StretchRect Revisited . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .42
Sprites .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .46
What Do Sprites Need? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .46
Representing a Sprite in Code. . . . . . . . . . . . . . . . . . . . . . . . . . .46
Creating Your First Sprite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .47
Moving Your Sprite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .51
Animating Your Sprite. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .53
Displaying the Animated Sprites. . . . . . . . . . . . . . . . . . . . . . . . .55
Why Is It So Fast?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .57
Timers: How to Animate on Time . . . . . . . . . . . . . . . . . . . . . . . . . . . .57
Timing Under Windows. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .57
Using QueryPerformanceCounter . . . . . . . . . . . . . . . . . . . . . . . .58
Getting the Time for Each Frame . . . . . . . . . . . . . . . . . . . . . . . . .58
Changing the Animation to Be Time Based . . . . . . . . . . . . . . . . .59
Chapter Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .61
Part II It’s a 3D World After All . . . . . . . . . . .63
Chapter 4 3D Primer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .65
3D Space. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .65
Coordinate Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .66
Defining a Point in 2D Space. . . . . . . . . . . . . . . . . . . . . . . . . . . .66
x Contents
Chapter 5
Defining a Point in 3D Space. . . . . . . . . . . . . . . . . . . . . . . . . . . .67
Left-Handed Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .68
Right-Handed Systems. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .68
Vertices Explained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .68
Creating a Shape. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .69
Adding Color. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .70
Vertex Buffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .71
Creating a Vertex Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .71
Flexible Vertex Format. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .72
Loading Data into a Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .74
Drawing the Contents of the Buffer . . . . . . . . . . . . . . . . . . . . . . .78
Primitive Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .82
Point List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .83
Line List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .83
Line Strip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .83
Triangle List . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .83
Triangle Strip . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .84
Triangle Fan . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .85
Chapter Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .85
Matrices, Transforms, and Rotations . . . . . . . . . . . . . . . . . .87
Creating a 3D Model . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .87
Defining the Vertex Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .88
Rendering the Cube. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .91
Index Buffers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .92
Generating a Cube by Using Index Buffers . . . . . . . . . . . . . . . . . .93
Creating and Filling the Index Buffer . . . . . . . . . . . . . . . . . . . . . .94
The Geometry Pipeline. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .97
World Transformation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .98
View Transformation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .98
Projection Transformation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .98
What Is a Matrix?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .99
The Identity Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .100
Initializing a Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .100
Multiply Matrices. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .101
How Direct3D Defines a Matrix. . . . . . . . . . . . . . . . . . . . . . . . .102
D3DX Makes Matrices Easier . . . . . . . . . . . . . . . . . . . . . . . . . . . .102
Manipulating 3D Objects by Using Matrices . . . . . . . . . . . . . . . . . . .104
Moving an Object Around. . . . . . . . . . . . . . . . . . . . . . . . . . . . .104
Rotating an Object . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .105
Center of Rotation. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .108
xi Contents
Chapter 6
Scaling.. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .110
Order of Matrix Operations. . . . . . . . . . . . . . . . . . . . . . . . . . . .111
Creating a Camera by Using Projections . . . . . . . . . . . . . . . . . . . . . .112
Positioning and Pointing the Camera . . . . . . . . . . . . . . . . . . . . .113
Chapter Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .115
Vertex Colors, Texture Mapping, and 3D Lighting. . . . . .117
Changing the Color of an Object. . . . . . . . . . . . . . . . . . . . . . . . . . .117
Vertex Colors Revisited . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .118
Color Macros . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .119
Shading .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .119
Flat Shading. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .120
Gouraud Shading. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .121
Choosing the Shading Mode. . . . . . . . . . . . . . . . . . . . . . . . . . .121
Fill Mode . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .122
Lighting Explained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .124
Lighting Types . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .124
Ambient Light . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .124
Directional Lights. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .125
Point Lights . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .125
Spotlights .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .126
Light Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .127
Creating Lights in a Scene . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .128
Creating an Ambient Light . . . . . . . . . . . . . . . . . . . . . . . . . . . . .129
Creating a Directional Light . . . . . . . . . . . . . . . . . . . . . . . . . . . .130
Creating a Point Light . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .131
Creating a Spotlight . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .132
Materials Explained . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .134
Diffuse Reflection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .134
Ambient Reflection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .134
Specular Reflection . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .134
Emission .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .135
How Materials Are Used . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .135
Specular Highlights . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .136
Texture Mapping . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .136
How Direct3D Uses Textures . . . . . . . . . . . . . . . . . . . . . . . . . . . .137
How Textures Are Applied. . . . . . . . . . . . . . . . . . . . . . . . . . . . .137
Texture Coordinates. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .138
Texture Stages . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .139
Texture Stage States . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .139
xii Contents
Chapter 7
Chapter 8
Part III
Loading a Texture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .139
Applying a Texture. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .142
Chapter Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .145
Meshes .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .147
Creating a 3D World . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .147
What Is a Mesh?. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .148
How Direct3D Defines a Mesh. . . . . . . . . . . . . . . . . . . . . . . . . . . . .148
Creating a Mesh. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .148
Filling the Mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .151
Displaying a Mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .154
Optimizing a Mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .155
Predefined Meshes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .162
D3DX Object Creation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .163
The Direct3D Mesh Format: The X File . . . . . . . . . . . . . . . . . . . .168
Saving a Mesh to an X File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .169
D3DXSaveMeshToX .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .169
Loading a Mesh from an X File . . . . . . . . . . . . . . . . . . . . . . . . . . . . .172
Using the D3DXLoadMeshFromX Function . . . . . . . . . . . . . . . . .172
Chapter Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .175
Point Sprites, Particles, and Pyrotechnics. . . . . . . . . . . . .177
Particles .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .177
Particle Properties . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .178
The Particle Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .178
How Are the Particles Created?. . . . . . . . . . . . . . . . . . . . . . . . .179
How Do the Particles Move? . . . . . . . . . . . . . . . . . . . . . . . . . . . .180
Particle Systems . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .182
Designing a Particle System. . . . . . . . . . . . . . . . . . . . . . . . . . . .182
Coding a Particle System Manager . . . . . . . . . . . . . . . . . . . . . . .184
Point Sprites: Making Particles Easy. . . . . . . . . . . . . . . . . . . . . . . . .193
Using Point Sprites in Direct3D . . . . . . . . . . . . . . . . . . . . . . . . . .193
How to Use Point Sprites. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .194
Chapter Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .197
Additional Needs . . . . . . . . . . . . . . . . .199
Chapter 9 Using DirectInput . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .201
INeed Input. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .201
Using DirectInput. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .203
Creating the DirectInput Object . . . . . . . . . . . . . . . . . . . . . . . . .204
Contents xiii
Chapter 10
Chapter 11
Creating the DirectInput Device . . . . . . . . . . . . . . . . . . . . . . . . .205
Setting the Data Format . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .206
Setting the Cooperative Level . . . . . . . . . . . . . . . . . . . . . . . . . .207
Acquiring Access . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .209
Getting Input. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .209
Enumerating Input Devices . . . . . . . . . . . . . . . . . . . . . . . . . . . . .210
Getting the Device Capabilities. . . . . . . . . . . . . . . . . . . . . . . . .214
Getting Input from a Keyboard. . . . . . . . . . . . . . . . . . . . . . . . .216
Getting Input from a Mouse . . . . . . . . . . . . . . . . . . . . . . . . . . . .217
Using a Gamepad or Joystick. . . . . . . . . . . . . . . . . . . . . . . . . . .221
Supporting Multiple Input Devices . . . . . . . . . . . . . . . . . . . . . . .226
Reacquiring an Input Device . . . . . . . . . . . . . . . . . . . . . . . . . . . .228
Cleaning Up DirectInput . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .229
Force Feedback. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .230
Force Feedback Effects. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .230
Enumerating the Input Devices for Force Feedback . . . . . . . . . .231
Creating a Force Feedback Effect . . . . . . . . . . . . . . . . . . . . . . . .232
Starting an Effect. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .235
Stopping an Effect. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .235
Chapter Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .236
DirectSound .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .237
Sound .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .237
DirectSound .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .238
How Does DirectSound Work? . . . . . . . . . . . . . . . . . . . . . . . . . .238
Using DirectSound. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .239
Sound Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .244
The Secondary Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .244
Creating a Secondary Buffer . . . . . . . . . . . . . . . . . . . . . . . . . . . .247
Loading a Sound File into a Buffer . . . . . . . . . . . . . . . . . . . . . . .248
Chapter Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .255
The Final Project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .257
Welcome to the Final Project. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .257
Creating the Application Window. . . . . . . . . . . . . . . . . . . . . . . . . .258
WinMain .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .258
initWindow .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .259
WndProc .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .261
Initializing DirectX . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .262
The DirectX Manager. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .262
Hooking in the DirectX Manager . . . . . . . . . . . . . . . . . . . . . . . .264
xiv Contents
Coding the Demo. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .266
The Game Application Class . . . . . . . . . . . . . . . . . . . . . . . . . . . .266
Creating the Game Timer . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .267
Hooking the Game Application into WinMain . . . . . . . . . . . . . .268
Adding Objects to the World. . . . . . . . . . . . . . . . . . . . . . . . . . . . . .270
The CGameObject Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .271
The CModel Class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .272
The Game Object List. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .276
Creating the Planet . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .277
The CPlanet Class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .277
Adding the Planet to the Scene . . . . . . . . . . . . . . . . . . . . . . . . .280
Adding a Spaceship . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .281
Moving in the Universe . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .283
The Spaceship Move Function . . . . . . . . . . . . . . . . . . . . . . . . . .283
Bringing in DirectInput . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .285
Releasing Your Creation to the World. . . . . . . . . . . . . . . . . . . . . . .288
Packaging Your Game for Release. . . . . . . . . . . . . . . . . . . . . . .288
What Tools Are Available to Bundle My Game? . . . . . . . . . . . . .289
The DirectX Runtime . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .289
Shipping the DirectX Runtime with Your Game . . . . . . . . . . . . .289
Installing the DirectX Runtime . . . . . . . . . . . . . . . . . . . . . . . . . .290
Chapter Summary. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .292
Part IV Appendixes . . . . . . . . . . . . . . . . . . . . . .293
Appendix A
Answers to End-of-Chapter Exercises . . . . . . . . . . . . . . . .295
. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .311 Appendix B
Using the CD-ROM
What’s on the CD-ROM . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .311
Installing the DirectX SDK . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .311
Glossary .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .315
Index .. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . .318
LƯU Ý:
Tài liệu được đóng góp bởi CTV "Mân Trần Lê" chỉ được sử dụng phục vụ cho mục đích học tập và nghiên cứu.
BUY THIS EBOOK ON AMAZON (BEST SELLING)



Không có nhận xét nào: