Game Development Reference
In-Depth Information
After the surfaces have been cleared, we present the back buffer by
calling the IDirect3DDevice9::Present method.
The window procedure method handles a couple of events; namely
it allows us to exit the application by pressing the Escape key.
LRESULT CALLBACK d3d::WndProc(HWND hwnd, UINT msg, WPARAM wParam,
LPARAM lParam)
{
switch( msg )
{
case WM_DESTROY:
::PostQuitMessage(0);
break;
case WM_KEYDOWN:
if( wParam == VK_ESCAPE )
::DestroyWindow(hwnd);
break;
}
return ::DefWindowProc(hwnd, msg, wParam, lParam);
}
Finally, WinMain performs the following steps:
1. Initializes the main display window and Direct3D
2. Calls the Setup routine to set up the application
3. Enters the message loop using Display as the display function
4. Cleans up the application and finally releases the IDirect3D-
Device9 object
int WINAPI WinMain(HINSTANCE hinstance,
HINSTANCE prevInstance,
PSTR cmdLine,
int showCmd)
{
if(!d3d::InitD3D(hinstance,
800, 600, true, D3DDEVTYPE_HAL, &Device))
{
::MessageBox(0, "InitD3D() - FAILED", 0, 0);
return 0;
}
if(!Setup())
{
::MessageBox(0, "Setup() - FAILED", 0, 0);
return 0;
}
d3d::EnterMsgLoop( Display );
Cleanup();
Device->Release();
Search WWH ::




Custom Search