0

Hi I am trying to do Tutorial2 of https://code.msdn.microsoft.com/windowsdesktop/Direct3D-Tutorial-Win32-829979ef#content.

In Tutorial 1 I had to add #pragma comment(lib,"d3d11.lib") to make it work.

In Tutorial 2, I added 2 pragmas,#pragma comment(lib,"d3d11.lib") and #pragma comment(lib,"D3DCompiler.lib"). But still I can't build it. The .hlsl files produce the error:{Error X1507 failed to open source file: 'Tutorial02.fx'}. I tried to locate Tutorial02.fx in my computer but couldn't. Any idea where this file would be or how to make this work? I am using Visual studio 2015 community edition.

Niraj
  • 25
  • 4

1 Answers1

0

Since you are using VS 2015, I assume you opened the Tutorials.sln and upgraded them to v140, yes?

I just did that and was able to build all the tutorials for all configurations without any problem using VS 2015. It sounds like you may not have expanded the package correctly because Tutorial02.fx is clearly present in the package.

Note that I've not updated the MSDN copies of my samples in some time. I now maintain them on GitHub.

Chuck Walbourn
  • 38,259
  • 2
  • 58
  • 81
  • Thanks for answering. I was just wondering how does this type of file format get created. I know how to add .hlsl file. But I don't know how this file(Tutorial02.fx) was added. In Visual studio, I can add code files, resource files, data file,web file , utility file,property sheets, HLSL file and Graphics file by right clicking on the project in the solution explorer and then clicking "add item". I couldn't find a way to add .fx file. How was this file added ? In .cpp file, I found the line "hr = CompileShaderFromFile( L"Tutorial02.fx", "VS", "vs_4_0", &pVSBlob ); ". Is it creating the file? – Niraj Jul 26 '16 at 10:23
  • ``.fx`` files are handled exactly like ``.hlsl`` files by Visual Studio. However, for the tutorial the ``.fx`` file is not compiled directly because Visual Studio can't compile the same source file more than once. Therefore the two .hlsl files are using ``#include`` of the ``.fx`` file. This is just for validation of the shader to make it easier to play with because as you see in the code, the ``.fx`` file is complied twice by the code. – Chuck Walbourn Jul 26 '16 at 15:00
  • In real applications, you want to prefer to build all your shaders at compile time of your application rather than at runtime when your program runs. For simplicity, these tutorials do the building at compile time (for easy validation) and at runtime (for easy use). – Chuck Walbourn Jul 26 '16 at 15:23