我宣佈屬性WNDCLASSEX wc
在我的頭文件,像這樣:爲什麼我無法初始化WNDCLASSEX wc?
private:
HWND hWnd;
LPDIRECT3D9 g_pD3D; // Used to create the D3DDevice
LPDIRECT3DDEVICE9 g_pd3dDevice; // Our rendering device
WNDCLASSEX wc;
我想初始化它在我的init()函數,就像這樣:
void RAT_RendererDX9::Init(RAT_WindowManager* argWMan)
{
wMan = argWMan;
// Register the window class
wc =
{
sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0, 0,
GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
"D3D Tutorial", NULL
};
RegisterClassEx(&wc);
hWnd = CreateWindow("", "abc", WS_OVERLAPPEDWINDOW, 10, 10, 20, 20,
NULL, NULL, wc.hInstance, NULL);
g_pD3D = (LPDIRECT3D9)Direct3DCreate9(D3D_SDK_VERSION);
D3DPRESENT_PARAMETERS d3dpp;
ZeroMemory(&d3dpp, sizeof(d3dpp));
d3dpp.Windowed = TRUE;
d3dpp.SwapEffect = D3DSWAPEFFECT_DISCARD;
d3dpp.BackBufferFormat = D3DFMT_UNKNOWN;
g_pD3D->CreateDevice(D3DADAPTER_DEFAULT, D3DDEVTYPE_HAL, hWnd,
D3DCREATE_SOFTWARE_VERTEXPROCESSING,
&d3dpp, &g_pd3dDevice);
}
不過,我得到以下因爲它的錯誤:
1> E:\ rat_engine \ rat_engine \ rat_engine \ rat_rendererdx9.cpp(18):錯誤 C2059:語法錯誤: '{'
1> e:\ rat_engine \ rat_engine \ rat_engine \ rat_rendererdx9.cpp(18):錯誤 C2143:語法錯誤:缺少';'之前 '{'
1> E:\ rat_engine \ rat_engine \ rat_engine \ rat_rendererdx9.cpp(19):錯誤 C3867: 'RAT_ENGINE :: RAT_RendererDX9 :: MsgProc':函數調用缺少 參數列表;使用 '& RAT_ENGINE :: RAT_RendererDX9 :: MsgProc' 創建 指針構件
1> E:\ rat_engine \ rat_engine \ rat_engine \ rat_rendererdx9.cpp(22):錯誤 C2143:語法錯誤:缺少「; 「 '}'
但我實際上從教程中複製了初始化,唯一的例外是wc在WinMain()函數中初始化,而不是Init()函數。
爲什麼它不工作,我該如何解決它?