directx11編程中遇到的錯誤及解決方法


(2016-05-10)xnamath.h 報錯: 在標識符“XMConvertToRadians”的前面

報錯如下:

1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(159): error C2146: 語法錯誤: 缺少“;”(在標識符“XMConvertToRadians”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(159): error C2433: “FLOAT”: 不允許在數據聲明中使用“__forceinline”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(159): error C4430: 缺少類型說明符 - 假定為 int。注意: C++ 不支持默認 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(159): error C2146: 語法錯誤: 缺少“)”(在標識符“fDegrees”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(159): error C4430: 缺少類型說明符 - 假定為 int。注意: C++ 不支持默認 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(159): error C2059: 語法錯誤:“)”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(159): error C2143: 語法錯誤 : 缺少“;”(在“{”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(159): error C2447: “{”: 缺少函數標題(是否是老式的形式表?)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(160): error C2146: 語法錯誤: 缺少“;”(在標識符“XMConvertToDegrees”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(160): error C2433: “FLOAT”: 不允許在數據聲明中使用“__forceinline”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(160): error C4430: 缺少類型說明符 - 假定為 int。注意: C++ 不支持默認 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(160): error C2086: “int FLOAT”: 重定義
1> d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(159) : 參見“FLOAT”的聲明
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(160): error C2146: 語法錯誤: 缺少“)”(在標識符“fRadians”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(160): error C4430: 缺少類型說明符 - 假定為 int。注意: C++ 不支持默認 int
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(160): error C2059: 語法錯誤:“)”
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(160): error C2143: 語法錯誤 : 缺少“;”(在“{”的前面)
1>d:\program files\microsoft directx sdk (june 2010)\include\xnamath.h(160): error C2447: “{”: 缺少函數標題(是否是老式的形式表?)

解決方法:

將 #include <xnamath.h>頭文件放到 

#include <D3D11.h>
#include <d3dx11.h>
#include <DxErr.h>
#include <D3DCompiler.h> // for shader flags

的后面即可

 

(2016-06-17)windows10中創建Direct3D11設備出現0x887a002d錯誤,提示應用程序請求的操作依賴於已缺失或不匹配的 SDK 組件

最近把系統中win7升級到了win10,在運行之前的dx11demo時發現彈出的都是空白窗口,調試時發現在代碼中調用D3D11CreateDevice函數返回0x887a002d, 錯誤消息是"應用程序請求的操作依賴於已缺失或不匹配的 SDK 組件。

解決方法:原來windows10沒有自帶圖形調試器, 調用D3D11CreateDevice函數時Flags參數包含D3D11_CREATE_DEVICE_DEBUG就會創建失敗.

對於 Windows 10,圖形診斷工具現已作為 Windows 內的可選功能提供。若要使用在運行時和 Visual Studio 中提供的圖形診斷功能來開發 DirectX 應用或游戲,請安裝可選“圖形工具”功能:

  1. 轉到“設置”、依次選擇“系統”和“可選功能”,然后單擊“添加功能”
  2. 在“添加功能”列表中,單擊“圖形工具”

微軟官方說明:https://msdn.microsoft.com/library/windows/apps/dn914047.aspx


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM