Advanced 3D Game Programming Using DirectX 9.0
BierBak
Advanced 3D Game Programming with DirectX 9.0
Introduction
Advanced 3D Game Programming with DirectX 9.0
by Peter Walsh
Wordware Publishing © 2003
Companion Web Site

Advanced 3D Game Programming Using DirectX 9.0

Peter Walsh

Wordware Publishing, Inc.

Library of Congress Cataloging-in-Publication Data

Walsh, Peter (Peter Andrew), 1980-
Advanced 3D game programming with DirectX 9.0 / by Peter Walsh.
p. cm.
ISBN 1-55622-968-2 (pbk.)
1. Computer games–Programming. 2. DirectX. I. Title.
QA76.76.C672W382 2003
794.8'167768–dc21 2003007140
CIP

All Rights Reserved

2320 Los Rios Boulevard
Plano, Texas 75074

No part of this book may be reproduced in any form or by any means without permission in writing from Wordware Publishing, Inc.

1-55622-968-2

10 9 8 7 6 5 4 3 2 1
0403

DirectX is a registered trademark of Microsoft Corporation in the United States and/or other countries.

All brand names and product names mentioned in this book are trademarks or service marks of their respective companies. Any omission or misuse (of any kind) of service marks or trademarks should not be regarded as intent to infringe on the property of others. The publisher recognizes and respects all marks used by companies, manufacturers, and developers as a means to distinguish their products.

All inquiries for volume purchases of this book should be addressed to Wordware Publishing, Inc., at the above address. Telephone inquiries may be made by calling:
(972) 423-0090

Dedications

To my beautiful fiancée Lisa Sullivan
I love you with all my heart.

Peter

To my parents, Manny and Maria

Adrian

Original edition for DirectX version 7.0 written by Adrian Perez with Dan Royer. Revised and updated by Peter Walsh.

Acknowledgments

Like Adrian says below, this book, like any other, was not just the work of one (or two or three) people; there have been so many people over the years who have helped me in one way or another, and the result of all these efforts contributed to the knowledge contained in this book. I will try to thank everyone I can. My update of this book would not have occurred without the help of Tracy Williams, who has helped me many times with my books. Not only did she get me going on my first book, but she got me hooked up with Wordware for this book, my third. Of course, I must thank Jim Hill, Wes Beckwith, and Tim McEvoy of Wordware for being such great people to work with.

Thanks to Phil Taylor on the DirectX team at Microsoft for agreeing to do the tech check and also to Wolfgang Engel and Bruno Sousa for their technical support. Of course, thank you to my wonderful fiancee Lisa for helping to keep me motivated while working on the book, when I just wanted to give up and party!

Where would I be without thanking all my friends and family, who keep me sane during the many months that I spent researching and writing these massive books. So thank you Jon-Paul Keatley, Stewart Wright, Andrew McCall, Todd Fay, Mike Andrews, Laz Allen, and all my other friends around the world that I don't have room to list! Also, who would I be writing a book and not mentioning my soon-to-be family-in-law? So thank you Liam and Ann Sullivan for giving me permission to marry your beautiful daughter (also to Joanne, Pauline, Liam Jr., and the rest of the family). Of course, thanks to my parents Simon and Joy Walsh for being so supportive during my younger years and to this day.

The worst thing about writing acknowledgments is that you always forget someone who helped you until the day the book goes to print. So thank you to everyone else I forgot—please accept my apologies; my poor brain is worn out after all this work!

Peter Walsh

This book couldn't have been completed without the help and guidance of a whole lot of people. I'll try to remember them all here. First, thanks to Wes Beckwith and Jim Hill at Wordware Publishing. They were extremely forgiving of my hectic schedule, and they helped guide me to finishing this book. I also must thank Alex Dunne for letting me write an article in 1998 for Game Developer magazine. If I hadn't written that article, I never would have written this book.

Everything I know about the topics in this book I learned from other people. Some of these people were mentors, others were bosses, and still others were professors and teachers. Some were just cool people who took the time to sit and talk with me. I can't thank them enough. Paul Heckbert, Tom Funkhouser, Eric Petajan, Charles Boyd, Mike Toelle, Kent Griffin, David Baraff, Randy Pausch, Howie Choset, Michael Abrash, Hugues Hoppe, and Mark Stehlik: You guys rock. Thank you.

Thanks to Microsoft, ATI, nVidia, id Software, and Lydia Choy for helping me with some of the images used in the text.

Many people helped assure the technical correctness and general sanity of this text. Ian Parberry and his class at University of North Texas were immensely helpful: Thanks, guys. Michael Krause was an indispensable help in assuring the correctness of the DirectX chapters. Bob Gaines, Mikey Wetzel, and Jason Sandlin from the DirectX team at Microsoft helped make sure Chapters 2, 3, 4, 8, and 10 were shipshape: Mad props to them. David Black was kind enough to look over Chapter 11 and help remove some errors and clarify a few points.

Finally, I need to thank all of the people who helped me get this thing done. I know I won't be able to remember all of them, but here's a short list: Manual and Maria Perez, Katherin Peperzak, Lydia Choy (again), Mike Schuresko, Mike Breen (and the rest of the Originals), Vick Mukherjee, Patrick Nelson, Brian Sharp, and Marcin Krieger.

Adrian Perez

About the author

Peter Walsh is a professional game programmer at Visual Science Ltd., where he has worked on a number of titles including the Formula 1 series of games, Harry Potter and the Chamber of Secrets, and others for Electronic Arts, the world's leading publisher of computer games. He has studied for a degree in computer games development at Abertay University in Dundee, Scotland, and has worked with IC-CAVE, a think tank for the next generation of gaming technology.

The complete source code in C++, including a game demonstrating techniques covered in this book, can be downloaded from http://www.wordware.com/files/dx9.