最近研究Directx9.0做的游戏,发觉就是标准的前后台,呵呵。
//----------------------------------------------------------------------------- // Name: WinMain() // Desc: The application's entry point //----------------------------------------------------------------------------- INT WINAPI WinMain( HINSTANCE hInst, HINSTANCE, LPSTR, INT ) { // Register the window class WNDCLASSEX wc = { sizeof(WNDCLASSEX), CS_CLASSDC, MsgProc, 0L, 0L, GetModuleHandle(NULL), NULL, NULL, NULL, NULL, "D3D Tutorial", NULL }; RegisterClassEx( &wc );
// Create the application's window HWND hWnd = CreateWindow( "D3D Tutorial", "D3D Tutorial 02: Vertices", WS_OVERLAPPEDWINDOW, 100, 100, 300, 300, GetDesktopWindow(), NULL, wc.hInstance, NULL );
// Initialize Direct3D if( SUCCEEDED( InitD3D( hWnd ) ) ) { // Create the vertex buffer if( SUCCEEDED( InitVB() ) ) { // Show the window ShowWindow( hWnd, SW_SHOWDEFAULT ); UpdateWindow( hWnd );
// Enter the message loop MSG msg; ZeroMemory( &msg, sizeof(msg) );
while( msg.message!=WM_QUIT ) //此处循环,包含WINDOW系统使用的消息处理和游戏的主循环 { if( PeekMessage( &msg, NULL, 0U, 0U, PM_REMOVE ) ) { TranslateMessage( &msg ); DispatchMessage( &msg ); } else Render(); //此处就是游戏的主循环处,单片机中的main主循环 } } }
UnregisterClass( "D3D Tutorial", wc.hInstance ); return 0; }
|