- int Game_Shutdown(void *parms = NULL, int num_parms = 0)
- {
- // this is called after the game is exited and the main event
- // loop while is exited, do all you cleanup and shutdown here
- // kill all the surfaces
- // first the palette
- if (lpddpal)
- {
- lpddpal->Release();
- lpddpal = NULL;
- } // end if
- // now the primary surface
- if (lpddsprimary)
- {
- lpddsprimary->Release();
- lpddsprimary = NULL;
- } // end if
- // now blow away the IDirectDraw4 interface
- if (lpdd)
- {
- lpdd->Release();
- lpdd = NULL;
- } // end if
- Unload_Bitmap_File(&bitmap);//疑问
- // return success or failure or your own return code here
- return(1);
- } // end Game_Shutdown
- // WINMAIN
- int WINAPI WinMain( HINSTANCE hinstance,
- HINSTANCE hprevinstance,
- LPSTR lpcmdline,
- int ncmdshow)
- {
- WNDCLASSEX winclass; // this will hold the class we create
- HWND hwnd; // generic window handle
- MSG msg; // generic message
- HDC hdc; // graphics device context
- // first fill in the window class stucture
- winclass.cbSize = sizeof(WNDCLASSEX);
- winclass.style = CS_DBLCLKS | CS_OWNDC |
- CS_HREDRAW | CS_VREDRAW;
- winclass.lpfnWndProc = WindowProc;
- winclass.cbClsExtra = 0;
- winclass.cbWndExtra = 0;
- winclass.hInstance = hinstance;
- winclass.hIcon = LoadIcon(NULL, IDI_APPLICATION);
- winclass.hCursor = LoadCursor(NULL, IDC_ARROW);
- winclass.hbrBackground = (HBRUSH)GetStockObject(BLACK_BRUSH);
- winclass.lpszMenuName = NULL;
- winclass.lpszClassName = WINDOW_CLASS_NAME;
- winclass.hIconSm = LoadIcon(NULL, IDI_APPLICATION);
- // save hinstance in global
- hinstance_app = hinstance;
- // register the window class
- if (!RegisterClassEx(&winclass))
- return(0);
- // create the window
- if (!(hwnd = CreateWindowEx(NULL, // extended style
- WINDOW_CLASS_NAME, // class
- "DirectDraw 8-Bit Blitting Demo", // title
- WS_POPUP | WS_VISIBLE,
- 0,0, // initial x,y
- SCREEN_WIDTH,SCREEN_HEIGHT, // initial width, height
- NULL, // handle to parent
- NULL, // handle to menu
- hinstance,// instance of this application
- NULL))) // extra creation parms
- return(0);
- // save main window handle
- main_window_handle = hwnd;
- // initialize game here
- Game_Init();
- // enter main event loop
- while(TRUE)
- {
- // test if there is a message in queue, if so get it
- if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))
- {
- // test if this is a quit
- if (msg.message == WM_QUIT)
- break;
- // translate any accelerator keys
- TranslateMessage(&msg);
- // send the message to the window proc
- DispatchMessage(&msg);
- } // end if
- // main game processing goes here
- Game_Main();
- } // end while
- // closedown game here
- Game_Shutdown();
- // return to Windows like this
- return(msg.wParam);
- } // end WinMain
- ///