我在讀這本書介紹由Frank Luna編寫的DirectX 11編程,我遇到了Effects11的問題。D3D11 D3DX11CreateEffectFromMemory返回E_NOITERFACE
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();
}
我正在使用此代碼來加載我的效果文件。問題是我在D3DX11CreateEffectFromMemory處收到E_NOINTERFACE錯誤。有趣的部分是運行本書中的示例成功調用函數,並且使用相同的靜態庫(d3dx11effect.h和Effect11d.lib)。我試着編譯效果,然後加載它,但問題仍然存在。
感謝您的幫助。
我發現這個人(E_NOINTERFACE result from D3DX11CreateEffectFromMemory)有完全相同的問題,他通過降級到VS2010解決了這個問題。我會很高興與任何其他解決方案。
我照你說的做了,似乎現在工作。非常感謝您幫助我解決這個問題並提供所有這些帖子。一旦我對DX有了更多的瞭解,我會嘗試擺脫D3DX。再次感謝。 – wajsic