Book Image

Learning Windows 8 Game Development

By : Michael Quandt
Book Image

Learning Windows 8 Game Development

By: Michael Quandt

Overview of this book

With the recent success of a lot of smaller games, game development is quickly becoming a great field to get in to. Mobile and PC games are on the rise, and having a way to create a game for all types of devices without rewriting everything is a huge benefit for the new Windows 8 operating system. In this book, you will learn how to use cutting-edge technologies like DirectX and tools that will make creating a game easy. This book also allows you to make money by selling your games to the world. Learning Windows 8 Game Development teaches you how to create exciting games for tablets and PC on the Windows 8 platform. Make a game, learn the techniques, and use them to make the games you want to play. Learn about graphics, multiplayer options, how to use the Proximity + Socket APIs to add local multiplayer, how to sell the game outright, and In-App Purchases. Learning Windows 8 Game Development guides you from the start of your journey all the way to developing games for Windows by showing you how to develop a game from scratch and sell it in the store.With Learning Windows 8 Game Development, you will learn how to write the code required to set everything up, get some graphics on screen, and then jump into the fun part of adding gameplay to turn a graphics sample into a proper game. From there, you'll look at how to add awesome features to your game like networking, motion controls, and even take advantage of new Windows 8 features like live tiles and sharing to make your players want to challenge their friends and keep playing. This book wraps up by covering the only way a good game can finish development: by shipping the game on the Windows Store. You'll look at the things to remember to make certification painless and some great tips on how to market and sell your game to the public.
Table of Contents (17 chapters)
Learning Windows 8 Game Development
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Vertices and triangles


All 3D models consist of a collection of points in space called vertices. These vertices (singular: vertex) define the shape of the model when combined. Each vertex is a coordinate in space, represented in vector form. They can, however, also contain further information, such as the following:

  • Color

  • Normal

  • Texture coordinates

  • Anything else you need to draw the model

These vertices are used by the GPU to draw the model; however, the GPU by itself has no way of understanding how they relate to each other, and how to draw the correct model. This is resolved by arranging vertices into the most basic shape possible: a triangle. If you consider that one vertex alone as a point, which along with a second forms a line, then a third vertex creates a triangle, which is the simplest polygon you can create. The GPU can then draw these triangles by taking the vertices, three at a time, and using those values to generate an area to draw.

A model created in a 3D editing program can have thousands of these vertices, all forming triangles that define the final shape. The following diagram shows one such instance:

The more vertices drawn, the more work the GPU has to do, and the larger impact on performance a model takes. There is also no point drawing vertices that are completely hidden by other triangles on the same model.

This is where backface culling comes into play. Backface culling allows the GPU to only draw triangles facing the camera, saving time on triangles that are on the other side of the object and usually invisible. Now how would you determine if a triangle is on the back of an object, when the object could have any orientation, and the camera could be in any position?

This is done by ensuring that all triangles facing the camera have their vertices specified in a clockwise-winding order, which is demonstrated in the diagram that follows. When sent to the GPU, the order is evaluated and if the vertices are submitted in a counter-clockwise fashion, they are discarded as they should be facing away from the camera, and are most likely hidden.

Winding order

This can be disabled or changed using the custom states that are set on the GPU. By disabling or reversing the winding order that gets culled, you can tailor the behavior of the backface culling system to allow for different rendering techniques.