Reputation: 419
I'm reading the book Introduction to DirectX 11 Programming by Frank Luna and I'm having a problem with Effects11.
void BoxApp::BuildFX()
{
DWORD shaderFlags = 0;
#if defined( DEBUG ) || defined( _DEBUG )
shaderFlags |= D3D10_SHADER_DEBUG;
shaderFlags |= D3D10_SHADER_SKIP_OPTIMIZATION;
#endif
ID3D10Blob* compiledShader = 0;
ID3D10Blob* compilationMsgs = 0;
HRESULT hr = D3DX11CompileFromFile(L"FX/color.fx", 0, 0, 0, "fx_5_0", shaderFlags,
0, 0, &compiledShader, &compilationMsgs, 0);
// compilationMsgs can store errors or warnings.
if( compilationMsgs != 0 )
{
MessageBoxA(0, (char*)compilationMsgs->GetBufferPointer(), 0, 0);
ReleaseCOM(compilationMsgs);
}
// Even if there are no compilationMsgs, check to make sure there were no other errors.
if(FAILED(hr))
{
DXTrace(__FILE__, (DWORD)__LINE__, hr, L"D3DX11CompileFromFile", true);
}
HR(D3DX11CreateEffectFromMemory(compiledShader->GetBufferPointer(), compiledShader->GetBufferSize(),
0, md3dDevice, &mFX));
// Done with compiled shader.
ReleaseCOM(compiledShader);
mTech = mFX->GetTechniqueByName("ColorTech");
mfxWorldViewProj = mFX->GetVariableByName("gWorldViewProj")->AsMatrix();
}
I'm using this code to load my effect file. The problem is that I get E_NOINTERFACE error at D3DX11CreateEffectFromMemory. The interesting part is that running the sample from the book calls the function successfully and it's using excatly the same static lib ( d3dx11effect.h and Effect11d.lib ). I tried even compiling the effect first and then loading it but the problem persists.
Thanks for help in advance.
I found out that this guy (E_NOINTERFACE result from D3DX11CreateEffectFromMemory) had exactly the same problem and he solved it by downgrading to VS2010. I would be very happy with any other solutions.
Upvotes: 0
Views: 1306
Reputation: 11
Project property -> Configuration Properties -> General -> Platform Toolset -> change the "Visual studio 2013 (v120)" to "Visual Studio 2013 - Windows XP (v120_xp)"
Hope this could be helpful.
Upvotes: 1
Reputation: 1667
compile source code from DXSDK Sample With VS2010
C:\Program Files (x86)\Microsoft DirectX SDK (February 2010)\Samples\C++\Effects11\Effects11_2008.sln
copy D3DX11EffectsD.lib to your lib path, and linked it.
Upvotes: 0
Reputation: 41047
For your specific problem, the issue is that you are trying to use a static C++ library built with VS 2010 with a newer version of the Visual C++ toolset, which can cause problems. The solution is to build the Effects library from source with your current toolset.
The latest and complete source for the Effects library for Direct3D 11 is available on CodePlex & GitHub. If you are using VS 2013, you can get a copy for Windows desktop apps from NuGet as well.
Unfortunately, Frank's book was written and published just before a major shift in how developers get the latest headers, libraries, tools, and samples for DirectX and the deprecation of the legacy DirectX SDK. See MSDN and this blog post for some details. I've made some specific notes about Frank's books here as well.
You haven't mentioned it explicitly, but I assume you are using either VS 2012 or VS 2013 which includes the Windows 8.x SDK. You can use the legacy DirectX SDK with this toolset with some project file tweaks, but you should keep in mind that all versions of D3DX9, D3DX10, and D3DX11 are deprecated. See Living without D3DX for replacements for Direct3D 11.
See also DirectX SDKs of a certain age, DirectX SDK Samples Catalog, and DirectX SDK Tools Catalog.
Upvotes: 2