0

I'm probably overlooking something simple, however compilation of the shader compilation call is claiming there is no instance of overloaded function, despite the code working in other projects.

//Globals
IDXGISwapChain *swapChain;          //Pointer to the swapchain interface
ID3D11Device *dev;                  //Pointer to the Direct3D Device interface
ID3D11DeviceContext *devcon;        //Pointer to the Direct3D Device context
ID3D11RenderTargetView *backBuffer;

//Shaders
ID3D11VertexShader* pVS;
ID3D11PixelShader* pPS;

void InitPipeline()
{
//Load and Compile Shaders
ID3D10Blob *VS;
ID3D10Blob *PS;

D3DX11CompileFromFile(L"shader.shader", 0, 0, "VShader", "vs_4_0", 0, 0, 0, &VS, 0, 0);
D3DX11CompileFromFile(L"shader.shader", 0, 0, "PShader", "ps_4_0", 0, 0, 0, &PS, 0, 0);

//encapsulate shaders into shader objects
dev->CreateVertexShader(VS->GetBufferPointer(), VS->GetBufferSize(), NULL, &pVS);
dev->CreatePixelShader(PS->GetBufferPointer(), PS->GetBufferSize(), NULL, &pPS);

//Set Shader Objects
devcon->VSSetShader(pVS, 0, 0);
devcon->PSSetShader(pPS, 0, 0);

}

The error is:

no instance of overloaded function "D3DX11CompileFromFileA" matches the argument list argument types are: (const wchar_t [14], int, int, const char [8], const char [7], int, int, int, ID3D10Blob **, int, int)    
MuertoExcobito
  • 9,741
  • 2
  • 37
  • 78
Nixxus
  • 99
  • 1
  • 1
  • 7
  • please give the text of the error you're getting. – MuertoExcobito Jun 10 '15 at 13:31
  • 1 IntelliSense: no instance of overloaded function "D3DX11CompileFromFileA" matches the argument list argument types are: (const wchar_t [14], int, int, const char [8], const char [7], int, int, int, ID3D10Blob **, int, int) d:\Documents\GitHub\Matrixology\Engine\Engine\D3D.cpp 73 – Nixxus Jun 10 '15 at 17:49

1 Answers1

1

D3DX11CompileFromFileA is an ANSI string method. You are attempting to pass a wide character constant into it as the first parameter (L"shader.shader"). See this question for more details on the difference between ANSI and UNICODE functions in Windows APIs.

You will either need to change your project settings, so that the CharacterSet property is UNICODE (see here for documentation), or you can pass in a UTF-8 string (and continue to use the ANSI method), by removing the L in front of the string constant.

Community
  • 1
  • 1
MuertoExcobito
  • 9,741
  • 2
  • 37
  • 78
  • Better yet, just use ``D3DCompileFromFile`` directly rather than the legacy D3DX wrapper... See [this blog post](http://blogs.msdn.com/b/chuckw/archive/2012/05/07/hlsl-fxc-and-d3dcompile.aspx) – Chuck Walbourn Jun 11 '15 at 05:20