Main.cpp
上传用户:whgydz
上传日期:2007-01-12
资源大小:2259k
文件大小:2k
源码类别:

其他书籍

开发平台:

HTML/CSS

  1. #include "Game.h"
  2. CGame* g_pGame = NULL;
  3. void CleanUp()
  4. {
  5. SafeDelete(g_pGame);
  6. }
  7. //The windows message handler
  8. LRESULT WINAPI WinProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
  9. {
  10.     switch(msg)
  11.     {
  12.         case WM_DESTROY:
  13.             PostQuitMessage(0);
  14.             return 0;
  15.         break;
  16.         case WM_KEYUP: 
  17.             switch (wParam)
  18.             { 
  19.                 case VK_ESCAPE:
  20.                     //User has pressed the escape key, so quit
  21.                     DestroyWindow(hWnd);
  22.                     return 0;
  23.                 break;
  24.             } 
  25.         break;
  26.     }
  27.     return DefWindowProc(hWnd, msg, wParam, lParam);
  28. }
  29. //Application entry point
  30. INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, INT)
  31. {
  32.     //Register the window class
  33.     WNDCLASSEX wc = {sizeof(WNDCLASSEX), CS_CLASSDC, WinProc, 0L, 0L, 
  34.                      GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
  35.                      "DX Project 9", NULL};
  36. //Set the mouse pointer to an arrow
  37.     wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  38. RegisterClassEx(&wc);
  39.     //Create the application's window
  40.     HWND hWnd = CreateWindow("DX Project 9", "www.andypike.com: Tutorial 9", 
  41.                               WS_OVERLAPPEDWINDOW, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN),
  42.                               NULL, NULL, wc.hInstance, NULL);
  43. //Show our window
  44.     ShowWindow(hWnd, SW_SHOWDEFAULT);
  45.     UpdateWindow(hWnd);
  46. g_pGame = new CGame();
  47.     g_pGame->StartLogging();
  48. //Initialize Direct3D
  49. if(g_pGame->Initialise(hWnd, 800, 600))
  50.     { 
  51.         //Start game running: Enter the game loop
  52. g_pGame->GameLoop();
  53.     }
  54.     
  55.     CleanUp();
  56.     UnregisterClass("DX Project 9", wc.hInstance);
  57.     
  58.     return 0;
  59. }