Advanced 3D Game Programming with 10.0 Peter Walsh Wordware Publishing, Inc... Library of Congress Cataloging-in-Publication DataWalsh, Peter, 1980-Advanced 3D game programming with Dire
Trang 2Advanced 3D Game Programming with
10.0
Peter Walsh
Wordware Publishing, Inc.
Trang 3Library of Congress Cataloging-in-Publication Data
Walsh, Peter,
1980-Advanced 3D game programming with DirectX 10.0 / by Peter Walsh
p cm
Includes index
ISBN 10: 1-59822-054-3
ISBN 13: 978-1-59822-054-4
1 Computer games Programming 2 DirectX I Title
QA76.76.C672W3823 2007
794.8'1526 dc22
2007041625
© 2008, Wordware Publishing, Inc.
All Rights Reserved
1100 Summit Avenue, Suite 102 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.
Printed in the United States of America
ISBN 10: 1-59822-054-3
ISBN 13: 978-1-59822-054-4
10 9 8 7 6 5 4 3 2 1
0712
DirectX is a registered trademark of Microsoft Corporation in the United States and/or other counties
Other 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
This book is sold as is, without warranty of any kind, either express or implied, respecting the contents of this book and any disks or programs that may accompany it, including but not limited to implied warranties for the book’s quality, performance, merchantability, or fitness for any particular purpose Neither Wordware Publishing, Inc nor its dealers or distributors shall be liable to the purchaser or any other person or entity with respect to any liability, loss, or damage caused or alleged to have been caused directly or indirectly by this book
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
Trang 4To my wife, Lisa
Peter
Trang 5This page intentionally left blank.
Trang 6sparse matrix, 410
specular highlight, 181
specular light, 181
specular maps, 452
specular reflection, 182-183
spherical coordinates, calculating, 449-450
spherical environment maps, 446-449
splines, 355
Split() function, 149, 152-153
spotlights, 185-186
sprites, 341
Standard Template Library, see STL
StartListening() function, 267
StartSending() function, 268
Startup() function, 266
static address, 256
steering, 210
algorithms, 211-230
stencil buffer, 325, 483
creating, 302-308
using, 483-484
STL, 517
containers, 518-519
functors, 521
iterators, 519-521
templates, 517-518
structures,
bSphere3, 176-177
color3, 178-180
D3D10_BLEND_DESC, 419-420, 422
D3D10_BUFFER_DESC, 326
D3D10_DEPTH_STENCIL_DESC, 303-304
D3D10_DEPTH_STENCIL_VIEW_DESC,
305-306
D3D10_INPUT_ELEMENT_DESC, 317
D3D10_MAPPED_TEXTURE2D, 52
D3D10_SHADER_RESOURCE_VIEW_DESC,
441
D3D10_SUBRESOURCE_DATA, 326-327
D3D10_TEXTURE2D_DESC, 46-50, 302
D3D10_VIEWPORT, 308
DIMOUSESTATE, 70-71
DSBUFFERDESC, 91-92
DXGI_SWAP_CHAIN_DESC, 58-59
matrix4, 166-167
MSG, 6
plane3, 143-144
POINT, 18
point3, 124-125
RECT, 18
WAVEFORMATEX, 92-93
subdivision schemes, 380-383
butterfly, 383
example application, 387-399
interpolating vs approximating, 382
modified butterfly, 383-387
stationary vs non-stationary, 383
triangles vs quads, 382
uniform vs non-uniform, 383
subdivision surfaces, 379 subtraction, vector, 127-128 surfaces, drawing, 367-368 Sutherland-Hodgeman algorithm, 150-151 swap chains, 46
creating, 58-61, 300-302 Synchronize() function, 290-291 system messages, 17
T
task generation, 210 TCP, 259
teapot example application, 369-376 tearing, 43
temporal independence, 293 texel, 424
texture addressing, 426-429 texture aliasing, 430-432 texture arrays, 443 texture chain, 46 texture coordinates, 424 texture description, 46 texture management, 436-437 texture mapping, 423-425, 443-483 texture wrapping, 429-430 textures, 44-45, 424 activating, 440-442 adding to shader, 441-442 complex, 46
creating, 52 describing, 46
in Direct3D, 436-437 loading, 51, 437-440 sampling, 442 sending to shader, 442 working with, 51-52 texturing example application, 465-483 ThreadProc() function, 262-263, 269-270 timing, 294
title bar, 4-5 ToInverse() function, 175 topology, 327
transformation matrix inverse, 163 transformations, 156
rotation, 158-159, 169-170 translation, 156, 168 TranslateMessage() function, 12-13 translation transformation, 156, 168 translocators, 502-503
Transmission Control Protocol, see TCP
transmission latency ping, 288 tri template class, 139 triangle fans, 139-140 triangle strips, 139-140 triangles, 138-139 true color, 42
U
UDP, 259 implementing, 260-292
528 n Index
Trang 7unit sphere, 123
unit vector, 123
universe box, 504
Unlock() function, 96
UpdateLights() function, 329
UpdateMatrices() function, 319
User Datagram Protocol, see UDP
V
vector, 121
equality, 130-131
length of, 123
magnitude of, 123
mathematical operators, 127-135
quantities, 121
vertex buffers, 325-326
using, 326-328
vertex shader, 310
creating, 312-313
vertex split, 401-402
vertical blank, 43
vertical retrace, 43
vertices, 153
view space, 162-163
viewing cone, 493
viewport, 308
creating, 308-309
Vista, see Windows Vista
Visual C++, setting up, 36-38
W
WAV files, loading, 96-103
WAVEFORMATEX structure, 92-93
Win32 API, 2
vs DirectInput, 68
Win32 example program, 7-11
window, 4
class, 13
handle, 6
initializing, 13-16 messages, 20-23 procedure, 7 Windows, message handling in, 5-6 Windows programming, 1-3
vs DOS programming, 1-2 Windows Vista, 1-2
WinMain() function, 11-12, 29-30 Winsock, 257
wipes, 485 WM_CLOSE message, 20 WM_CREATE message, 20 WM_DESTROY message, 17, 20 WM_ERASEBKGND message, 20 WM_KEYDOWN message, 21 WM_KEYUP message, 21 WM_LBUTTONDOWN message, 21-22 WM_LBUTTONUP message, 23 WM_MBUTTONDOWN message, 22 WM_MBUTTONUP message, 23 WM_MOUSEMOVE message, 21 WM_MOUSEWHEEL message, 23 WM_MOVE message, 20 WM_PAINT message, 17, 20 WM_QUIT message, 21 WM_RBUTTONDOWN message, 22 WM_RBUTTONUP message, 23 WM_SIZE message, 20 WndProc() function, 7, 15, 17 world coordinate space, 161 world space, 163
wrap addressing, 426-427
X
XOR, 240
Z
z-buffering, 323-325