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.     }
  17.     return DefWindowProc(hWnd, msg, wParam, lParam);
  18. }
  19. //Application entry point
  20. INT WINAPI WinMain(HINSTANCE hInst, HINSTANCE, LPSTR, INT)
  21. {
  22.     //Register the window class
  23.     WNDCLASSEX wc = {sizeof(WNDCLASSEX), CS_CLASSDC, WinProc, 0L, 0L, 
  24.                      GetModuleHandle(NULL), NULL, NULL, NULL, NULL,
  25.                      "DX Project 12", NULL};
  26. //Set the mouse pointer to an arrow
  27.     wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  28. ShowCursor(FALSE);
  29. RegisterClassEx(&wc);
  30.     //Create the application's window
  31.     HWND hWnd = CreateWindow("DX Project 12", "www.andypike.com: Tutorial 12", 
  32.                               WS_OVERLAPPEDWINDOW, 0, 0, GetSystemMetrics(SM_CXSCREEN), GetSystemMetrics(SM_CYSCREEN),
  33.                               NULL, NULL, wc.hInstance, NULL);
  34. //Show our window
  35.     ShowWindow(hWnd, SW_SHOWDEFAULT);
  36.     UpdateWindow(hWnd);
  37. g_pGame = new CGame();
  38.     g_pGame->StartLogging();
  39. //Initialize Direct3D
  40. if(g_pGame->Initialise(hWnd, hInst, 800, 600))
  41.     { 
  42.         //Start game running: Enter the game loop
  43. g_pGame->GameLoop();
  44.     }
  45.     
  46.     CleanUp();
  47.     UnregisterClass("DX Project 12", wc.hInstance);
  48.     
  49.     return 0;
  50. }