예제 #1
0
//--------------------------------------------------------------------------------------
// Entry point to the program. Initializes everything and goes into a message processing 
// loop. Idle time is used to render the scene.
//--------------------------------------------------------------------------------------
int WINAPI wWinMain( _In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPWSTR lpCmdLine, _In_ int nCmdShow )
{
    UNREFERENCED_PARAMETER( hPrevInstance );
    UNREFERENCED_PARAMETER( lpCmdLine );

    if( FAILED( InitWindow( hInstance, nCmdShow ) ) )
        return 0;

	device = Device();
    if( FAILED( device.InitDevice(g_hWnd, g_hInst) ) )
    {
        device.CleanupDevice();
        return 0;
    }

    // Main message loop
    MSG msg = {0};
	//Check for escape key exit
    while( WM_QUIT != msg.message)
    {
        if( PeekMessage( &msg, nullptr, 0, 0, PM_REMOVE ) )
        {
            TranslateMessage( &msg );
            DispatchMessage( &msg );
        }
		else
		{
			device.Render(g_hWnd);
			if (input.IsQuitting()) break;
		}
    }

    device.CleanupDevice();
    return ( int )msg.wParam;
}