OpenGL game development

497 508 0
OpenGL game development

Đang tải... (xem toàn văn)

Tài liệu hạn chế xem trước, để xem đầy đủ mời bạn chọn Tải xuống

Thông tin tài liệu

TeAm YYePG Digitally signed by TeAm YYePG DN: cn=TeAm YYePG, c=US, o=TeAm YYePG, ou=TeAm YYePG, email=yyepg@msn.com Reason: I attest to the accuracy and integrity of this document Date: 2005.04.04 12:42:45 +08'00' OpenGL Game Development Chris Seddon Wordware Publishing, Inc Library of Congress Cataloging-in-Publication Data Seddon, Chris OpenGL game development / by Chris Seddon p cm Includes bibliographical references and index ISBN 1-55622-989-5 (pbk.) Computer games Programming OpenGL QA76.76.C672S43 2004 794.8'1526 dc22 Computer graphics I Title 2004024961 CIP © 2005, Wordware Publishing, Inc 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 Printed in the United States of America ISBN 1-55622-989-5 10 0411 3DNow! Technology is a trademark of Advanced Micro Devices, Inc Adobe Photoshop is a registered trademark of Adobe Systems, Inc Direct X, Microsoft, MS, MS-DOS, Windows, Win32, and Windows NT are either registered trademarks or trademarks of Microsoft Corporation in the United States and/or other countries OpenGL is a registered trademark and IRIS GL is a trademark of Silicon Graphics, Inc Quake is a trademark of id Software Inc Super Mario Brothers and Donkey Kong are trademarks of Nintendo Entertainment Sonic the Hedgehog is a trademark of Sega Corporation 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 To Tim, Mom, and my wonderful wife, Dina This page intentionally left blank Contents Introduction xi Part I — Creating the Map Editor Chapter Introducing Windows Programming Concepts of Event-Driven Programming Introducing the Win32 SDK Registering a Window Class Creating a Window The Main Loop The Message Handler Your First Windows Application 11 Compiling Notes 12 Adding Windows 13 Buttons 13 Adding Functionality to Button Clicks 15 Resources 17 The Resource Editor 19 Adding Menus 20 Adding Item Click Functions 22 Checkmarking Items 25 Getting the Check State 25 Making a Pop-up Menu 26 Dialog Boxes 30 Differences between Windows and Dialog Controls 30 Using Controls 31 Buttons Edit Box Controls List Box Controls Combo Box Controls Static Controls 33 34 35 37 39 Chapter Example 39 Conclusion 42 Chapter Introduction to OpenGL 43 The History of OpenGL Why Use OpenGL? The World in Three Dimensions OpenGL Buffers Accumulation Buffer 43 45 47 48 48 vi | Contents Depth Buffer Frame Buffer Stencil Buffer Basic OpenGL Terminology Vertex Triangle Polygon Primitive Initializing OpenGL Releasing OpenGL The Different Matrices Projection Model View Texture Matrix Functions Selecting a Matrix Setting the Identity Matrix Rotating a Matrix Translating a Matrix Scaling a Matrix Saving and Restoring the Matrix Resizing a GL Window Setting the Rendering Defaults Drawing “Things” in OpenGL Points Lines Triangles Quads Polygons Chapter Example Conclusion Chapter 49 49 49 50 50 50 50 50 51 65 68 68 69 69 69 69 70 70 71 72 73 73 77 78 80 80 81 81 81 82 88 Defining the Map Format 89 Version Control 89 The Map Header 90 Extra Map Features 92 Main Rendering Structures 97 Miscellaneous Map Structures 108 Creating the MAP Class 112 Chapter Example 113 Conclusion 118 Chapter Creating the Low-Level Map Code 119 Generating Unique Colors Checking to See If the Color Exists Inserting Objects Generating Unique Vertex Colors Inserting Vertices 119 121 123 129 131 Contents | vii Inserting Triangles 135 Chapter Example 137 Conclusion 150 Chapter Creating Map Objects 151 The Basic Interface Handling the WM_LBUTTONDOWN Message Handling the WM_LBUTTONUP Message Create a Wall Create a Floor Create a Ceiling Handling the WM_MOUSEMOVE Message The New Globals Modifying the Rendering Function Creating the New Buttons Checking for Button Clicks Chapter Example Conclusion Chapter 151 157 159 160 162 163 165 168 168 172 173 174 185 187 190 191 197 208 Adding Game-Related Functionality 209 Placing Start Positions Placing Multiplayer Starting Positions Placing Entity Positions Placing Items Inserting Sounds Placing Lights Chapter Example Conclusion Chapter Drawing Primitives 187 Adding Layers Updating Wireframe Rendering with Layers Drawing Solid Primitive Chapter Example Conclusion Chapter 209 214 220 227 234 242 255 275 Adding Useful Functionality 277 Selecting an Object Moving Objects Assigning Textures to Objects Duplicating Objects Adding Skyboxes Adding Fog Editing Map Details Selecting and Assigning Objects to Lights Removing Objects from Lights Editing Object Values Deleting Objects 277 286 291 299 304 308 311 313 317 319 324 viii | Contents Chapter Example 335 Conclusion 335 Chapter Saving and Opening Files 337 Saving Files Clearing Map Data Opening Files Chapter Example Conclusion 337 341 343 346 346 Part II — Creating the Game Engine Chapter 10 Basic Game Setup 349 The New Base Code Using a Dialog Box for Game Configuration Chapter Example Conclusion Chapter 11 349 351 354 356 358 359 363 364 367 368 369 370 373 374 378 380 380 Rendering Scenes 381 Setting the Perspective View Loading Maps Rendering Scenes Skyboxes Chapter Example Conclusion Chapter 13 OpenGL Texturing 357 How Texturing Works Loading Bitmap Files Releasing Bitmap Data Using Textures Texture Filtering Texture Wrapping Texture Environment Settings Transparent Colors Using Mipmaps Bitblitting in OpenGL Using Texture Lists Chapter Example Conclusion Chapter 12 381 382 384 386 390 390 Movement 391 The Math Behind Movement Moving Forward and Backward Strafing Turning Checking for Keypresses Tracking Mouse Movements 391 393 394 394 395 396 | Contents ix Checking Mouse Button Input 396 Chapter Example 397 Conclusion 397 Chapter 14 Lights and Fog 399 Dynamic Lighting Vertex-Colored Lighting Radiosity Lighting Projected Texturing Fog Chapter Example Conclusion Chapter 15 399 400 401 402 407 409 409 411 413 419 420 421 421 425 425 427 428 431 433 433 435 435 436 436 Multiplayer Gaming 437 Initializing the Server Initializing the Client Sending Packets Receiving Packets Releasing Open Sockets Multiplayer Setup Chapter Example Conclusion Chapter 18 Beyond OpenGL 1.1 423 Texturing Anisotropic Filtering (GL_EXT_texture_filter_anisotropic) Irregular Texture Sizes (GL_ARB_texture_non_power_of_two) Multitexturing (GL_ARB_multitexture) Texture Compression (GL_ARB_texture_compression) Fog Volumetric Fog (GL_EXT_fog_coord) Windows Extensions Swap Control (WGL_EXT_SWAP_CONTROL) Chapter Example Conclusion Chapter 17 Using 3D Models 411 Exporting from 3ds max Loading ASE Models Releasing Model Data Drawing Models Chapter Example Conclusion Chapter 16 439 440 442 443 444 445 449 449 Using OpenAL 451 OpenAL Installation Initializing OpenAL Using Audio Files Playing Sources 451 452 454 456 470 | Chapter 19 Part II player.xyz[2] = map.details.deathmatch[0].xyz[2]; } } else { player.xyz[0] = map.details.single_player.xyz[0]; player.xyz[2] = map.details.single_player.xyz[2]; } Optimization Techniques There are many methods of optimization that can be performed in OpenGL, including using display lists, sorting texture IDs, using vertex arrays, and testing for occlusion This section discusses these techniques Using Display Lists Although our rendering engine isn’t complex compared to many retail games, there are still many optimizations that can be completed very easily In Chapter 12, we created the function RenderObject to render an object’s triangles Without adding too much new code, we can optimize this rendering process by placing each object’s triangle data into a display list instead A display list allows you to cache a compiled list of OpenGL commands into an OpenGL display list number When rendering a scene in OpenGL, you can call the display list number as opposed to continuously specifying each GL command From the main rendering loop you can then call the display list number to render the data When using display lists (depending on the hardware), you’ll notice some increases in speed In some cases the speed increase is minor, and in some cases it’s quite drastic The performance gains all depend on your graphics hardware To begin the coding process we’ll create a new function called BuildDisplayLists, which as the name implies will build the display lists for our map data In the function we’ll loop through the different objects in the map, compiling each display list using the object number To compile a display list we use the OpenGL command glNewList with the object number plus one to avoid a list name of The second parameter of the GL command is the compilation mode, which describes how the list will be used In our case we’ll use the constant GL_COMPILE_AND_EXECUTE to compile and execute the display list After we’ve called glNewList, we must run the OpenGL commands that we want the display list to process, which in our case are stored in the RenderObject function Following the call to RenderObject, which will write the GL map rendering calls to the display list, we run the GL command glEndList to tell OpenGL we’re done compiling our display list Once the loop finishes compiling the different lists, we’re Tips and Tricks | 471 Creating the Game Engine finished with the function The source code for the BuildDisplayLists function is shown below void BuildDisplayLists() { for (long obj = 0; obj < map.header.max_objects; obj++) { glNewList (obj, GL_COMPILE_AND_EXECUTE); RenderObject (obj+1); glEndList(); } } With the functionality now created to compile the GL display lists, we’ll call the BuildDisplayLists function inside the LoadMap function to compile the display lists when we load our map data The final step to implementing display lists is to update our rendering code to call the display lists instead of calling the RenderObject function The functions that would be affected by this change in our game engine are the RenderLight function and the main render loop where we call RenderObject to render each object To execute the commands in the display list, we use the GL command glCallList and specify the list number For instance, if we were rendering the objects in the map, we would comment the RenderObject function call and simply add the call glCallList The single parameter of the command is the list number, which is the object number plus one Pretty simple, huh? The updated source code for the main object rendering loop is written below to show how to call our display lists for (long obj = 0; obj < map.header.max_objects; obj++) { glColor3f (1.0f, 1.0f, 1.0f); for (long layer = 0; layer < MAX_TEXTURE_LAYERS; layer++) { if (map.object[obj].texture[layer].id > 0) { glActiveTextureARB (GL_TEXTURE0_ARB + layer); glBindTexture (GL_TEXTURE_2D, TextureName[map.object[obj].texture [layer].id]); } } // RenderObject ( obj ); glCallList ( obj ); } 472 | Chapter 19 Part II Sorting Texture Binds Another optimization that can be performed in our game engine is the sorting of the texture IDs If we sort our objects by their texture IDs, we can then limit the number of texture binds that are being performed with each frame being rendered This can have a huge effect on performance since we are only transferring bitmaps a few times instead of potentially hundreds Even with compressed textures, this method can help The sort simply involves classing the bitmaps by their numbers and checking the previous texture against the current one If the texture IDs are different, then we’ll bind a new texture; otherwise, we’ll continue using the texture This is slightly more difficult when using multitexturing because we must sort each texture layer, which can become annoying at times, but it’s part of programming games Vertex Arrays Another method of optimizing a rendering engine is by using vertex arrays A vertex array allows you to push many vertices for an object at once Rather than specifying 100 calls to glVertex for a specific object, you can specify the data in an array and the hardware will automatically run through them Some video cards process this data faster than display lists and some have the opposite effect This technique is ideal for use with static geometry because you don’t have to worry about updating the arrays Occlusion Querying Occlusion querying allows you to test if a triangle is behind another This is a fantastic feature and is especially great for detailed landscapes because we can easily cut certain objects or triangles out of a scene using new extensions Through occlusion testing we can simply see if the “bad guys” are on one side of a mountain when we’re on the other side If we cannot see them, we don’t have to worry about binding the textures and drawing them Although the hardware does attempt to this on its own, in some cases we can create faster algorithms by generalizing information For instance, if the characters on one side of the mountain haven’t moved since the last frame rendered, we can ignore drawing them As our user walks we could test for occlusion every tenth of a second, which would provide us a simple means for culling our models Tips and Tricks | 473 Creating the Game Engine Chapter Example Please see the example from the companion file (ex19_1) Conclusion In this chapter we discussed simple techniques that add some spice to our game In game development there are literally hundreds and even thousands of techniques that could have been included in this chapter I focused on the techniques that would be the easiest for beginners yet still useful to intermediate and advanced programmers With the functionality discussed in the book, you should be able to write your own basic OpenGL video game with all the trimmings! In writing this book I tried to discuss how to create games in OpenGL in a simple, plain-English manner I hope you’ve gotten everything you wanted from this book and more! Of course that would be learning how to make games in OpenGL It’s been a long journey to this point, and I’d like to thank you for reading this book! This page intentionally left blank Sources Michael Abrash’s Graphics Programming Black Book, Special Edition, Michael Abrash, Coriolis Group Books, 1997 OpenGL Programming Guide: The Official Guide to Learning OpenGL Version 1.1 (second edition), Mason Woo, Jackie Neider, Tom Davis, Addison-Wesley Publishing, 1997 Windows 95 API How-To, Matthew Telles, Andrew Cooke, Waite Group Press, 1996 “The OpenGL Graphics System: A Specification (Version 1.5),” Mark Segal, Kurt Akeley, Silicon Graphics, Inc., 2003 (http://www.opengl.org/documentation/specs/version1.5/ glspec15.pdf) “OpenGL BOF,” Jon Leech, SGI/OpenGL ARB Secretary (http://www.opengl.org/developers/code/features/siggraph2002_bof/ sg2002bof_sgi.ppt) “Creative OpenAL Programmer’s Reference (Version 1.0),” Creative Technology Limited, 2001 (http://chopenal.sourceforge.net/OpenAL.pdf) “OpenAL Specification and Reference (Version 1.0 Draft Edition),” Loki Software, 2000 (http://www.openal.org/oalspecs-annote/) GL_ARB_texture_compression Extension Specification (2000), GL_EXT_abgr Extension Specification (1995), GL_EXT_fog_coord Extension Specification (1999), WGL_EXT_swap_control Extension Specification (1999) (http://oss.sgi.com/projects/ogl-sample/registry) “BMP Format, Windows Bitmap File Format Specifications, V1.1,” Wim Wouters (atlc.sourceforge.net/bmp.html) “The Design of the OpenGL Graphics Interface,” Mark Segal, Kurt Akeley, Silicon Graphics Systems (http://www.opengl.org/developers/documentation/white_papers/opengl/) Microsoft Developer Network — http://msdn.microsoft.com Silicon Graphics Inc (SGI) — http://www.sgi.com OpenAL — http://www.openal.org OpenGL — http://www.opengl.org Mesa — http://www.mesa3d.org 475 This page intentionally left blank Further Reading Official Web Sites Official OpenGL web site — http://www.opengl.org Official Mesa web site — http://www.mesa3d.org OpenGL Extension Registry — http://oss.sgi.com/projects/ogl-sample/ registry/ Official OpenAL web site — http://www.openal.org Hobbyist OpenGL Web Sites NeHe — http://nehe.gamedev.net Game tutorials — http://www.gametutorials.com Code Sampler — http://www.codesampler.com DevMaster — http://www.devmaster.net News Groups and Mailing Lists OpenGL news groups — comp.graphics.api.opengl and www.opengl.org/ community/newsgroups.html OpenGL Vendor Developer Sites 3Dlabs developer site — http://developer.3dlabs.com This site has a lot of information about 3Dlabs’ video cards and capabilities, along with example code and ideas on the future of OpenGL ATI developer site — http://www.ati.com/developer/ A great resource for developers with an interest in ATI-specific OpenGL features Some of the examples here are wild! Intel developer site — http://www.intel.com/developer/ Matrox developer site — http://developer.matrox.com nVIDIA developer site — http://developer.nvidia.com A great resource for any developer wanting to learn about OpenGL coding for nVIDIA video cards and about the Cg Shader language SiS developer site — http://www.sis.com 477 478 | Further Reading Software Sites 3D Modeling Software Alias|Wavefront — http://www.aliaswavefront.com Makers of Maya Avid — http://www.avid.com Makers of SoftImage Blender Foundation — http://www.blender3d.com Makers of Blender chUmbaLum sOft — www.swissquake.ch/chumbalum-soft Makers of MilkShape, an inexpensive modeling tool Discreet — http://www.discreet.com Makers of 3ds max and gmax NewTek — http://www.newtek.com Makers of LightWave Side Effects Software — http://www.sidefx.com Makers of Houdini Paint Software Adobe Systems — http://www.adobe.com Makers of Photoshop, Illustrator, and many other packages GIMP Foundation — http://www.gimp.org Makers of the free GNU Image Manipulation Program (GIMP) Jasc Software — http://www.jasc.com Makers of Paint Shop Pro Terrain Generation Software Corel — http://www.corel.com Makers of Corel Bryce Terragen — http://www.planetside.co.uk/terragen Makers of Terragen Index 3ds max, exporting data from, 411-412 A accumulation buffer, 48-49 anisotropic filtering, 425-426 applications, creating, 4-5 AssignTextureDlgProc function, 293-298 AssignToLight function, 314-317 audio buffer, 453 audio files, see sound sources auto texture generation, 403-404 B backface culling, 78, 365 bilinear filtering, 357-358, 367-368 bitblitting, 374-378 bitmap data, releasing, 363-364 bitmap file, loading, 359-363 bitmap format, 360-362 buffer ID, obtaining, 457-458 BuildDisplayLists function, 470-471 buttons, click functionality, 15, 173 creating, 13-14, 33-34, 172 C CalculateFPS function, 467-468 camera, 105 ceiling, creating, 163 CheckInput function, 395-397 ChoosePixelFormat function, 60-61 Clear function, 341-342 click functionality, 15, 173 client, initializing, 440-442 ColorExists function, 122-123 colors, checking for existence of, 121-123 generating, 119-121, 129-130 transparent, 370-372 combo box controls, 37-38 ComputeMouseCoords function, 154-157 CONFIG structure, 192 configuration dialog box, creating, 351-354 controls, 30-31 using, 31-33 COORDS structure, 152-153 CreateSources function, 460 CreateWindow function, CREATION_COORDS structure, 153-154 D deathmatch, see multiplayer Delete function, 324-335 depth buffer, 49, 364-365 dialog box, 30 creating, 31-32 display lists, using, 470-471 DMPositionDlgProc function, 216-218 DrawDeathmatchPositions function, 219-220 DrawEntities function, 226-227 DrawItems function, 233-234 DrawLights function, 255 DrawPlayerGun function, 468 DrawSolid function, 193-196 DrawSounds function, 241 DrawStartPosition function, 213-214 DrawWireframe function, 190-191 Duplicate function, 299-303 dynamic lighting, 399-400 E edit box controls, 34 EditObjectDlgProc function, 320-324 entities, 108, 220 placing, 220-227 event-driven programming, 3-4 F field of view, 381 files, opening, 343-346 saving, 337-341 filtering, 357-358, 367-368 floor, creating, 162-163 fog, 407-408 adding, 308-310 extensions, 433-435 volumetric, 433-435 FogDlgProc function, 308-310 FPS counter, adding, 467-468 frame buffer, 49 479 480 | Index G game engine base code, 349-351 GenerateColor function, 120-121 GenerateVertexColor function, 130 GetBufferID function, 457-458 GetTextureID function, 383 glBitBlt function, 374-378 glTextOut function, 466-467 graphics formats, 359-360 I identity matrix, 70 include lists, 402-403 Init function, 63, 452-454 InitClient function, 440-442 InitServer function, 439-440 InsertEntityDlgProc function, 223-225 InsertItem function, 227-229 InsertItemDlgProc function, 231-233 InsertLight function, 242-246 InsertLightDlgProc function, 250-254 InsertSound function, 235-237 InsertSoundDlgProc function, 239-240 InsertTexture function, 292-293 InsertTriangle function, 136 InsertVertex function, 133-134 items, 110, 227 holding, 468 placing, 227-234 K keypresses, checking for, 395 L LAYER structure, 188 layers, adding, 187-190 light angles, 249 lighting, 106-107, 399-407 lightmapping, 252 lights, assigning to objects, 313-317 placing, 242-255 removing objects from, 317-319 line, 80 list box controls, 35-36 listener, setting up, 461-462 Load function, 361-363, 416-418 LoadGLExtensions function, 429-430 LoadMap function, 382-384, 387, 407-409, 434-435, 463-464 LoadModel function, 419-420 LoadTexture function, 366-370, 426 LoadTransparentTexture function, 371-372 LoadWav function, 455-456 M main loop, creating, 8-9 MAP class, creating, 112-113 modifying, 123-125 map data, clearing, 341-342 map details, editing, 311-312 setting, 95-96 map editor base code, 11-12 map format, defining, 89-111 map header, defining, 90-91 map structures, 89-111 MapDetailsDlgProc function, 311-312 maps, loading, 382-384 matrices, 68-69 restoring, 73 rotating, 70-71 saving, 73 scaling, 72 selecting, 69-70 translating, 71-72 menu, adding, 20-22 creating pop-up, 26-27 menu item, adding, 22-23 checkmarking, 25-26 message handler, creating, 9-10 MessageBox function, messages, handling, 157-160, 165-167 MFC, creating applications with, Microsoft Foundation Classes, see MFC mipmapping, 373-374 model data, releasing, 419-420 model view matrix, 69 models, drawing, 420-421 exporting from 3ds max, 411-412 loading, 413-418 mouse movements, tracking, 396 Move function, 287-290 MoveBackward function, 393 MoveForward function, 393, 469 movement, 393-394 time-based, 468-469 multiplayer, gaming considerations, 437-438 Index start positions, 214-220 support, 445-448 multitexturing, 291, 428-431 N nearest filtering, 367 O objects, adding, 13-14 assigning textures to, 291-299 assigning to lights, 313-317 deleting, 324-335 duplicating, 299-303 editing values of, 319-324 generating colors for, 119-121 inserting, 123-128 moving, 286-291 removing from lights, 317-319 selecting, 277-286 occlusion querying, 472 Open function, 343-346 OpenAL, 451 initializing, 452-454 installing, 451-452 releasing, 461 OpenGL, 43-44, 50-51 buffers, 48-50 cross-compatibility of, 45-46 extensions, 423-425 initializing, 51, 53-63 matrices, 68 reasons for using, 45-46 releasing, 65-67 optimization, 470-472 orthographic projection, setting, 74 P packets, receiving, 443-444 sending, 442-443 PeekMessage function, perspective view, setting, 381-382 PIXELFORMATDESCRIPTOR structure, 56-60 PlaySource function, 456-457 point, 80 polygon, 50, 81 culling, 78 pop-up menu, creating, 26-27 positions, calculating, 391-393 | 481 primitive, 50 drawing, 78-80, 151-157, 191-196 programming, event-driven, 3-4 projected texturing, 402-407 projection matrix, 68 Q quad, 81 R radiosity lighting, 401 Receive function, 443-444 Release function, 67, 363-364, 419, 444-445, 461 ReleaseDC function, 66 ReleaseSources function, 460 RemoveFromLight function, 317-319 Render function, 168-171, 196, 392-393, 427-428, 447-448 rendering defaults, setting, 77-78 rendering types, 168 rendering viewport, resizing, 73-74 RenderItems function, 420-421 RenderLight function, 403-406 RenderMap function, 384-385 RenderModel function, 420-421 RenderObject function, 384-385, 430-431, 433-434 RenderSkybox function, 388-390 ResizeGLWindow function, 75 resource editor, 18 using, 19-20 resources, 17 adding, 20-22 creating, 18-19 S Save function, 338-341 scenes, rendering, 384-385 SelectAnObject function, 281-285 SelectLightDlgProc function, 313-314 Send function, 442-443 SendMultiplayerPacket function, 448 server, initializing, 439-440 SetGLDefaults function, 78, 378-379, 381-382 SetListener method, 461-462 SetPixelFormat function, 61 SetSource function, 458-459 ShowSelectedButton function, 210-211 single-player start position, placing, 209-214 482 | Index skybox, 91, 92, 304 adding, 304-307 rendering, 386-390 SkyboxDlgProc function, 305-307 sockets, releasing, 444-445 solid primitive, drawing, 191-196 sound sources, loading, 454-456 playing, 456-457 releasing memory of, 460 setting, 458-459 specifying number of, 460 stopping, 457 sounds, 110-111 adding to game, 463-464 inserting, 234-242 start position, placing, 209-220 setting, 94, 469-470 static controls, 39 stencil buffer, 49-50 StopSource function, 457 StrafeLeft function, 394 StrafeRight function, 394 strafing, 391-392 swap control, 435-436 T text, displaying, 465-467 texture compression, 431-432 coordinate, 376 filtering, see filtering matrix, 69 wrapping, 368-369 texture environment settings, modifying, 369-370 texture IDs, sorting, 472 texture list, 378 using, 378-379 textures, 291 assigning to objects, 291-299 irregular, 427-428 using, 364-367 texturing, 357-359 extensions, 425-432 transparency, 370-372 triangle, 50, 81 inserting, 135-136 turning, 394-395 TurnLeft function, 395 TurnRight function, 395 U UV coordinates, 100 V version control, 89 vertex, 50 vertex arrays, 472 vertex coloring, 400 VertexColorExists function, 129-130 vertices, generating colors for, 129-130 inserting, 131-134 viewport, resizing, 73-74 volumetric fog, 433-435 W wall, creating, 160-162 Win32 application, Win32 console application, Win32 SDK, creating applications with, 4-5 window, creating, 7-8 window class, registering, 5-7 Windows applications, methods for creating, Windows extensions, 435-436 WinMain, 4-5 wireframe, 168 wireframe rendering, 190-191 WM_LBUTTONDOWN message, handling, 157-159 WM_LBUTTONUP message, handling, 159-160 WM_MOUSEMOVE message, handling, 165-167 WMLButtonDown function, 158-159 WMLButtonUp function, 159, 163-164 WMMouseMove function, 165-167 WMSize function, 77 WndProc, 10, 167-168, 446-447 X x-axis, 47-48 Y y-axis, 47-48 Z z-axis, 47-48 Z-buffer, 364-365 Looking for more? Check these and other titles from Wordware’s complete list Introduction to 3D Game Programming with DirectX 9.0 1-55622-913-5 • $49.95 x • 424 pp Advanced 3D Game Programming with DirectX 9.0 1-55622-968-2 • $59.95 x • 552 pp Learn Vertex and Pixel Shader Programming with DirectX 1-55622-287-4 • $34.95 x • 304 pp Programming Multiplayer Games 1-55622-076-6 • $59.95 x • 576 pp ShaderX2: Introductions & Tutorials with DirectX 1-55622-902-X • $44.95 x • 384 pp ShaderX2: Shader Programming Tips & Tricks with DirectX 1-55622-988-7 • $59.95 x • 728 pp DirectX Audio Exposed 1-55622-288-2 • $59.95 x • 568 pp DirectX User Interfaces 1-55622-249-1 • $44.95 x • 376 pp Programming Game AI by Example 1-55622-078-2 • $49.95 x • 520 pp Wireless Game Development in Java with MIDP 2.0 1-55622-998-4 • $39.95 x • 360 pp Game Design Theory and Practice 2nd Ed 1-55622-912-7 • $49.95 x • 728 pp Official Butterfly.net Game Developer’s Guide 1-55622-044-8 • $49.95 x • 424 pp www.wordware.com Visit us online at for more information Use the following coupon code for online specials: opengl9895 Looking for more? Check out Wordware’s market-leading Graphics and Game Programming Libraries featuring the following new releases, backlist, and upcoming titles Essential LightWave 3D 7.5 1-55622-226-2 • $44.95 x • 424 pp LightWave 3D Cartoon Character Creation: Volume Modeling & Texturing 1-55622-253-X • $49.95 x • 496 pp LightWave 3D 7.5 Lighting 1-55622-354-4 • $69.95 x • 496 pp LightWave 3D Cartoon Character Creation: Volume Rigging & Animation 1-55622-254-8 • $49.95 x • 440 pp LightWave 3D Lighting 1-55622-094-4 • $54.95 x • 536 pp LightWave 3D 8: 1001 Tips and Tricks 1-55622-090-1 • $39.95 x • 648 pp LightWave 3D Texturing 1-55622-285-8 • $49.95 x • 504 pp CGI Filmmaking: The Creation of Ghost Warrior 1-55622-227-0 • $49.95 x • 344 pp 3ds max Lighting 1-55622-401-X $49.95 x • 432 pp Advanced Lighting and Materials with Shaders 1-55622-292-0 • $44.95 x • 360 pp LightWave 3D Character Animation 1-55622-099-5 • $49.95 x • 496 pp www.wordware.com Visit us online at for more information Use the following coupon code for online specials: opengl9895 .. .OpenGL Game Development Chris Seddon Wordware Publishing, Inc Library of Congress Cataloging-in-Publication Data Seddon, Chris OpenGL game development / by Chris Seddon... OpenGL is the industry standard for 3D graphics The SDK has been used in many leading applications, games, CAD, and military and medical simulations over the past eight years In OpenGL Game Development, ... 42 Chapter Introduction to OpenGL 43 The History of OpenGL Why Use OpenGL? The World in Three Dimensions OpenGL Buffers Accumulation Buffer

Ngày đăng: 18/10/2019, 16:02