Advertisement
Martin_Berger

DEMO7_11

Jul 28th, 2011
387
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 18.07 KB | None | 0 0
  1.  
  2. // DEMO7_11.CPP 16-bit bitmap loading demo  
  3. // require 24-bit bitmap in source directory, which is later being converted to 16-bit
  4.  
  5. // INCLUDES ///////////////////////////////////////////////  
  6.  
  7. #define WIN32_LEAN_AND_MEAN  // just say no to MFC  
  8.  
  9. #define INITGUID  
  10.  
  11. #include <windows.h>   // include important windows stuff  
  12. #include <windowsx.h>    
  13. #include <mmsystem.h>  
  14. #include <iostream> // include important C/C++ stuff  
  15. #include <conio.h>  
  16. #include <stdlib.h>  
  17. #include <malloc.h>  
  18. #include <memory.h>  
  19. #include <string.h>  
  20. #include <stdarg.h>  
  21. #include <stdio.h>    
  22. #include <math.h>  
  23. #include <io.h>  
  24. #include <fcntl.h>  
  25. #include <fstream>
  26. #include <ddraw.h> // include directdraw  
  27.  
  28. using namespace std;
  29.  
  30.  
  31.  
  32. // DEFINES ////////////////////////////////////////////////  
  33.  
  34. // defines for windows    
  35. #define WINDOW_CLASS_NAME L"WINCLASS1"  
  36.  
  37. // default screen size  
  38. #define SCREEN_WIDTH    640  // size of screen  
  39. #define SCREEN_HEIGHT   480  
  40. #define SCREEN_BPP      16   // bits per pixel  
  41.  
  42. #define BITMAP_ID            0x4D42 // universal id for a bitmap  
  43. #define MAX_COLORS_PALETTE   256  
  44.  
  45.  
  46.  
  47. // TYPES //////////////////////////////////////////////////////  
  48.  
  49. // basic unsigned types  
  50. typedef unsigned short USHORT;  
  51. typedef unsigned short WORD;  
  52. typedef unsigned char  UCHAR;  
  53. typedef unsigned char  BYTE;  
  54.  
  55. // container structure for bitmaps .BMP file  
  56. typedef struct BITMAP_FILE_TAG  
  57. {  
  58.     BITMAPFILEHEADER bitmapfileheader;  // this contains the bitmapfile header  
  59.     BITMAPINFOHEADER bitmapinfoheader;  // this is all the info including the palette  
  60.     PALETTEENTRY     palette[256];      // we will store the palette here  
  61.     UCHAR            *buffer;           // this is a pointer to the data  
  62.  
  63. } BITMAP_FILE, *BITMAP_FILE_PTR;  
  64.  
  65.  
  66.  
  67. // PROTOTYPES  //////////////////////////////////////////////  
  68.  
  69. int Flip_Bitmap(UCHAR *image, int bytes_per_line, int height);  
  70.  
  71. int Load_Bitmap_File(BITMAP_FILE_PTR bitmap, char *filename);  
  72.  
  73. int Unload_Bitmap_File(BITMAP_FILE_PTR bitmap);  
  74.  
  75.  
  76.  
  77. // MACROS /////////////////////////////////////////////////  
  78.  
  79. // tests if a key is up or down  
  80. #define KEYDOWN(vk_code) ((GetAsyncKeyState(vk_code) & 0x8000) ? 1 : 0)  
  81. #define KEYUP(vk_code)   ((GetAsyncKeyState(vk_code) & 0x8000) ? 0 : 1)  
  82.  
  83. // initializes a direct draw struct  
  84. #define DDRAW_INIT_STRUCT(ddstruct) { memset(&ddstruct, 0, sizeof(ddstruct)); ddstruct.dwSize = sizeof(ddstruct); }  
  85.  
  86. // this builds a 16 bit color value in 5.5.5 format (1-bit alpha mode)  
  87. #define _RGB16BIT555(r,g,b) ((b & 31) + ((g & 31) << 5) + ((r & 31) << 10))  
  88.  
  89. // this builds a 16 bit color value in 5.6.5 format (green dominate mode)  
  90. #define _RGB16BIT565(r,g,b) ((b & 31) + ((g & 63) << 5) + ((r & 31) << 11))  
  91.  
  92. // this builds a 32 bit color value in A.8.8.8 format (8-bit alpha mode)  
  93. #define _RGB32BIT(a,r,g,b)  ((b) + ((g) << 8) + ((r) << 16) + ((a) << 24))  
  94.  
  95.  
  96.  
  97. // GLOBALS ////////////////////////////////////////////////  
  98.  
  99. HWND      main_window_handle = NULL; // globally track main window  
  100. int       window_closed      = 0;    // tracks if window is closed  
  101. HINSTANCE hinstance_app      = NULL; // globally track hinstance  
  102.  
  103. // directdraw stuff  
  104.  
  105. LPDIRECTDRAW7         lpdd         = NULL;   // dd object  
  106. LPDIRECTDRAWSURFACE7  lpddsprimary = NULL;   // dd primary surface  
  107. LPDIRECTDRAWSURFACE7  lpddsback    = NULL;   // dd back surface  
  108. LPDIRECTDRAWPALETTE   lpddpal      = NULL;   // a pointer to the created dd palette  
  109. LPDIRECTDRAWCLIPPER   lpddclipper  = NULL;   // dd clipper  
  110. PALETTEENTRY          palette[256];          // color palette  
  111. PALETTEENTRY          save_palette[256];     // used to save palettes  
  112. DDSURFACEDESC2        ddsd;                  // a direct draw surface description struct  
  113. DDBLTFX               ddbltfx;               // used to fill  
  114. DDSCAPS2              ddscaps;               // a direct draw surface capabilities struct  
  115. HRESULT               ddrval;                // result back from dd calls  
  116. DWORD                 start_clock_count = 0; // used for timing  
  117.  
  118. BITMAP_FILE           bitmap;                // holds the bitmap  
  119.  
  120. char buffer[80];                             // general printing buffer  
  121.  
  122.  
  123.  
  124. // FUNCTIONS ////////////////////////////////////////////////  
  125.  
  126. void printError (char * errorName)
  127. {
  128.     // print error to log.txt
  129.     ofstream errorFile = ofstream ("log.txt");
  130.     if (errorFile.is_open ())
  131.     {
  132.         errorFile << errorName << endl; //"Error: OpenFile function failure. "
  133.     }
  134.     errorFile.close ();
  135. }
  136.  
  137. int Load_Bitmap_File(BITMAP_FILE_PTR bitmap, char *filename)  
  138. {  
  139.     int file_handle = 0;        // the file handle
  140.     int index = 0;                  // looping index  
  141.     int bitmapWidth = 0;
  142.     int bitmapHeight = 0;
  143.     int bitmapSize = 0;
  144.     UCHAR *temp_buffer = NULL; // used to convert 24 bit images to 16 bit  
  145.     streampos pos_cur;
  146.  
  147.     ifstream bitmapFile = ifstream ();
  148.     bitmapFile.open (filename, ifstream::in);
  149.     if (! bitmapFile.is_open ())
  150.     {
  151.     printError ("Error: OpenFile function failure. ");
  152.  
  153.         // abort
  154.         return(0);
  155.     }
  156.  
  157.  
  158.     // load the bitmap file header:  
  159.     //_lread(file_handle, &(bitmap->bitmapfileheader), sizeof(BITMAPFILEHEADER));
  160.     bitmapFile.read ((char *) &(bitmap->bitmapfileheader), sizeof (BITMAPFILEHEADER));
  161.  
  162.     // test if this is a bitmap file  
  163.     if (bitmap->bitmapfileheader.bfType != BITMAP_ID)  
  164.     {  
  165.         // close the file  
  166.         //_lclose(file_handle);  
  167.         bitmapFile.close ();
  168.         printError ("error: wrong bitmap type");
  169.         cout << "error: wrong bitmap type" << endl;
  170.         // return error  
  171.         return(0);  
  172.     } // end if  
  173.  
  174.     // now we know this is a bitmap, so read in all the sections.  
  175.     if (bitmap->bitmapinfoheader.biSizeImage == 0)
  176.     printError ("error: biSizeImage equals 0");
  177.  
  178.  
  179.     // now the bitmap infoheader:  
  180.  
  181.     //_lread(file_handle, &bitmap->bitmapinfoheader, sizeof(BITMAPINFOHEADER));  
  182.     bitmapFile.seekg (sizeof (BITMAPFILEHEADER), ios::beg);
  183.     pos_cur = bitmapFile.tellg (); // save current stream position
  184.     bitmapFile.read ((char *) &(bitmap->bitmapinfoheader), sizeof (BITMAPINFOHEADER));
  185.  
  186.     //cout << bitmap->bitmapinfoheader.biBitCount << endl;
  187.  
  188.  
  189.     // now load the color palette if there is one  
  190.     if (bitmap->bitmapinfoheader.biBitCount == 8)  
  191.     {  
  192.         //_lread(file_handle, &bitmap->palette, MAX_COLORS_PALETTE * sizeof(PALETTEENTRY));  
  193.         // not tested:
  194.         bitmapFile.read ((char *) &(bitmap->palette), MAX_COLORS_PALETTE * sizeof(PALETTEENTRY));
  195.  
  196.         // now set all the flags in the palette correctly and fix the reversed    
  197.         // BGR RGBQUAD data format  
  198.         for (index = 0; index < MAX_COLORS_PALETTE; index++)  
  199.         {  
  200.             // reverse the red and green fields  
  201.             int temp_color                = bitmap->palette[index].peRed;  
  202.             bitmap->palette[index].peRed  = bitmap->palette[index].peBlue;  
  203.             bitmap->palette[index].peBlue = temp_color;  
  204.  
  205.             // always set the flags word to this  
  206.             bitmap->palette[index].peFlags = PC_NOCOLLAPSE;  
  207.         } // end for index  
  208.  
  209.     } // end if  
  210.    
  211.     bitmapWidth = bitmap->bitmapinfoheader.biWidth * (bitmap->bitmapinfoheader.biBitCount / 8);
  212.     bitmapHeight = bitmap->bitmapinfoheader.biHeight;
  213.     bitmapSize = bitmapWidth * bitmapHeight;
  214.  
  215.  
  216.     // finally the image data itself:  
  217.     //_lseek(file_handle, -((int) (bitmap->bitmapinfoheader.biSizeImage)), SEEK_END);
  218.     bitmapFile.seekg (-((int) bitmapSize), ios::end);
  219.     //bitmapFile.seekg (sizeof (BITMAPINFOHEADER) + sizeof (BITMAPFILEHEADER) + MAX_COLORS_PALETTE * sizeof(PALETTEENTRY), ios::beg);
  220.  
  221.     // now read in the image, if the image is 8 or 16 bit then simply read it  
  222.     // but if its 24 bit then read it into a temporary area and then convert  
  223.     // it to a 16 bit image  
  224.  
  225.     if (bitmap->bitmapinfoheader.biBitCount == 8  ||
  226.          bitmap->bitmapinfoheader.biBitCount == 16 ||    
  227.          bitmap->bitmapinfoheader.biBitCount == 24)  
  228.     {  
  229.         // delete the last image if there was one  
  230.         if (bitmap->buffer)  
  231.             free(bitmap->buffer);  
  232.  
  233.         // allocate the memory for the image  
  234.         //if (!(bitmap->buffer = (UCHAR *) malloc (bitmap->bitmapinfoheader.biSizeImage))) // error: biSizeImage == 0 !
  235.         if (!(bitmap->buffer = (UCHAR *) malloc (bitmapSize)))
  236.         {  
  237.             // close the file  
  238.             //_lclose(file_handle);  
  239.             bitmapFile.close ();
  240.  
  241.             // return error  
  242.             return(0);  
  243.         } // end if  
  244.  
  245.         // now read it in  
  246.         //_lread(file_handle, bitmap->buffer, bitmap->bitmapinfoheader.biSizeImage);  
  247.         bitmapFile.read ((char *) (bitmap->buffer), bitmapSize);
  248.  
  249.     } // end if  
  250.     else  
  251.     {  
  252.         // serious problem  
  253.         return(0);  
  254.  
  255.     } // end else  
  256.  
  257.  
  258.     // close the file  
  259.     //_lclose(file_handle);  
  260.     bitmapFile.close ();
  261.  
  262.     // flip the bitmap  
  263.    
  264.     Flip_Bitmap(bitmap->buffer,    
  265.                     bitmap->bitmapinfoheader.biWidth * (bitmap->bitmapinfoheader.biBitCount / 8),
  266.                     bitmap->bitmapinfoheader.biHeight);  
  267.     //cout << "biSizeImage: " << bitmap->bitmapinfoheader.biSizeImage << endl;
  268.     //cout << (bitmap->bitmapinfoheader.biWidth * (bitmap->bitmapinfoheader.biBitCount / 8)) * bitmap->bitmapinfoheader.biHeight << endl;
  269.  
  270.     // return success  
  271.     return(1);  
  272.  
  273. } // end Load_Bitmap_File  
  274.  
  275. ///////////////////////////////////////////////////////////  
  276.  
  277.  
  278. int Unload_Bitmap_File(BITMAP_FILE_PTR bitmap)  
  279. {  
  280.     // this function releases all memory associated with "bitmap"  
  281.     if (bitmap->buffer)  
  282.     {  
  283.         // release memory  
  284.         free(bitmap->buffer);  
  285.  
  286.         // reset pointer  
  287.         bitmap->buffer = NULL;  
  288.  
  289.     } // end if  
  290.  
  291.     // return success  
  292.     return(1);  
  293.  
  294. } // end Unload_Bitmap_File  
  295.  
  296. ///////////////////////////////////////////////////////////  
  297.  
  298. int Flip_Bitmap(UCHAR *image, int bytes_per_line, int height)  
  299. {  
  300.     // this function is used to flip bottom-up .BMP images  
  301.  
  302.     UCHAR *buffer; // used to perform the image processing  
  303.     int index;     // looping index  
  304.  
  305.     // allocate the temporary buffer  
  306.     if (!(buffer = (UCHAR *) malloc (bytes_per_line*height)))  
  307.         return(0);  
  308.  
  309.     // copy image to work area  
  310.     memcpy(buffer,image,bytes_per_line*height);  
  311.  
  312.     // flip vertically  
  313.     for (index=0; index < height; index++)  
  314.         memcpy(&image[((height-1) - index) * bytes_per_line],   &buffer[index * bytes_per_line], bytes_per_line);  
  315.  
  316.     // release the memory  
  317.     free(buffer);  
  318.  
  319.     // return success  
  320.     return(1);  
  321.  
  322. } // end Flip_Bitmap  
  323.  
  324. ///////////////////////////////////////////////////////////////  
  325.  
  326. LRESULT CALLBACK WindowProc(HWND hwnd,    
  327.     UINT msg,    
  328.     WPARAM wparam,    
  329.     LPARAM lparam)  
  330. {  
  331.     // this is the main message handler of the system  
  332.     PAINTSTRUCT     ps;     // used in WM_PAINT  
  333.     HDC             hdc;    // handle to a device context  
  334.     //char buffer[80];        // used to print strings  
  335.  
  336.     // what is the message    
  337.     switch(msg)  
  338.     {      
  339.     case WM_CREATE:    
  340.         {  
  341.             // do initialization stuff here  
  342.             // return success  
  343.             return(0);  
  344.         } break;  
  345.  
  346.     case WM_PAINT:    
  347.         {  
  348.             // simply validate the window    
  349.             hdc = BeginPaint(hwnd,&ps);    
  350.  
  351.             // end painting  
  352.             EndPaint(hwnd,&ps);  
  353.  
  354.             // return success  
  355.             return(0);  
  356.         } break;  
  357.  
  358.     case WM_DESTROY:    
  359.         {  
  360.  
  361.             // kill the application, this sends a WM_QUIT message    
  362.             PostQuitMessage(0);  
  363.  
  364.             // return success  
  365.             return(0);  
  366.         } break;  
  367.  
  368.     default:break;  
  369.  
  370.     } // end switch  
  371.  
  372.     // process any messages that we didn't take care of    
  373.     return (DefWindowProc(hwnd, msg, wparam, lparam));  
  374.  
  375. } // end WinProc  
  376.  
  377. ///////////////////////////////////////////////////////////  
  378.  
  379. int Game_Main(void *parms = NULL, int num_parms = 0)  
  380. {  
  381.     // this is the main loop of the game, do all your processing  
  382.     // here  
  383.  
  384.     // make sure this isn't executed again  
  385.     if (window_closed)  
  386.         return(0);  
  387.  
  388.     // for now test if user is hitting ESC and send WM_CLOSE  
  389.     if (KEYDOWN(VK_ESCAPE))  
  390.     {  
  391.         PostMessage(main_window_handle, WM_CLOSE, 0, 0);  
  392.         window_closed = 1;  
  393.     } // end if  
  394.  
  395.     // copy the bitmap image to the primary buffer line by line  
  396.     // notice the 24 to 16 bit conversion pixel by pixel  
  397.  
  398.     // lock the primary surface  
  399.     lpddsprimary->Lock(NULL, &ddsd, DDLOCK_SURFACEMEMORYPTR | DDLOCK_WAIT, NULL);  
  400.  
  401.     // get video pointer to primary surfce  
  402.     USHORT *primary_buffer = (USHORT *) ddsd.lpSurface;          
  403.  
  404.     // process each line and copy it into the primary buffer  
  405.     for (int index_y = 0; index_y < SCREEN_HEIGHT; index_y++)  
  406.     {  
  407.         for (int index_x = 0; index_x < SCREEN_WIDTH; index_x++)  
  408.         {  
  409.             // get BGR values, note the scaling down of the channels, so that they  
  410.             // fit into the 5.6.5 format  
  411.             UCHAR blue  = (bitmap.buffer[index_y * SCREEN_WIDTH*3 + index_x*3 + 0]) >> 3, // /2^3 ; 8
  412.                     green = (bitmap.buffer[index_y * SCREEN_WIDTH*3 + index_x*3 + 1]) >> 2, // /2^2 ; 4
  413.                     red   = (bitmap.buffer[index_y * SCREEN_WIDTH*3 + index_x*3 + 2]) >> 3; // /2^3 ; 8
  414.  
  415.             // this builds a 16 bit color value in 5.6.5 format (green dominant mode)  
  416.             USHORT pixel = _RGB16BIT565(red, green, blue);  
  417.  
  418.             // write the pixel  
  419.             primary_buffer[index_x + (index_y * ddsd.lPitch >> 1)] = pixel;  
  420.  
  421.         } // end for index_x  
  422.  
  423.     } // end for index_y  
  424.  
  425.     // now unlock the primary surface  
  426.     if (FAILED(lpddsprimary->Unlock(NULL)))  
  427.         return(0);  
  428.  
  429.     // do nothing -- look at pretty picture  
  430.  
  431.     // return success or failure or your own return code here  
  432.     return(1);  
  433.  
  434. } // end Game_Main  
  435.  
  436. ////////////////////////////////////////////////////////////  
  437.  
  438. int Game_Init(void *parms = NULL, int num_parms = 0)  
  439. {  
  440.     // this is called once after the initial window is created and  
  441.     // before the main event loop is entered, do all your initialization  
  442.     // here  
  443.  
  444.     // create IDirectDraw interface 7.0 object and test for error  
  445.     if (FAILED(DirectDrawCreateEx(NULL, (void **) &lpdd, IID_IDirectDraw7, NULL)))  
  446.         return(0);  
  447.  
  448.     // set cooperation to full screen  
  449.     if (FAILED(lpdd->SetCooperativeLevel(main_window_handle,    
  450.         DDSCL_FULLSCREEN | DDSCL_ALLOWMODEX | DDSCL_EXCLUSIVE | DDSCL_ALLOWREBOOT)))
  451.         //DDSCL_NORMAL | DDSCL_ALLOWREBOOT)))  
  452.         return(0);  
  453.  
  454.     // set display mode to 1024x768x8  
  455.     if (FAILED(lpdd->SetDisplayMode(SCREEN_WIDTH, SCREEN_HEIGHT, SCREEN_BPP, 0, 0)))  
  456.         return(0);  
  457.  
  458.     // clear ddsd and set size  
  459.     DDRAW_INIT_STRUCT(ddsd);    
  460.  
  461.     // enable valid fields  
  462.     ddsd.dwFlags = DDSD_CAPS;  
  463.  
  464.     // request primary surface  
  465.     ddsd.ddsCaps.dwCaps = DDSCAPS_PRIMARYSURFACE;  
  466.  
  467.     // create the primary surface  
  468.     if (FAILED(lpdd->CreateSurface(&ddsd, &lpddsprimary, NULL)))  
  469.         return(0);  
  470.  
  471.     // load the 24-bit image  
  472.     if (!Load_Bitmap_File(&bitmap, "bitmap24.bmp"))  
  473.         return(0);  
  474.  
  475.  
  476.     // return success or failure or your own return code here  
  477.     return(1);  
  478.  
  479. } // end Game_Init  
  480.  
  481. /////////////////////////////////////////////////////////////  
  482.  
  483. int Game_Shutdown(void *parms = NULL, int num_parms = 0)  
  484. {  
  485.     // this is called after the game is exited and the main event  
  486.     // loop while is exited, do all you cleanup and shutdown here  
  487.  
  488.  
  489.     // first the palette  
  490.     if (lpddpal)  
  491.     {  
  492.         lpddpal->Release();  
  493.         lpddpal = NULL;  
  494.     } // end if  
  495.  
  496.     // now the primary surface  
  497.     if (lpddsprimary)  
  498.     {  
  499.         lpddsprimary->Release();  
  500.         lpddsprimary = NULL;  
  501.     } // end if  
  502.  
  503.     // now blow away the IDirectDraw4 interface  
  504.     if (lpdd)  
  505.     {  
  506.         lpdd->Release();  
  507.         lpdd = NULL;  
  508.     } // end if  
  509.  
  510.     // unload the bitmap file, we no longer need it  
  511.     Unload_Bitmap_File(&bitmap);  
  512.  
  513.     // return success or failure or your own return code here  
  514.     return(1);  
  515.  
  516. } // end Game_Shutdown  
  517.  
  518. // WINMAIN ////////////////////////////////////////////////  
  519.  
  520. int WINAPI WinMain( HINSTANCE hinstance,  
  521.     HINSTANCE hprevinstance,  
  522.     LPSTR lpcmdline,  
  523.     int ncmdshow)  
  524. {  
  525.  
  526.     WNDCLASSEX winclass; // this will hold the class we create  
  527.     HWND       hwnd;     // generic window handle  
  528.     MSG        msg;      // generic message  
  529.     //HDC        hdc;      // graphics device context  
  530.  
  531.     // first fill in the window class stucture  
  532.     winclass.cbSize         = sizeof(WNDCLASSEX);  
  533.     winclass.style          = CS_DBLCLKS | CS_OWNDC | CS_HREDRAW | CS_VREDRAW;  
  534.     winclass.lpfnWndProc    = WindowProc;  
  535.     winclass.cbClsExtra     = 0;  
  536.     winclass.cbWndExtra     = 0;  
  537.     winclass.hInstance      = hinstance;  
  538.     winclass.hIcon          = LoadIcon(NULL, IDI_APPLICATION);  
  539.     winclass.hCursor        = LoadCursor(NULL, IDC_ARROW);    
  540.     winclass.hbrBackground  = (HBRUSH)GetStockObject(BLACK_BRUSH);  
  541.     winclass.lpszMenuName   = NULL;  
  542.     winclass.lpszClassName  = WINDOW_CLASS_NAME;  
  543.     winclass.hIconSm        = LoadIcon(NULL, IDI_APPLICATION);  
  544.  
  545.     // save hinstance in global  
  546.     hinstance_app = hinstance;  
  547.  
  548.     // register the window class  
  549.     if (!RegisterClassEx(&winclass))  
  550.         return(0);  
  551.  
  552.     // create the window  
  553.     if (!(hwnd = CreateWindowEx(NULL,   // extended style  
  554.         WINDOW_CLASS_NAME,  // class  
  555.         L"DirectDraw 16-Bit Bitmap Loading", // title  
  556.         WS_POPUP | WS_VISIBLE,  
  557.         0, 0,           // initial x,y  
  558.         SCREEN_WIDTH,SCREEN_HEIGHT,  // initial width, height  
  559.         NULL,           // handle to parent    
  560.         NULL,           // handle to menu  
  561.         hinstance,  // instance of this application  
  562.         NULL)))     // extra creation parms  
  563.         return(0);  
  564.  
  565.     // save main window handle  
  566.     main_window_handle = hwnd;  
  567.  
  568.     // initialize game here  
  569.     Game_Init();  
  570.  
  571.     // enter main event loop  
  572.     while(TRUE)  
  573.     {  
  574.         // test if there is a message in queue, if so get it  
  575.         if (PeekMessage(&msg,NULL,0,0,PM_REMOVE))  
  576.         {    
  577.             // test if this is a quit  
  578.             if (msg.message == WM_QUIT)  
  579.                 break;  
  580.  
  581.             // translate any accelerator keys  
  582.             TranslateMessage(&msg);  
  583.  
  584.             // send the message to the window proc  
  585.             DispatchMessage(&msg);  
  586.         } // end if  
  587.  
  588.         // main game processing goes here  
  589.         Game_Main();  
  590.  
  591.     } // end while  
  592.  
  593.     // closedown game here  
  594.     Game_Shutdown();  
  595.  
  596.     // return to Windows like this  
  597.     return(msg.wParam);  
  598.  
  599. } // end WinMain  
  600.  
  601. ///////////////////////////////////////////////////////////
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement