DirectX 11.1 Game Programming

DirectX 11.1 Game ProgrammingReviews
Author: Pooya Eimandar
Pub Date: 2013
ISBN: 978-1-84969-480-3
Pages: 146
Language: English
Format: PDF/EPUB
Size: 10 Mb


DirectX is designed to create eye-popping 3-D visuals and immersive sound effects found in many of today’s PC games. DirectX 11.1 includes numerous improvements from its previous version. It’s designed to be more efficient, leverage the power of today’s multi-core processors, and provide support for sophisticated shading and texturing techniques such as tessellation. DirectX 11.1 Game Programming brings unprecedented power and flexibility to programmers who want to excel in graphical programs. DirectX 11.1 Game Programming is an introduction to creating interactive computer graphics and games, using Direct3D 11.1. You would be guided through the new features of Direct3D along with XAML to build an extensible multithreaded framework for creating 3D applications and games on the Windows 8 metro style platform. DirectX 11.1 Game Programming explores the techniques to set up a 3D multithreaded framework for metro style graphics programs. You would be guided through the process of extending your framework to utilize the advantages of Direct3D 11.1. We would then explore Visual Studio Model editor for loading and editing your assets and learn how to render them with the Direct3D pipeline. We will also explore the supporting inputs such as keyboards, pointers, Xbox controllers, and how to render the complete 3D scene using camera, sound, billboard, tessellation, post processors, and parallel libraries, along with supporting XAML. You would also learn the different techniques of debugging the program and would be well equipped with everything you need to start programming 3D applications and games with DirectX 11.1 on Windows 8 platforms.
What you will learn from this book
– Loading and rendering mesh using the output format of Visual Studio Model Editor
– Draw geometry with texture and compiled shaders
– Load and render meshes using the output format of the Visual Studio Model editor
– Implementing asynchronous resource loading
– Displaying performance data
– Add collision detection, sound, bump mapping, specular mapping, and a billboard system to the framework
– Use tessellation for improving material surfaces
– Compose XAML and Direct3D
– Add post processing and parallel collision detection using C++Amp


Introduction to C++/CX

C++/CX is a great place for developing applications for those game programmers who come from a background of C#, such as XNA Platform, SlimDx, and SharpDx. Also, for those who come from the management background of C++ or native C++, C++/CX won’t disappoint! As mentioned earlier, you can use C++/CX along with XAML, but it is only available under the Metro UI; this means that C++/CX only runs on Windows 8 platforms.

There is no need to use native C++ while using Windows Runtime C++ Template Library(WRL); instead, you can use C++/CX code as a high-level language for using WRL code. In other words, it helps you write simpler code. According to MSDN, the purpose and design of the WRL is inspired by the Active Template Library(ATL), which is a set of template-based C++ classes that simplifies the programming of Component Object Model(COM)objects.

In this chapter, we have introduced the new features of Windows 8, DirectX 11.1, and the new extension of C++, which is called C++/CX. Also, we have set up our first project, added time to our new framework, and initialized the Direct3D device. In the next chapter, we will cover the new features of HLSL in DirectX 11.1, buffers, and the compiled shader objects. Finally, we will outline the new additions of Direct3D 1.1.

The structure of a 3D texture (also known as a volume texture) is similar to 1D and 2D except for the third dimension, which contains the depth parameters. There is no
concept of a 3D texture array, but we can have a 1D texture array and a 2D texture array (the texture cube).

Each texture type can contain mipmap levels. The mipmap improves the quality of the rendered textures by saving the memory bandwidth. It simply represents a lower
resolution version of a texture. The lower resolution mipmap image is used when the object appears far away, and a high resolution mipmap image is used for closer objects.

Rendering a 3D Scene

Composing XAML and Direct3D

Welcome to one of the most amazing features of C++/CX. Most game programmers have the same problem when it comes to developing an editor for their game engine
because it requires a lot of effort.

In order to develop an editor for a game engine, you can start wrapping a native DLL in C# and use a WPF or Windows Form application as the GUI of your game engine; this requires a lot of calls for unmanaged DLLs and involves a lot of pointers which are only available in the unsafe mode of C#. If you don’t prefer this way, instead of using .NET, you can go deep into the native code and then use libraries such as Nokia QT, wxWidgets, or cegui. These libraries are open source and use the standard C++ language, and they also give you standard user controls.

You can also write in your editor using MFC or buy the license of Autodesk Scaleform, which enables developers to increase the power of the Adobe Flash tool that is used to create powerful and immersive user interface environments for video games and beyond.

Before the C++/CX language extensions were released, I wondered why there was no way to have C++ as a code-behind XAML. You could not decide whether you were happy or not when C++/CX was released with Microsoft Windows 8 because it gave you great features just for Metro Style applications, but unfortunately runs only on the Windows 8 runtime libraries. C++/CX consists of both the power of UI designing with XAML and native programming for developers. The following image shows the diagram of building XAML and C++ code: