| Introduction |
|
xxvii | |
| Part 1 Learning The Ropes |
|
1 | (48) |
|
Introduction to Direct3D and DirectX |
|
|
3 | (20) |
|
|
|
5 | (7) |
|
|
|
9 | (1) |
|
And Then There Was DirectX |
|
|
10 | (2) |
|
How Does Direct3D Fit In? |
|
|
12 | (9) |
|
Immediate Mode vs. Retained Mode |
|
|
13 | (1) |
|
|
|
14 | (1) |
|
|
|
15 | (5) |
|
|
|
20 | (1) |
|
|
|
20 | (1) |
|
|
|
21 | (2) |
|
90 Percent Preparation, 10 Percent Initialization |
|
|
23 | (14) |
|
Installing the DirectX SDK |
|
|
24 | (1) |
|
Setting Up Visual Studio to Use DirectX |
|
|
25 | (3) |
|
|
|
28 | (3) |
|
Adding a File to Your Project |
|
|
30 | (1) |
|
Setting Up Your Project to Use DirectX |
|
|
31 | (1) |
|
|
|
32 | (1) |
|
|
|
33 | (2) |
|
Adding a Little Structure to Your Life |
|
|
33 | (1) |
|
|
|
34 | (1) |
|
|
|
35 | (1) |
|
|
|
35 | (2) |
|
The Structure of a Direct3D Application |
|
|
37 | (12) |
|
|
|
38 | (6) |
|
|
|
40 | (1) |
|
|
|
40 | (1) |
|
|
|
40 | (1) |
|
|
|
41 | (1) |
|
Update Character Positions |
|
|
41 | (1) |
|
|
|
41 | (1) |
|
|
|
42 | (1) |
|
|
|
42 | (1) |
|
|
|
43 | (1) |
|
|
|
43 | (1) |
|
|
|
44 | (3) |
|
|
|
47 | (2) |
| 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) |
|
|
|
57 | (4) |
|
|
|
59 | (2) |
|
Events: A New Style of Programming |
|
|
61 | (1) |
|
Don't Shoot the Messenger |
|
|
62 | (3) |
|
|
|
65 | (2) |
|
|
|
67 | (14) |
|
Your First Windows Program |
|
|
68 | (2) |
|
|
|
70 | (1) |
|
|
|
71 | (3) |
|
The Message Box[] Function |
|
|
74 | (3) |
|
|
|
77 | (1) |
|
|
|
78 | (1) |
|
|
|
79 | (2) |
|
|
|
81 | (38) |
|
|
|
82 | (1) |
|
Relax---It's Only Nine Function Calls |
|
|
83 | (1) |
|
|
|
84 | (10) |
|
Your Variables: A Handle, a Message, and a Touch of Class |
|
|
85 | (9) |
|
Registering the Window Class |
|
|
94 | (1) |
|
|
|
94 | (6) |
|
|
|
100 | (1) |
|
|
|
101 | (3) |
|
|
|
102 | (1) |
|
|
|
103 | (1) |
|
|
|
104 | (1) |
|
The Return Value Returns! |
|
|
104 | (1) |
|
A Stroll through WndProc[] |
|
|
105 | (3) |
|
|
|
108 | (7) |
|
|
|
109 | (1) |
|
|
|
109 | (1) |
|
|
|
110 | (1) |
|
Letting Windows Take Care of It |
|
|
111 | (4) |
|
Turning an Application into a Game |
|
|
115 | (3) |
|
|
|
118 | (1) |
|
Getting Jiggy with Windows |
|
|
119 | (94) |
|
|
|
120 | (5) |
|
Obtaining the Device Context |
|
|
121 | (1) |
|
|
|
122 | (2) |
|
|
|
124 | (1) |
|
Code Blue! Calling Dr. da Vinci |
|
|
125 | (11) |
|
|
|
126 | (2) |
|
|
|
128 | (2) |
|
|
|
130 | (1) |
|
|
|
131 | (1) |
|
|
|
132 | (4) |
|
|
|
136 | (14) |
|
|
|
136 | (7) |
|
|
|
143 | (7) |
|
Getting Advanced with the Device Context |
|
|
150 | (6) |
|
|
|
156 | (10) |
|
|
|
166 | (2) |
|
|
|
168 | (7) |
|
|
|
169 | (2) |
|
|
|
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) |
|
|
|
181 | (5) |
|
Don't Sync Out on Me, Man |
|
|
184 | (2) |
|
|
|
186 | (1) |
|
|
|
186 | (1) |
|
Advanced Rendering Using Raster Operations |
|
|
187 | (2) |
|
|
|
189 | (23) |
|
|
|
210 | (1) |
|
|
|
210 | (1) |
|
|
|
211 | (1) |
|
Some Meandering Thoughts on Zong |
|
|
211 | (1) |
|
|
|
212 | (1) |
| Part Three 2D Directx Graphics |
|
213 | (200) |
|
|
|
215 | (90) |
|
Microsoft And The Infinite Wisdom |
|
|
216 | (2) |
|
Pixels and Resolution: Give Me the Pitch |
|
|
218 | (9) |
|
|
|
219 | (5) |
|
A Bit about Display Modes |
|
|
224 | (1) |
|
|
|
225 | (2) |
|
|
|
227 | (2) |
|
|
|
229 | (25) |
|
The Direct3D Include Files |
|
|
230 | (1) |
|
Getting Ready to Rock---Initializing Direct3D |
|
|
230 | (2) |
|
|
|
232 | (6) |
|
|
|
238 | (4) |
|
|
|
242 | (5) |
|
|
|
247 | (7) |
|
|
|
254 | (5) |
|
|
|
259 | (8) |
|
|
|
260 | (7) |
|
|
|
267 | (17) |
|
|
|
267 | (2) |
|
|
|
269 | (3) |
|
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) |
|
|
|
300 | (4) |
|
|
|
304 | (1) |
|
|
|
305 | (66) |
|
Color-Keyed Surface Copying |
|
|
306 | (6) |
|
|
|
312 | (10) |
|
Timing Back in the Old Days |
|
|
313 | (1) |
|
|
|
313 | (2) |
|
64-Bit High Precision Timers |
|
|
315 | (3) |
|
Using Precision Timing to Control Execution Speed |
|
|
318 | (2) |
|
|
|
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) |
|
|
|
332 | (2) |
|
Developing a 2D Sprite Engine |
|
|
334 | (21) |
|
|
|
336 | (3) |
|
|
|
339 | (5) |
|
|
|
344 | (1) |
|
|
|
345 | (2) |
|
|
|
347 | (6) |
|
|
|
353 | (2) |
|
|
|
355 | (15) |
|
|
|
357 | (13) |
|
|
|
370 | (1) |
|
California-Style Consoles |
|
|
371 | (42) |
|
|
|
372 | (2) |
|
|
|
374 | (2) |
|
|
|
376 | (7) |
|
|
|
379 | (4) |
|
Getting Down with CConsole |
|
|
383 | (7) |
|
|
|
390 | (11) |
|
|
|
393 | (2) |
|
Outputting Strings to the Console |
|
|
395 | (1) |
|
|
|
395 | (1) |
|
|
|
396 | (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) |
|
|
|
401 | (2) |
|
|
|
403 | (2) |
|
|
|
405 | (3) |
|
Programming the Command Parser |
|
|
408 | (4) |
|
Commands with No Parameters |
|
|
409 | (1) |
|
|
|
409 | (3) |
|
|
|
412 | (1) |
| Part Four 3D Mathematics |
|
413 | (326) |
|
|
|
415 | (60) |
|
|
|
416 | (8) |
|
Getting Jiggy with Philosophy |
|
|
417 | (1) |
|
Representing the Universe with Numbers |
|
|
418 | (6) |
|
|
|
424 | (4) |
|
Moving to the Third Dimension |
|
|
428 | (2) |
|
Geometric Transformations |
|
|
430 | (9) |
|
|
|
430 | (1) |
|
|
|
431 | (3) |
|
|
|
434 | (5) |
|
|
|
439 | (2) |
|
What's the Vector, Victor? |
|
|
441 | (10) |
|
|
|
442 | (1) |
|
The Magnitude of a Vector |
|
|
443 | (1) |
|
|
|
444 | (1) |
|
|
|
445 | (1) |
|
Vector Multiplication---The Scalar Way |
|
|
446 | (1) |
|
Vector Multiplication---The Dot Way |
|
|
447 | (2) |
|
Vector Multiplication---The Cross Way |
|
|
449 | (1) |
|
|
|
450 | (1) |
|
Matrices---Which Pill to Take? |
|
|
451 | (7) |
|
|
|
452 | (1) |
|
|
|
453 | (1) |
|
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) |
|
|
|
457 | (1) |
|
|
|
457 | (1) |
|
Applying Matrices to 3D Transformations |
|
|
458 | (3) |
|
|
|
458 | (1) |
|
|
|
459 | (1) |
|
|
|
460 | (1) |
|
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) |
|
|
|
462 | (1) |
|
|
|
463 | (2) |
|
|
|
465 | (2) |
|
|
|
465 | (1) |
|
|
|
466 | (1) |
|
|
|
467 | (4) |
|
|
|
468 | (1) |
|
|
|
468 | (1) |
|
|
|
469 | (1) |
|
|
|
469 | (1) |
|
|
|
470 | (1) |
|
|
|
471 | (2) |
|
|
|
473 | (2) |
|
Getting to Know Direct3D in a More 3D Sort of Way |
|
|
475 | (56) |
|
Getting Back to the Setup Code |
|
|
476 | (10) |
|
|
|
476 | (1) |
|
|
|
477 | (1) |
|
|
|
477 | (2) |
|
Getting Down with WinMain[] |
|
|
479 | (3) |
|
|
|
482 | (2) |
|
Shutting Down with GameShutdown[] |
|
|
484 | (1) |
|
Getting the GameLoop[] Going |
|
|
485 | (1) |
|
|
|
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) |
|
|
|
495 | (10) |
|
|
|
505 | (9) |
|
Modifying the Vertex Structure |
|
|
505 | (1) |
|
|
|
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) |
|
|
|
514 | (8) |
|
|
|
515 | (3) |
|
|
|
518 | (1) |
|
Setting Up Lights with D3DLIGHT8 |
|
|
518 | (2) |
|
|
|
520 | (2) |
|
|
|
522 | (7) |
|
|
|
523 | (3) |
|
Creating a Texture from a File |
|
|
526 | (2) |
|
|
|
528 | (1) |
|
|
|
529 | (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) |
|
|
|
540 | (2) |
|
|
|
542 | (1) |
|
|
|
542 | (1) |
|
|
|
543 | (8) |
|
|
|
544 | (5) |
|
|
|
549 | (2) |
|
Ask No Questions, See No Lines |
|
|
551 | (4) |
|
Getting Classy with Lines |
|
|
551 | (2) |
|
|
|
553 | (1) |
|
|
|
554 | (1) |
|
|
|
555 | (10) |
|
|
|
557 | (4) |
|
|
|
561 | (4) |
|
|
|
565 | (3) |
|
|
|
568 | (7) |
|
|
|
569 | (2) |
|
Setting Vertex Properties |
|
|
571 | (1) |
|
|
|
572 | (2) |
|
|
|
574 | (1) |
|
Rendering Cubes with Indexed Vertices |
|
|
575 | (12) |
|
|
|
577 | (1) |
|
|
|
578 | (8) |
|
|
|
586 | (1) |
|
|
|
587 | (2) |
|
Directing Input with DirectInput |
|
|
589 | (24) |
|
|
|
590 | (3) |
|
|
|
590 | (1) |
|
|
|
591 | (1) |
|
|
|
592 | (1) |
|
|
|
593 | (19) |
|
|
|
593 | (1) |
|
The Code---Initialization and Release |
|
|
594 | (1) |
|
|
|
595 | (9) |
|
|
|
604 | (7) |
|
|
|
611 | (1) |
|
|
|
612 | (1) |
|
|
|
613 | (88) |
|
Encapsulating Materials into CZenMaterial |
|
|
615 | (4) |
|
Loading External 3D Models |
|
|
619 | (15) |
|
Dealing with the Devil: Conv3DS.exe |
|
|
620 | (1) |
|
|
|
621 | (2) |
|
|
|
623 | (11) |
|
|
|
634 | (15) |
|
|
|
635 | (2) |
|
Modifying the Zen Engine to Use Frames |
|
|
637 | (3) |
|
|
|
640 | (9) |
|
|
|
649 | (8) |
|
|
|
650 | (2) |
|
|
|
652 | (1) |
|
|
|
653 | (1) |
|
Updating Lights with Direct3D |
|
|
654 | (2) |
|
|
|
656 | (1) |
|
|
|
656 | (1) |
|
|
|
657 | (2) |
|
|
|
659 | (20) |
|
|
|
661 | (6) |
|
Creating the View Matrix...the Hard Way |
|
|
667 | (10) |
|
Oh, Yes---Connecting the Camera to DirectInput |
|
|
677 | (2) |
|
|
|
679 | (20) |
|
|
|
679 | (6) |
|
|
|
685 | (9) |
|
|
|
694 | (5) |
|
|
|
699 | (2) |
|
Advanced Graphics Techniques |
|
|
701 | (38) |
|
Developing an Advanced Frame-Based Hierarchy System |
|
|
702 | (15) |
|
|
|
703 | (4) |
|
|
|
707 | (2) |
|
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) |
|
|
|
732 | (1) |
|
|
|
733 | (2) |
|
Updating the Cursor Position |
|
|
735 | (1) |
|
Using CZenMouse and the Custom Cursor |
|
|
736 | (1) |
|
|
|
737 | (2) |
| Part Five Appendices |
|
739 | (103) |
|
Appendix A C++ Programming 101 |
|
|
741 | (30) |
|
C, C++: What's the Difference? |
|
|
742 | (1) |
|
|
|
743 | (1) |
|
|
|
744 | (1) |
|
|
|
745 | (1) |
|
The Basics of Implementing C++ |
|
|
746 | (1) |
|
|
|
746 | (1) |
|
|
|
747 | (1) |
|
|
|
748 | (2) |
|
Passing Variables by Reference |
|
|
750 | (1) |
|
Streaming Input and Output |
|
|
751 | (3) |
|
|
|
754 | (1) |
|
|
|
754 | (1) |
|
Data Representation in the Dark Ages |
|
|
755 | (1) |
|
|
|
755 | (1) |
|
Accessing Class Data Elements |
|
|
756 | (2) |
|
|
|
758 | (2) |
|
Constructors and Destructors |
|
|
760 | (4) |
|
|
|
764 | (2) |
|
|
|
766 | (2) |
|
Function and Operator Overloading |
|
|
768 | (2) |
|
|
|
770 | (1) |
|
Appendix B Direct 3D Advanced Reference |
|
|
771 | (71) |
|
|
|
772 | (1) |
|
|
|
772 | (1) |
|
|
|
773 | (1) |
|
|
|
773 | (8) |
|
|
|
781 | (50) |
|
|
|
831 | (2) |
|
|
|
833 | (4) |
|
|
|
837 | (3) |
|
|
|
840 | (2) |
| Index |
|
842 | |