2013-05-12 35 views
0

我正在關注一本名爲「使用DirectX 9.0c進行3D遊戲編程的介紹:着色器方法」,並且所有示例都使用了多字節字符集,而我沒有想要使用它,我不希望我的項目成爲多再見的主角。我的問題是書上有一個調試功能,這裏是代碼。使用Unicode字符集定義調試

//debug 
#if defined(DEBUG) | defined(_DEBUG) 
    #ifndef HR 
    #define HR(x)          \ 
    {             \ 
     HRESULT hr = x;        \ 
     if(FAILED(hr))         \ 
     {            \ 
      DXTrace(__FILE__, __LINE__, hr, #x, TRUE); \ 
     }            \ 
    } 
    #endif 

#else 
    #ifndef HR 
    #define HR(x) x; 
    #endif 
#endif 

然後在我的.cpp文件上,我用這本書上的代碼來創建設備。

HR(md3dObject->CreateDevice(
     D3DADAPTER_DEFAULT, // primary adapter 
     mDevType,   // device type 
     mhMainWnd,   // window associated with device 
     devBehaviorFlags, // vertex processing 
     &md3dPP,   // present parameters 
     &gd3dDevice));  // return created device 

然後錯誤是。 錯誤C2664:'DXTraceW':無法將參數4從'const char [107]'轉換爲'const WCHAR *'

希望有人能幫助我。謝謝。

+0

這本書是教你不止一個不好的做法。 CreateDevice()失敗必須結束程序。擺脫這本書。 – 2013-05-12 02:31:00

回答

1

嘗試將參數#x更改爲L#x,或者使用微軟的宏_T(#x)