DirectX 32位显示模式简单控制 Demo 下

 

  
  
  
  
  1. int Game_Shutdown(void *parms = NULL, int num_parms = 0)   
  2. {   
  3.     // this is called after the game is exited and the main event   
  4.     // loop while is exited, do all you cleanup and shutdown here   
  5.        
  6.     // kill all the surfaces   
  7.        
  8.        
  9.     // first the palette   
  10.     if (lpddpal)   
  11.     {   
  12.         lpddpal->Release();   
  13.         lpddpal = NULL;   
  14.     } // end if   
  15.        
  16.     // now the primary surface   
  17.     if (lpddsprimary)   
  18.     {   
  19.         lpddsprimary->Release();   
  20.         lpddsprimary = NULL;   
  21.     } // end if   
  22.        
  23.     // now blow away the IDirectDraw4 interface   
  24.     if (lpdd)   
  25.     {   
  26.         lpdd->Release();   
  27.         lpdd = NULL;   
  28.     } // end if   
  29.       Unload_Bitmap_File(&bitmap);//疑问   
  30.     // return success or failure or your own return code here   
  31.     return(1);   
  32.        
  33. // end Game_Shutdown   
  34.    
  35. // WINMAIN ////////////////////////////////////////////////   
  36.    
  37. int WINAPI WinMain( HINSTANCE hinstance,   
  38.                    HINSTANCE hprevinstance,   
  39.                    LPSTR lpcmdline,   
  40.                    int ncmdshow)   
  41. {   
  42.        
  43.     WNDCLASSEX winclass; // this will hold the class we create   
  44.     HWND       hwnd;     // generic window handle   
  45.     MSG        msg;      // generic message   
  46.     HDC        hdc;      // graphics device context   
  47.        
  48.     // first fill in the window class stucture   
  49.     winclass.cbSize         = sizeof(WNDCLASSEX);   
  50.     winclass.style          = CS_DBLCLKS | CS_OWNDC |    
  51.         CS_HREDRAW | CS_VREDRAW;   
  52.     winclass.lpfnWndProc    = WindowProc;   
  53.     winclass.cbClsExtra     = 0;   
  54.     winclass.cbWndExtra     = 0;   
  55.     winclass.hInstance      = hinstance;   
  56.     winclass.hIcon          = LoadIcon(NULL, IDI_APPLICATION);   
  57.     winclass.hCursor        = LoadCursor(NULL, IDC_ARROW);    
  58.     winclass.hbrBackground  = (HBRUSH)GetStockObject(BLACK_BRUSH);   
  59.     winclass.lpszMenuName   = NULL;   
  60.     winclass.lpszClassName  = WINDOW_CLASS_NAME;   
  61.     winclass.hIconSm        = LoadIcon(NULL, IDI_APPLICATION);   
  62.        
  63.     // save hinstance in global   
  64.     hinstance_app = hinstance;   
  65.        
  66.     // register the window class   
  67.     if (!RegisterClassEx(&winclass))   
  68.         return(0);   
  69.        
  70.     // create the window   
  71.     if (!(hwnd = CreateWindowEx(NULL,                  // extended style   
  72.         WINDOW_CLASS_NAME,     // class   
  73.         "DirectDraw 8-Bit Blitting Demo"// title   
  74.         WS_POPUP | WS_VISIBLE,   
  75.         0,0,      // initial x,y   
  76.         SCREEN_WIDTH,SCREEN_HEIGHT,  // initial width, height   
  77.         NULL,     // handle to parent    
  78.         NULL,     // handle to menu   
  79.         hinstance,// instance of this application   
  80.         NULL))) // extra creation parms   
  81.         return(0);   
  82.        
  83.     // save main window handle   
  84.     main_window_handle = hwnd;   
  85.        
  86.     // initialize game here   
  87.     Game_Init();   
  88.        
  89.     // enter main event loop   
  90.     while(TRUE)   
  91.     {   
  92.         // test if there is a message in queue, if so get it   
  93.         if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))   
  94.         {    
  95.             // test if this is a quit   
  96.             if (msg.message == WM_QUIT)   
  97.                 break;   
  98.                
  99.             // translate any accelerator keys   
  100.             TranslateMessage(&msg);   
  101.                
  102.             // send the message to the window proc   
  103.             DispatchMessage(&msg);   
  104.         } // end if   
  105.            
  106.         // main game processing goes here   
  107.         Game_Main();   
  108.            
  109.     } // end while   
  110.        
  111.     // closedown game here   
  112.     Game_Shutdown();   
  113.        
  114.     // return to Windows like this   
  115.     return(msg.wParam);   
  116.        
  117. // end WinMain   
  118.    
  119. ///////////////////////////////////////////////////////////  
相关文章
相关标签/搜索