ebook img

Multi-Threaded Game Engine Design PDF

593 Pages·2010·9.89 MB·english
Save to my drive
Quick download
Download
Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.

Preview Multi-Threaded Game Engine Design

Multi-Threaded Game Engine Design Jonathan S. Harbour Course Technology PTR A part of Cengage Learning Australia . Brazil . Japan . Korea . Mexico . Singapore . Spain . UnitedKingdom . UnitedStates Multi-ThreadedGameEngineDesign ©2011CourseTechnology,apartofCengageLearning. JonathanS.Harbour ALLRIGHTSRESERVED.Nopartofthisworkcoveredbythecopyright hereinmaybereproduced,transmitted,stored,orusedinanyformor PublisherandGeneralManager, byanymeansgraphic,electronic,ormechanical,includingbutnot CourseTechnologyPTR:StacyL.Hiquet limitedtophotocopying,recording,scanning,digitizing,taping,Web AssociateDirectorofMarketing:SarahPanella distribution,informationnetworks,orinformationstorageandretrieval ManagerofEditorialServices:HeatherTalbot systems,exceptaspermittedunderSection107or108ofthe1976 MarketingManager:JordanCastellani UnitedStatesCopyrightAct,withoutthepriorwrittenpermissionofthe publisher. SeniorAcquisitionsEditor:EmiSmith ProjectEditor:JennyDavidson Forproductinformationandtechnologyassistance,contactusat TechnicalReviewer:JoshuaSmith CengageLearningCustomer&SalesSupport,1-800-354-9706 InteriorLayoutTech:MPSLimited,aMacmillan Company Forpermissiontousematerialfromthistextorproduct, submitallrequestsonlineatwww.cengage.com/permissions CoverDesigner:MikeTanamachi Furtherpermissionsquestionscanbeemailedto Indexer:LarrySweazy [email protected] Proofreader:MichaelBeady Alltrademarksarethepropertyoftheirrespectiveowners. (cid:1) Allimages C CengageLearningunlessotherwisenoted. LibraryofCongressControlNumber:2010922087 ISBN-13:978-1-4354-5417-0 ISBN-10:1-4354-5417-0 eISBN-10:1-4354-5598-3 CourseTechnology,apartofCengageLearning 20ChannelCenterStreet Boston,MA02210 USA CengageLearningisaleadingproviderofcustomizedlearningsolutions withofficelocationsaroundtheglobe,includingSingapore,theUnited Kingdom,Australia,Mexico,Brazil,andJapan.Locateyourlocalofficeat: international.cengage.com/region CengageLearningproductsarerepresentedinCanadabyNelson Education,Ltd. Foryourlifelonglearningsolutions,visitcourseptr.com Visitourcorporatewebsiteatcengage.com Printed in the United States of America 1 2 3 4 5 6 7 12 11 10 — — To the talented faculty at UAT and especially those in Game Studies with fi whom I shared ve arduous but rewarding years: Michael Eilers, Ken Adams, Arnaud Ehgner, Justin Selgrad, Dave Wessman, and Bill Fox. Acknowledgments Thank you to Emi Smith, Jenny Davidson, and Joshua Smith, for your efforts to getthislong-overduebookintopublishablecondition.ThankstoDaveWessman formanydiversionaryhoursplayingTwilightStruggleandMemoir44.Thanksto my favorite game studios Bungie, Obsidian Entertainment, Firaxis Games, and BioWare, for their inspiring works of creativity. Thanks to Misriah Armory for their SRS99D 14.5mm and M6G 12.7mm semi-automatic weapons, which are a lot of fun to shoot (only at the range, of course!). Author Bio Jonathan S. Harbour is a freelance writer, teacher, and indie game developer, fi whose rst experience with a computer was with a cassette-based Commodore fi PET, and rst video game system, an Atari 2600. His website at www.jharbour. com includes a forum for book support and game development discussions. fl — He has been involved in two recent indie games: Star ight The Lost Colony fl (www.star ightgame.com) and (with Dave Wessman) Aquaphobia: Mutant Brain Sponge Madness (www.aquaphobiagame.com). He loves to read science fi ctionandcomicbooksandtoplayvideogameswithhisfourkids,andevenafter “ ” growingup, heisstillanunapologeticTrekkie.Whenvirtualrealitytechnology progresses to the full holodeck experience, he will still spend time playing shoot- ’ em-ups,role-playinggames,andturn-basedstrategygames.Theresalwaysanew story waiting to be told. He has studied many programming languages and SDKs for his courses and þþ books, primarily: C , C#, Visual Basic, Java, DirectX, Allegro, Python, LUA, DarkBasic,JavaWirelessToolkit,andXNAGameStudio.Heisalsotheauthorof Visual C# Game Programming for Teens; Beginning Java Game Programming, Third Edition; Visual Basic Game Programming for Teens, Third Edition; Begin- ning Game Programming, Third Edition; and Advanced 2D Game Development. He lives in Arizona with his wife, Jennifer, and kids Jeremiah, Kayleigh, Kaitlyn, and Kourtney. Contents Introduction . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . xi PART I AN INTRODUCTION TO SYMMETRIC MULTI-PROCESSING . . . . . . 1 Chapter 1 Overview of Symmetric Multi-processing Technologies . . . 3 Digging In to SMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 4 Avoid Threading for the Sake of Threading. . . . . . . . . . . . . . . . . 5 Design First, Optimize Later . . . . . . . . . . . . . . . . . . . . . . . . . . . . 6 Peeking Under the Hood. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 7 Overview of Multi-threading Technology . . . . . . . . . . . . . . . . . . . . 10 Serial Processing (Single Thread) . . . . . . . . . . . . . . . . . . . . . . . . 10 Parallel Processing (Multiple Threads) . . . . . . . . . . . . . . . . . . . . 11 An Example Using Windows Threads . . . . . . . . . . . . . . . . . . . . . 13 SMP Libraries. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 OpenMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 16 Boost Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 19 Windows Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 24 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 29 Chapter 2 Working with Boost Threads . . . . . . . . . . . . . . . . . . . . . . 31 Punishing a Single Core . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 31 Calculating Prime Numbers . . . . . . . . . . . . . . . . . . . . . . . . . . . . 32 Prime Number Test 1 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 33 iv Contents v Optimizing the Primality Test: Prime Divisors . . . . . . . . . . . . . . . 36 Optimizing the Primality Test: Odd Candidates . . . . . . . . . . . . . 40 Spreading Out the Workload . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 Threaded Primality Test. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 44 Getting to Know boost::thread . . . . . . . . . . . . . . . . . . . . . . . . . 50 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 51 Chapter 3 Working with OpenMP . . . . . . . . . . . . . . . . . . . . . . . . . . 53 Say Hello To OpenMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 54 What Is OpenMP and How Does It Work? . . . . . . . . . . . . . . . . . . . 54 Advantages of OpenMP . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 55 What Is Shared Memory? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 56 Threading a Loop . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 57 Configuring Visual Cþþ . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 58 Exploring OpenMP. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 59 Specifying the Number of Threads. . . . . . . . . . . . . . . . . . . . . . . 59 Sequential Ordering . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 62 Controlling Thread Execution . . . . . . . . . . . . . . . . . . . . . . . . . . 65 Data Synchronization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 66 Prime Numbers Revisited . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 67 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 71 References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 72 Chapter 4 Working with POSIX Threads . . . . . . . . . . . . . . . . . . . . . 73 Introducing the POSIX Threads Library . . . . . . . . . . . . . . . . . . . . . . 74 Thread Theory in a Nutshell . . . . . . . . . . . . . . . . . . . . . . . . . . . 74 Putting POSIX Threads to Work. . . . . . . . . . . . . . . . . . . . . . . . . 76 Installing The Pthreads Library. . . . . . . . . . . . . . . . . . . . . . . . . . 79 Programming with Pthreads . . . . . . . . . . . . . . . . . . . . . . . . . . . 80 ThreadDemo Program. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 83 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 92 References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 93 Chapter 5 Working with Windows Threads . . . . . . . . . . . . . . . . . . . 95 Exploring Windows Threads . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 95 Quick Example . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 Creating a Thread. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 96 Controlling Thread Execution . . . . . . . . . . . . . . . . . . . . . . . . . . 97 vi Contents The Thread Function . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 Thread Function Parameters . . . . . . . . . . . . . . . . . . . . . . . . . . . 98 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 101 PART II CREATING AN ENGINE FOR SMP EXPERIMENTATION . . . . . . . 103 Chapter 6 Engine Startup . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 105 Why Build an Engine Yourself? . . . . . . . . . . . . . . . . . . . . . . . . . . 106 Valid Arguments in Favor . . . . . . . . . . . . . . . . . . . . . . . . . . . . 106 Valid Arguments Against. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 108 Creating the Engine Project . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 109 Engine Core System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 111 Engine Rendering System . . . . . . . . . . . . . . . . . . . . . . . . . . . . 139 Engine Support System . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 142 First Engine Demo. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 145 Enumerating Video Modes. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 149 Enumerating Multi-sampling Support . . . . . . . . . . . . . . . . . . . . . . 150 Verifying Framerates with FRAPS . . . . . . . . . . . . . . . . . . . . . . . . . 152 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 153 Chapter 7 Vectors and Matrices. . . . . . . . . . . . . . . . . . . . . . . . . . . 155 Vectors and Points . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 156 Understanding Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 157 Direct3D Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 Vector2 Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 158 Vector3 Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 162 Math Functions . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 165 Linear Velocity . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 166 Angle to Target . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 167 Math Class Header . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 168 Math Class Implementation . . . . . . . . . . . . . . . . . . . . . . . . . . . 169 Math Vector Demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 174 Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 Zero and Identity Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . 179 Matrix Operations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 182 Direct3D Matrices . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 184 Matrix Transforms. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 186 Matrix Struct. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 188 Math Matrix Demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 194 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 198 Contents vii Chapter 8 Rendering the Scene . . . . . . . . . . . . . . . . . . . . . . . . . . . 199 The Camera (View and Projection Matrices) . . . . . . . . . . . . . . . . . 200 The View Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 The Projection Matrix . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 201 Camera Class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 202 The Scene (World Matrix). . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 Rendering a Basic Scene . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 206 Loading an Effect File . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 208 Rendering a Stock Mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 218 Diffuse Lighting. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 223 Directional Light . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 224 Directional Light Demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 228 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239 References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 239 Chapter 9 Mesh Loading and Rendering . . . . . . . . . . . . . . . . . . . . 241 Mesh Loading and Rendering. . . . . . . . . . . . . . . . . . . . . . . . . . . . 241 .X Files . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 242 Mesh Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 251 Textured Ambient Light Rendering . . . . . . . . . . . . . . . . . . . . . 261 Texture Class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 267 Lighting Texture-Mapped Meshes. . . . . . . . . . . . . . . . . . . . . . . . . 272 Textured Directional Light Shader . . . . . . . . . . . . . . . . . . . . . . 275 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 284 Chapter 10 Advanced Lighting Effects. . . . . . . . . . . . . . . . . . . . . . . 285 Textured Point Light Shader. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 285 Point Lights . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 286 Textured Point Light Shader Demo . . . . . . . . . . . . . . . . . . . . . 289 Specular Reflection Shader. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 295 Specular Light Demo. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 298 Textured Specular Reflection . . . . . . . . . . . . . . . . . . . . . . . . . . 300 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 303 Chapter 11 Wrapping the Sky in a Box . . . . . . . . . . . . . . . . . . . . . . 305 Building a Skybox . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 305 Skybox or Skysphere? . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 306 Creating a Custom Skybox. . . . . . . . . . . . . . . . . . . . . . . . . . . . 308 Skybox Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 310 Skybox Shader . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 315 viii Contents Mountain Skybox Demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 317 Space Skybox Demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 322 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 328 Chapter 12 Environmental Concerns: Recycling Terrain Polygons . . . 329 Outer Space Environments . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 330 Indoor/Outdoor Environments . . . . . . . . . . . . . . . . . . . . . . . . . . . 332 Creating Terrain. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 332 Perlin Noise . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 334 Terrain Generation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 341 Terrain Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 343 Terrain Demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 353 Walking on Terrain . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357 Calculating Height . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 357 Terrain Following Demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 359 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 363 References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 364 Chapter 13 Skeletal Mesh Animation . . . . . . . . . . . . . . . . . . . . . . . 365 Hierarchical Mesh Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 366 Asset Pipeline . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 367 The Bone Structure . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 368 Loading a Skeletal Mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 370 Mesh File Differences . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 371 Loading the Hierarchy. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 375 Rendering a Skeletal Mesh. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 389 Animating a Skeletal Mesh . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 391 Updating the Frame Matrices . . . . . . . . . . . . . . . . . . . . . . . . . 392 Changing the Animation Set . . . . . . . . . . . . . . . . . . . . . . . . . . 393 The Bone Mesh Demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 394 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399 References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 399 Chapter 14 Sprite Animation and Rasterization . . . . . . . . . . . . . . . . 401 Sprite Rasterization . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 402 ID3DXSprite . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 403 Vectors . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404 Rectangles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 404 Contents ix The Sprite Class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 407 Drawing with Transparency. . . . . . . . . . . . . . . . . . . . . . . . . . . 414 Sprite Transformations. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 415 Calculating Transforms . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 416 Sprite Transform Demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 417 Sprite Animation . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 420 Animation with a Touch of Class . . . . . . . . . . . . . . . . . . . . . . . 421 Animation Demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 422 Sprite-Based Particles . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 426 Sprite-Based Fonts . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 433 Creating a Font. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 434 Loading and Rendering a Font . . . . . . . . . . . . . . . . . . . . . . . . 437 Using the BitmapFont Class . . . . . . . . . . . . . . . . . . . . . . . . . . . 439 Loading Assets from a Zip File . . . . . . . . . . . . . . . . . . . . . . . . . . . 441 Reading from a Zip File. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 442 Zip Asset Demo. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 446 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449 References. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 449 Chapter 15 Rendering to a Texture . . . . . . . . . . . . . . . . . . . . . . . . . 451 Rendering to a Texture . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 451 Creating a Render Target . . . . . . . . . . . . . . . . . . . . . . . . . . . . 452 Rendering to the Alternate Target . . . . . . . . . . . . . . . . . . . . . 453 Drawing Vector Shapes . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 454 VectorShape Class . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 455 Vector Shape Demo . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 458 Scrolling Background Layers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462 Bitmap Layers . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 462 Tiled Layers. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 475 Summary . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 483 Chapter 16 Entity Management . . . . . . . . . . . . . . . . . . . . . . . . . . . 485 Building an Entity Manager . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 486 The Entity Class. . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 488 Modifying the Engine . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . 491 Managed AutoTimer—Non-Rendering. . . . . . . . . . . . . . . . . . . 498 Entity-fying the Engine Classes . . . . . . . . . . . . . . . . . . . . . . . . . . . 500

See more

The list of books you might like

Most books are stored in the elastic cloud where traffic is expensive. For this reason, we have a limit on daily download.