我试图在我的C++项目中使用DirectX 11,但是在编译时出现错误消息:

D3D11 ERROR: D3D11 header version mismatch.
The application was compiled against and will only work with D3D11_SDK_VERSION (1), but the currently installed runtime is version (7).
Recompile the application against the appropriate SDK for the installed runtime.

我不知道是什么原因造成的。有没有一种方法可以切换尝试为其编译的运行时?我从2010年6月开始安装DirectX SDK。在这里尝试遵循Microsoft的说明(http://msdn.microsoft.com/zh-cn/library/windows/desktop/ee663275(v=vs.85).aspx)一切都已正确设置为可以使用DirectX。我仍然收到此错误。有谁知道这可能是什么原因以及如何解决?我正在使用Windows 8 64位和Visual Studio 2012。

供引用

我以一个空的C++解决方案而不是DirectX应用程序开始的。这是我的代码中处理DirectX的部分
#include <amp.h>
#include <amp_math.h>
#include <amp_graphics.h>
#include <d3d11.h>
#include <dxgi.h>

#pragma comment(lib, "d3d11")
#pragma comment(lib, "dxgi")

// Inside main()
    IDXGIAdapter* pAdapter = nullptr; // Use default adapter

    unsigned int createDeviceFlags = D3D11_CREATE_DEVICE_DISABLE_GPU_TIMEOUT;
    ID3D11Device *pDevice = nullptr;
    ID3D11DeviceContext *pContext = nullptr;
    D3D_FEATURE_LEVEL featureLevel;
    HRESULT hr = D3D11CreateDevice(pAdapter,
                                    D3D_DRIVER_TYPE_UNKNOWN,
                                    NULL,
                                    createDeviceFlags,
                                    NULL,
                                    0,
                                    D3D11_SDK_LAYERS_VERSION,
                                    &pDevice,
                                    &featureLevel,
                                    &pContext);
    if(FAILED(hr) ||
        ((featureLevel != D3D_FEATURE_LEVEL_11_1) &&
        (featureLevel != D3D_FEATURE_LEVEL_11_0)))
    {
        std::wcerr << "Failed to create Direct3D 11 device" << std::endl;
        return 10;
    }

最佳答案

您需要使用D3D11_SDK_LAYERS_VERSION作为here来代替D3D11_SDK_VERSION

关于c++ - 在Visual Studio 2012中使用DirectX 11,我们在Stack Overflow上找到一个类似的问题:https://stackoverflow.com/questions/13785431/

10-13 05:02