You are previewing Beginning DirectX®11 Game Programming.
O'Reilly logo
Beginning DirectX®11 Game Programming

Book Description

Discover the exciting world of game programming and 3D graphics creation using DirectX 11! BEGINNING DIRECTX 11 GAME PROGRAMMING is an introductory guide to creating fantastic graphics, amazing creatures, and realistic worlds for games. Written specifically for the beginner programmer, the book uses step-by-step instructions to teach the basics of DirectX 11, introducing skills that can be applied to creating games for both PC and game console platforms like the Xbox 360. Updated for all the newest DirectX technology, the book includes coverage of improved professional coding practices, an overview of the DirectX components and tools, sprites, text and font rendering, audio, shaders and effects, and much more.

Table of Contents

  1. Copyright
  2. Acknowledgments
  3. About the Authors
  4. Introduction
    1. About This Book
    2. Recommended Knowledge
    3. Companion Website: Code and Bonus Content
    4. Errata
    5. Companion Website Downloads
  5. 1. The What, Why, and How of DirectX
    1. What Is DirectX?
      1. DirectX 10 versus DirectX 9
      2. DirectX 11 versus DirectX 10
      3. DirectX 11 versus OpenGL 4.0
    2. Why Is DirectX Needed?
    3. How DirectX Is Put Together
      1. The Components of DirectX 11
        1. Direct2D
        2. DirectWrite
        3. DXGI
        4. Direct3D
        5. XAudio2
        6. XACT3
        7. XInput
        8. XNA Math
        9. DirectCompute
        10. DirectSetup
        11. Windows Games Explorer
        12. DirectInput
      2. Obsolete DirectX Components
        1. DirectDraw
        2. DirectPlay
        3. DirectShow
        4. DirectMusic
        5. DirectSound
        6. The Components Object Model
    4. Introducing Direct3D 11
      1. Stages of Direct3D 11
    5. Direct3D 11 Considerations
    6. DirectX Tools
      1. Sample Browser and Documentation
      2. PIX
      3. Caps Viewer
      4. Diagnostic Tools
      5. Texture Tool
      6. Error Lookup
      7. Control Panel
      8. Cross-Platform Audio Creation Tool
      9. Game Definition File Editor
      10. Down-Level Hardware
    7. Summary
    8. Chapter Questions
  6. 2. Your First DirectX Program
    1. Creating the Project
    2. Adding Windows Code
      1. The Main Entry Point
      2. Windows Initialization
      3. Windows Callback Procedure
    3. Time for Direct3D
      1. Adding the DirectX Libraries
      2. Initializing Direct3D
      3. Driver Types and Features Levels
      4. Device and Swap Chain Creation
      5. Render Target View Creation
      6. The Viewport
      7. Clearing and Displaying the Screen
      8. Cleaning Up
      9. Formats
    4. The Blank D3D Window
      1. Design of the Template Framework
      2. The Direct3D Class
      3. The Blank Window Demo Class
      4. Updating the Application Loop
    5. DirectX Error Handling Library
      1. Error Handling Functions
      2. Error Handling Macros
    6. Summary
    7. Chapter Questions
  7. 3. 2D Rendering
    1. 2D Game Development
      1. Textures
      2. Sprites
    2. 2D Geometry
      1. What Is a Vertex?
      2. Definition of a Triangle
      3. Vertex Buffers
      4. Input Layout
      5. Drawing a 2D Triangle
    3. 2D Triangle Demo
      1. Loading the Geometry
      2. Rendering the Geometry
    4. Texture Mapping
      1. Texture Interfaces
      2. MIP Maps
      3. Texture Details
      4. Texture Mapping Demo
    5. Sprites
      1. Z-Ordering
      2. Sprite Image
      3. Getting Sprites to the Screen
      4. Positioning and Scaling Sprites
    6. The Game Sprite Demo
      1. Creating and Rendering the Game Sprite
    7. Summary
    8. What You Have Learned
    9. Chapter Questions
    10. On Your Own
  8. 4. Text and Font Rendering
    1. Text in Games
    2. Adding Text
      1. Textured Fonts
      2. A Font System Explained
    3. Creating a Font System Using Sprites
    4. Advanced Topics
      1. In-Game Text Boxes
      2. In-Game Console Window
      3. Game Menus
      4. Heads-Up Display
    5. Summary
    6. Chapter Questions
    7. On Your Own
  9. 5. Input Detection and Response
    1. I Need Input
      1. Input Options
    2. Keyboard Input
      1. Win32 Keyboard Input
      2. DirectInput Keyboard Input
        1. Creating the DirectInput Object
        2. Creating the DirectInput Device
        3. Setting the Data Format
        4. Setting the Cooperation Level
        5. Acquiring the Device
        6. Getting Input
        7. Enumerating Input Devices
        8. Getting the Device Capabilities
        9. Reacquiring a Device
        10. Cleaning Up DirectInput
      3. DirectInput Keyboard Demo
    3. Mouse Input
      1. DirectInput Mouse Input
    4. XInput—Game Controllers
      1. Setting Up XInput
      2. Controller Vibrations
      3. XInput for Input
      4. Controller Capabilities
      5. Battery Life
      6. Keystrokes
      7. Headset Sound
      8. XInput Demo
    5. Summary
    6. What You Have Learned
    7. Chapter Questions
    8. On Your Own
  10. 6. 3D Primer
    1. XNA Math
    2. Utilities
    3. Points
    4. Vectors
      1. Vector Arithmetic
      2. Distance Between Vectors
      3. Determining the Length of a Vector
      4. Normalize a Vector
      5. Cross Product
      6. Dot Product
    5. 3D Space
      1. Coordinate Systems
        1. Left-Handed Coordinate Systems
        2. Right-Handed Coordinate Systems
      2. Transformations
      3. World Transformations
      4. View Transformations
      5. Projection Transformations
      6. Transforming an Object
    6. Matrices
      1. The Identity Matrix
      2. Matrix Scaling
      3. Matrix Translation
      4. Matrix Rotation
      5. Matrix Concatenation
    7. Cube Demo
    8. Additional XNA Math Topics
      1. Compiler Directives
      2. Constants
      3. Macros
      4. Structures and Types
      5. Additional Functions
        1. Color Functions
        2. Conversion Functions
        3. Scalar Functions
    9. Additional Math Structures and Topics
      1. Game Physics and Collision Detection
    10. Summary
    11. What You Have Learned
    12. Chapter Questions
  11. 7. Shaders and Effects
    1. Shaders in Direct3D
      1. History of Programmable Shaders
    2. Effect Files
      1. Effect File Layout
      2. Loading an Effect File
      3. External Variables and Constant Buffers
      4. Input and Output Structures
      5. Technique Blocks
      6. Rasterizer States
    3. High Level Shading Language
      1. Variable Types
      2. Semantics
      3. Function Declarations
    4. Vertex Shaders
    5. Pixel Shaders
      1. Texture Color Inversion
      2. Color Shifting
      3. Multitexturing
    6. Geometry Shaders
      1. Geometry Shader Function Declaration
      2. The Geometry Shader Explained
      3. Introduction to Lighting
        1. The Ambient Term
        2. The Diffuse Term
        3. Specular Term
        4. Putting It All Together
    7. Summary
    8. What You Have Learned
    9. Chapter Questions
    10. On Your Own
  12. 8. Cameras and Models in Direct3D
    1. Cameras in Direct3D
      1. Look-At Camera Demo
      2. Arc-Ball Camera Demo
    2. Meshes and Models
      1. The OBJ File Format
      2. Reading Tokens from a File
      3. Loading Meshes from OBJ Files
    3. Advanced Topics
      1. Complex Cameras
      2. 3D Level Files
    4. Summary
    5. What You Have Learned
    6. Chapter Questions