Tables of Contents for The Zen of Direc3d Game Programming
Part 1 Learning The Ropes
1
48
Introduction to Direct3D and DirectX
3
20
What Exactly Is DirectX?
5
7
And Then There Was DirectX
10
2
How Does Direct3D Fit In?
12
9
Immediate Mode vs. Retained Mode
13
1
90 Percent Preparation, 10 Percent Initialization
23
14
Installing the DirectX SDK
24
1
Setting Up Visual Studio to Use DirectX
25
3
Creating a New Project
28
3
Adding a File to Your Project
30
1
Setting Up Your Project to Use DirectX
31
1
Compiling and Executing
32
1
Adding a Little Structure to Your Life
33
1
The Structure of a Direct3D Application
37
12
Interface with Windows
40
1
Update Character Positions
41
1
Part Two: Windows Programming
49
164
Did Not Have a Relationship with MS Windows
51
16
The Importance of Windows
53
1
Nice Programs Share Their Toys
54
3
Events: A New Style of Programming
61
1
Don't Shoot the Messenger
62
3
Your First Windows Program
68
2
The Message Box[] Function
74
3
Relax---It's Only Nine Function Calls
83
1
A Walk through WinMain[]
84
10
Your Variables: A Handle, a Message, and a Touch of Class
85
9
Registering the Window Class
94
1
Displaying the Window
100
1
The Return Value Returns!
104
1
A Stroll through WndProc[]
105
3
Letting Windows Take Care of It
111
4
Turning an Application into a Game
115
3
Getting Jiggy with Windows
119
94
Obtaining the Device Context
121
1
Code Blue! Calling Dr. da Vinci
125
11
Oh, That Is So Picasso!
136
14
Getting Advanced with the Device Context
150
6
A Natural at Resources
169
2
A Menu Fit for a King
171
2
Gluing the Menu to the Window
173
2
Handling Keyboard Input: Windows Way
175
6
Don't Get Asynchronous on Me
178
3
Don't Sync Out on Me, Man
184
2
Asynchronous Graphics
186
1
Advanced Rendering Using Raster Operations
187
2
Some Meandering Thoughts on Zong
211
1
Part Three 2D Directx Graphics
213
200
How Many Lines of Code?
215
90
Microsoft And The Infinite Wisdom
216
2
Pixels and Resolution: Give Me the Pitch
218
9
The 2D Rendering Process
219
5
A Bit about Display Modes
224
1
Getting Your Hands Dirty
229
25
The Direct3D Include Files
230
1
Getting Ready to Rock---Initializing Direct3D
230
2
Setting Up the Surfaces
232
6
Shutting Down DirectX
247
7
Moving to Full Screen
254
5
Rendering with Direct3D
259
8
Getting in the Back Door
260
7
Bitmaps: The Direct3D Way
272
4
Copying Surfaces to the Back Buffer
276
8
Using the GDI with Direct3D Surface
284
16
Creating a Direct3D-Compatible Device Context
285
2
Deleting the Compatible DC from Memory
287
1
Copying a DC to a Direct3D Surface
288
12
Putting Direct3D to Work
305
66
Color-Keyed Surface Copying
306
6
Keeping Track of Time
312
10
Timing Back in the Old Days
313
1
64-Bit High Precision Timers
315
3
Using Precision Timing to Control Execution Speed
318
2
Tracking the Frame Rate
320
2
Developing a 2D Font Engine
322
12
ASCII Codes and Your Source Alphabet
323
8
Printing Multiple Characters to the Screen
331
1
Start Up that Engine!
332
2
Developing a 2D Sprite Engine
334
21
Sprite Class Definition
336
3
Sprite Initialization
339
5
Advanced Sprite Topics
353
2
Getting Down with Layers
355
15
California-Style Consoles
371
42
Implementing the Console
374
2
Adding Text to the Entry
379
4
Getting Down with CConsole
383
7
Console Initialization
390
11
Outputting Strings to the Console
395
1
Setting Up the External Parsing Callback
397
1
Preparsing Raw Strings into Command Parameters
398
3
Plugging the Console into the Game Engine
401
4
Programming the Command Parser
408
4
Commands with No Parameters
409
1
Commands with Parameters
409
3
Part Four 3D Mathematics
413
326
Getting Jiggy with Philosophy
417
1
Representing the Universe with Numbers
418
6
Moving to the Third Dimension
428
2
Geometric Transformations
430
9
Rollin' with Rotation
434
5
What's the Vector, Victor?
441
10
The Magnitude of a Vector
443
1
Vector Multiplication---The Scalar Way
446
1
Vector Multiplication---The Dot Way
447
2
Vector Multiplication---The Cross Way
449
1
Matrices---Which Pill to Take?
451
7
Matrix Scalar Multiplication
454
1
Matrix Multiplication (Real Man's Multiplication)
454
2
Put Down the Gun, Step Away from the Coax Connection, and Identify Yourself
456
1
Applying Matrices to 3D Transformations
458
3
The Transformation Pipeline
461
1
The Local to World Transform
461
1
The World to Camera Transform
462
1
The Camera to Projection Transform
462
1
The Painter's Algorithm
465
1
Getting to Know Direct3D in a More 3D Sort of Way
475
56
Getting Back to the Setup Code
476
10
Getting Down with WinMain[]
479
3
Shutting Down with GameShutdown[]
484
1
Getting the GameLoop[] Going
485
1
Rendering with Render[]
485
1
Constructing a 3D Graphics Engine: The Basics
486
19
Setting up the Flexible Vertex Format
487
3
Getting Jiggy with the Vertex Buffer
490
5
Rendering the Triangle
495
10
Animation with Matrices
505
9
Modifying the Vertex Structure
505
1
Setting Up the Viewport
506
2
Setting Up the Projection Matrix
508
2
Setting the Camera Position with the View Matrix
510
2
Animating the Triangle with the World Matrix
512
1
Disabling Culling and Lighting
513
1
Turning on the Lights
514
8
Defining Vertex Normals
515
3
Enabling Light Indices
518
1
Setting Up Lights with D3DLIGHT8
518
2
Creating a Texture from a File
526
2
Building the Zen 3D Engine
531
58
Getting a Permanent Vertex Format...Finally!
532
4
Creating a Base Game Object
536
2
Encapsulating the View Matrix
538
5
Creating a Point Object
544
5
Putting Points to Work
549
2
Ask No Questions, See No Lines
551
4
Getting Classy with Lines
551
2
The CZenLineList Class
557
4
Setting Vertex Properties
571
1
Rendering Textured Faces
572
2
Rendering Cubes with Indexed Vertices
575
12
Directing Input with DirectInput
589
24
DirectInput Components
592
1
Implementing DirectInput
593
19
Setting Up DirectInput
593
1
The Code---Initialization and Release
594
1
Coding for the Keyboard
595
9
Programming the Mouse
604
7
The State of the Union
611
1
Encapsulating Materials into CZenMaterial
615
4
Loading External 3D Models
619
15
Dealing with the Devil: Conv3DS.exe
620
1
The Holy Grail: CZenMesh
623
11
Introduction to Frames
634
15
The Right Frame of Mind
635
2
Modifying the Zen Engine to Use Frames
637
3
Updating Lights with Direct3D
654
2
Advanced Synchronization
657
2
Extending the Camera
659
20
Creating the View Matrix...the Hard Way
667
10
Oh, Yes---Connecting the Camera to DirectInput
677
2
Advanced Graphics Techniques
701
38
Developing an Advanced Frame-Based Hierarchy System
702
15
Dealing with Additive Transformations
709
2
Rendering with Frame Trees and Object Lists
711
2
Programming Pluggable Frame Behavior Modification Routines
713
4
Bringing Structure to the Zen Engine
717
2
Everything in Action...Finally!
719
5
Bilinear Filtering and Scene Anti-Aliasing
724
2
Using the Direct3D Texture Utility to Create Advanced Textures
726
3
Using Custom Mouse Cursors
729
8
Positioning the Mouse
733
2
Updating the Cursor Position
735
1
Using CZenMouse and the Custom Cursor
736
1
Part Five Appendices
739
103
Appendix A C++ Programming 101
741
30
C, C++: What's the Difference?
742
1
The Basics of Implementing C++
746
1
Passing Variables by Reference
750
1
Streaming Input and Output
751
3
Data Representation in the Dark Ages
755
1
Accessing Class Data Elements
756
2
Constructors and Destructors
760
4
Function and Operator Overloading
768
2
Appendix B Direct 3D Advanced Reference
771
71
IDirect3DIndexBuffer8
831
2
IDirect3DVertexBuffer8
840
2