我正在阅读一本关于如何使用driectx 11进行编程的书,但我仍然有3个错误,即使我已经将它编程为完全相同并且现在检查差异了近一整天。我有3个错误
error LNK1120: 1 unresolved externals C:\Users\Me\documents\visual studio 2013\Projects\TestX engine\Debug\TestX engine.exe 1 1 TestX engine
Error 2 error LNK2019: unresolved external symbol _D3DX11CreateEffectFromMemory@20 referenced in function "private: void __thiscall BoxApp::BuildFX(void)" (?BuildFX@BoxApp@@AAEXXZ) C:\Users\Me\documents\visual studio 2013\Projects\TestX engine\TestX engine\Box.obj TestX engine
Error 1 error LNK2005: _WinMain@16 already defined in Box.obj C:\Users\Me\documents\visual studio 2013\Projects\TestX engine\TestX engine\InitDirect3D.obj TestX engine
我的应用代码是:
class BoxApp : public Framework_App
{
public:
BoxApp(HINSTANCE hInstance);
~BoxApp();
bool Init();
void OnResize();
void UpdateScene( float dt);
void DrawScene();
void OnMouseDown(WPARAM btnState, int x, int y);
void OnMouseUp(WPARAM btnState, int x, int y);
void OnMouseMove(WPARAM btnState, int x, int y);
private:
void BuildGeometryBuffers();
void BuildFX();
void BuildVertexlayout();
ID3D11Buffer* mBoxVB;
ID3D11Buffer* mBoxIB;
ID3DX11Effect* mFX;
ID3DX11EffectTechnique* mTech;
ID3DX11EffectMatrixVariable* mfxWorldViewProj;
ID3D11InputLayout* inputLayout;
XMFLOAT4X4 mWorld;
XMFLOAT4X4 mView;
XMFLOAT4X4 mProj;
float mTheta, mPhi, mRadius;
POINT mLastMousePos;
};
问题应该在这些部分的某处,但我无法找到它们:
int WINAPI WinMain(HINSTANCE hInstance, HINSTANCE PrevhInstance, PSTR cmdLine, int showCmd){
BoxApp theApp(hInstance);
if (!theApp.Init())
{
return 0;
}
return theApp.App_Run();
}
和
void BoxApp::BuildFX()
{
DWORD shaderFlags = 0;
ID3D10Blob * compiledShader;
ID3D10Blob * compiledShaderMsgs;
HRESULT hr = D3DX11CompileFromFile((LPSTR)"mColor.fx", 0, 0, 0, "fx_5_0", shaderFlags, 0, 0, &compiledShader, &compiledShaderMsgs, 0);
if (compiledShaderMsgs != 0)
{
MessageBoxA(0, (char*)compiledShaderMsgs->GetBufferPointer(), 0, 0);
ReleaseCOM(compiledShaderMsgs);
}
D3DX11CreateEffectFromMemory(compiledShader->GetBufferPointer(), compiledShader->GetBufferSize(), 0, MainD3DDevice, &mFX);
ReleaseCOM(compiledShader);
mTech = mFX->GetTechniqueByName("ColorTech");
mfxWorldViewProj = mFX->GetVariableByName("gWorldViewProj")->AsMatrix();
}
在第二位特别是:D3DX11CreateEffectFromMemory(compiledShader->GetBufferPointer(), compiledShader->GetBufferSize(), 0, MainD3DDevice, &mFX);
事先谢谢你,我真的很感激。