home *** CD-ROM | disk | FTP | other *** search
/ VRML Tools for 3D Cyberspace / VRML_Tools_For_3D_Cyberspace.iso / amber / demos / viewer / viewer.bak < prev    next >
Text File  |  1996-07-01  |  3KB  |  132 lines

  1.  
  2.  
  3. #include <windows.h>
  4.  
  5. #include "amber.hpp"
  6. #include "mouse.hpp"
  7.  
  8. #include "viewer.h"
  9. #include "resource.h"
  10. #include "demo.hpp"
  11.  
  12. /**************************************************************************\
  13. *
  14. *  function:  WinMain()
  15. *
  16. *  input parameters:  c.f. generic sample
  17. *
  18. \**************************************************************************/
  19. int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
  20.                          LPSTR lpCmdLine, int nCmdShow)
  21. {
  22.     HANDLE hInst;
  23.     HWND   hwndMain;
  24.     MSG   msg;
  25.  
  26.     UNREFERENCED_PARAMETER( lpCmdLine );
  27.  
  28.  
  29.     /* Check for previous instance.  If none, then register class. */
  30.     if (!hPrevInstance) {
  31.         WNDCLASS  wc;
  32.  
  33.         wc.style = CS_VREDRAW;
  34.         wc.lpfnWndProc = (WNDPROC)MainWndProc;
  35.  
  36.         wc.cbClsExtra = 0;
  37.         wc.cbWndExtra = 0;
  38.         wc.hInstance = hInstance;
  39.         wc.hCursor = LoadCursor(NULL, IDC_ARROW);
  40.         wc.hbrBackground = GetStockObject(LTGRAY_BRUSH);
  41.           wc.lpszMenuName =  "SIMPLE_MENU";
  42.           wc.lpszClassName = "simple";
  43.  
  44.         if (!RegisterClass(&wc)) return (FALSE);
  45.     }  /* class registered o.k. */
  46.  
  47.  
  48.     /* Create the main window.  Return false if CreateWindow() fails */
  49.     hInst = hInstance;
  50.  
  51.     hwndMain = CreateWindow(
  52.           "simple",
  53.           "Simple",
  54.         WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
  55.         CW_USEDEFAULT,
  56.         CW_USEDEFAULT,
  57.           CW_USEDEFAULT,
  58.           CW_USEDEFAULT,
  59.         NULL,
  60.         NULL,
  61.         hInstance,
  62.         NULL);
  63.  
  64.     if (!hwndMain) return (FALSE);
  65.     ShowWindow(hwndMain, nCmdShow);
  66.     UpdateWindow(hwndMain);
  67.  
  68.  
  69.      /* Loop getting messages and dispatching them. */
  70.     while (GetMessage(&msg,NULL, 0,0)) {
  71.         TranslateMessage(&msg);
  72.           DispatchMessage(&msg);
  73.      }
  74.  
  75.     return (msg.wParam);
  76. }
  77.  
  78.  
  79. LRESULT CALLBACK MainWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
  80. {
  81. static channelClass *ch;
  82. universeClass *univ;
  83. V3 pos;
  84.  
  85.   switch (message) {
  86.  
  87.  
  88.      /**********************************************************************\
  89.      *  WM_CREATE
  90.      *
  91.      * Initialize the static variables.
  92.      \**********************************************************************/
  93.      case WM_CREATE:
  94.           popFileInitialize(hwnd);
  95.           amber = new amberClass();
  96.           univ = new universeClass();
  97.           ch = new channelClass(hwnd);
  98.           V3_set(pos, 0.0, 0.0, 10.0);
  99.           ch->setPosition(pos);
  100.           platter = new platterClass(hwnd);
  101.           mouse = new mouseClass(hwnd);
  102.           mouse->attachChannel(ch);
  103.           init(ch);
  104.      break;
  105.  
  106.  
  107.      case WM_DESTROY:
  108.      case WM_CLOSE:
  109.      case WM_QUIT:
  110.         infoMsg("QUITTING");
  111.         cleanup();
  112.       return 0;
  113.         //PostQuitMessage(0);
  114.      break;
  115.  
  116.     case WM_KEYDOWN:
  117.         processChar(wParam);
  118.         break;
  119.  
  120.     case WM_SIZE:
  121.         if (!ch || !IsWindowVisible(hwnd)) break;
  122.         ch->resetPerspective();
  123.         break;
  124.  
  125.     case WM_COMMAND:  // message: command from application menu
  126.         processWMCMD(hwnd,wParam);
  127.         break;
  128.  
  129.   } /* end switch */
  130.   return (DefWindowProc(hwnd, message, wParam, lParam));
  131. }
  132.