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

Indices


You may have noticed that we need to render each triangle with a new set of vertices, which can lead to a lot of vertices sitting in exactly the same place. This is fairly inefficient at high triangle counts, and takes up a lot of memory, especially when you have multiple blocks of information stored within a vertex. We can get around this using a concept similar to array indexing. We will start by providing an array of vertices to the GPU; however, instead of defining the order to draw the triangles in the same array, we just provide single vertex entries for each point.

The GPU then uses this alongside an array of indices to define the layout of the triangles. We will save a lot of memory by defining each point by a single integer rather than a full vertex for each triangle corner.

Indices for a quad

If we want to draw the given quad without an index buffer, we will need the following:

Vec3(0, 0, 0)
Vec3(1, 0, 0)
Vec3(0, 1, 0)
Vec3(0, 1, 0)
Vec3(1, 0, 0)
Vec3(1, 1, 0)

Now if we use an index buffer, we can just define four vertices and let the index buffer define the triangles, as follows:

Vec3(0, 0, 0)
Vec3(1, 0, 0)
Vec3(0, 1, 0)
Vec3(1, 1, 0)

Indices = [0, 1, 2, 2, 1, 3]

If you want to create a cube, you just need to define the eight points of the cube and use indices in the right order to create the triangles. In large models with thousands or tens of thousands of vertices this can save quite a lot of memory, and allows dynamic changes to the model without affecting the original vertex list.

Note

Remember that you can never have a negative index in an array, so Direct3D only supports unsigned integer values.