Using the DirectX App (XAML) project, the HLSL part, CSO and so forth

Well there are a lot of changes between Windows 8 and Windows 8.1, especially if you are using DirectX to build the next amazing game.  You are doing it the hard way, but I am with you on this.  There are a bunch of well defined game engines, but sometimes you just have to start from the basics.

One of the big changes is that the HLSL compiles in a “.cso” file, which means that you can like the files just like you might be doing in C++/11 but know you could.  Smile This maps to the OpenGL ES 2.0 process. 

To see how to modify your OpenGL ES 2.0  shaders to DirectX Shaders see:

This is a big change, which means you should take a look at the link:

  • HLSL shader linking
  • The link describes a  number of things you need to consider when using the process of HLSL

But if you want to see how it looks in the code you can simply create a new project in C++ and select the DirectX App (XAML). 

In this project you could do a ctrl+F (find) and then search for cso.  If you do you will see the code like the following:

    1: void Sample3DSceneRenderer::CreateDeviceDependentResources()
    2: {
    3:     // Load shaders asynchronously.
    4:     auto loadVSTask = DX::ReadDataAsync(L"SampleVertexShader.cso");
    5:     auto loadPSTask = DX::ReadDataAsync(L"SamplePixelShader.cso");

auto

The auto keyword is discussed in another blog of mine, and is discussed all over the place, I love it.  If you are a C# user than this is another reason to switch to C++.

DX

The DX refers to the namespace inside of the DirectXHelper.h which in VS 2013 is under the Common folder by default, it doesn’t have to be there, but it does clean up the project. Well I almost wrote that ReadDataAsync is part of the PPL library but it ISN’T!  ReadDataAsync() is a method implemented for the template that reads in a CSO file as an array of byte data (fileData).

Conclusion

Well that is it for now.  If you are going to use the GDC 2013 templates you will need to use VS 2012 to get them built.  Then you can do what you want with them.

Here are the links again: