MiniDemo.cpp
上传用户:sz83729876
上传日期:2013-03-07
资源大小:4140k
文件大小:4k
源码类别:

OpenGL

开发平台:

Windows_Unix

  1. #include <windows.h>
  2. #include "Demo.h"
  3. #include "ResourceResource.h"
  4. CParameters     g_Parameters;
  5. LRESULT CALLBACK DlgProc( HWND hWnd, UINT uMsg, WPARAM wParam, LPARAM lParam)
  6. {
  7.     switch( uMsg )
  8.     {
  9.         case WM_INITDIALOG:
  10.             ZeroMemory( &g_Parameters, sizeof(CParameters) );
  11.             SendDlgItemMessage( hWnd, IDC_RADIO_640, BM_SETCHECK, BST_CHECKED , 0 );
  12.             SendDlgItemMessage( hWnd, IDC_RADIO_32, BM_SETCHECK, BST_CHECKED , 0 );
  13.             SendDlgItemMessage( hWnd, IDC_CHECK_SOUND, BM_SETCHECK, BST_CHECKED , 0 );
  14.             SendDlgItemMessage( hWnd, IDC_CHECK_WINDOWED, BM_SETCHECK, BST_CHECKED , 0 );
  15.             g_Parameters.m_iWidth  = 640;
  16.             g_Parameters.m_iHeight = 480;
  17.             g_Parameters.m_iDepth  = 32;
  18.             g_Parameters.m_bLooped   = false;
  19.             g_Parameters.m_bWindowed = true;
  20.             g_Parameters.m_bSound    = true;
  21.             return true;
  22.         case WM_COMMAND:
  23.             switch( LOWORD( wParam ) )
  24.             {
  25.                 case IDC_RUN:
  26.                     EndDialog( hWnd, 0 );
  27.                     return true;
  28.                 case IDC_QUIT:
  29.                     EndDialog( hWnd, 1 );
  30.                     return true;
  31.                 case IDC_RADIO_640:
  32.                     g_Parameters.m_iWidth  = 640;
  33.                     g_Parameters.m_iHeight = 480;
  34.                     break;
  35.                 case IDC_RADIO_800:
  36.                     g_Parameters.m_iWidth  = 800;
  37.                     g_Parameters.m_iHeight = 600;
  38.                     break;
  39.                 case IDC_RADIO_1024:
  40.                     g_Parameters.m_iWidth  = 1024;
  41.                     g_Parameters.m_iHeight = 768;
  42.                     break;
  43.                 case IDC_RADIO_16:
  44.                     g_Parameters.m_iDepth  = 16;
  45.                     break;
  46.                 case IDC_RADIO_32:
  47.                     g_Parameters.m_iDepth  = 32;
  48.                     break;
  49.                 case IDC_CHECK_LOOP:
  50.                     if (g_Parameters.m_bLooped)
  51.                         g_Parameters.m_bLooped = false;
  52.                     else
  53.                         g_Parameters.m_bLooped = true;
  54.                     break;
  55.                 case IDC_CHECK_WINDOWED:
  56.                     if (g_Parameters.m_bWindowed)
  57.                         g_Parameters.m_bWindowed = false;
  58.                     else
  59.                         g_Parameters.m_bWindowed = true;
  60.                     break;
  61.                 case IDC_CHECK_SOUND:
  62.                     if (g_Parameters.m_bSound)
  63.                         g_Parameters.m_bSound = false;
  64.                     else
  65.                         g_Parameters.m_bSound = true;
  66.                     break;
  67.             }
  68.             break;
  69.         case WM_CLOSE:
  70.             EndDialog( hWnd, 1 );
  71.             break;
  72.         case WM_DESTROY:
  73.             break;
  74.     }
  75.     return false;
  76. }
  77. int APIENTRY WinMain( HINSTANCE hInstance, HINSTANCE, LPSTR, int )
  78. {
  79.     // our little popup, return a 1 when the user wants to exit
  80.     if (DialogBox( hInstance, MAKEINTRESOURCE(IDD_DIAG_MAIN), NULL, (DLGPROC)DlgProc ))
  81.         return 0;
  82.     // the actual demo
  83.     CApp* pApp;
  84.     pApp = new CApp();
  85.     if (pApp)
  86.     {
  87.         // window parameters
  88.         pApp->SetParameters( g_Parameters );
  89.         // our app class was succesfuly created
  90.         if (pApp->Initialize( hInstance, "The Hollow", g_Parameters.m_iWidth, g_Parameters.m_iHeight, 
  91.                               g_Parameters.m_iDepth, g_Parameters.m_bWindowed ))
  92.         {
  93.             // intialization succesfull,.... run !
  94.             int iReturn = pApp->Run();
  95.             // app has exited, attempt a cleanup
  96.             if (pApp->Cleanup())
  97.             {
  98.                 // cleanup succesfull, delete our app class and exit...
  99.                 delete pApp;
  100.                 return iReturn; // usually zero,...
  101.             }
  102.         }
  103.         // an error has occured, so try and cleanup everything
  104.         // that has already been initialized
  105.         pApp->Cleanup();
  106.         delete pApp;
  107.         MessageBox( NULL, "An Error Has Occured!!nnCheck the log file for further information...", 
  108.                     "Demo", MB_OK | MB_ICONERROR );
  109.         // exit
  110.         return 1;
  111.     }
  112.     MessageBox( NULL, "Something is *very* wrong here !!!", "Demo", MB_OK | MB_ICONERROR );
  113.     // exit
  114.     return 1;
  115. }