home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
VRML Tools for 3D Cyberspace
/
VRML_Tools_For_3D_Cyberspace.iso
/
amber
/
demos
/
viewer
/
viewer.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1996-07-01
|
3KB
|
128 lines
#include <windows.h>
#include "amber.hpp"
#include "mouse.hpp"
#include "viewer.h"
#include "resource.h"
#include "demo.hpp"
/**************************************************************************\
*
* function: WinMain()
*
* input parameters: c.f. generic sample
*
\**************************************************************************/
int PASCAL WinMain(HINSTANCE hInstance, HINSTANCE hPrevInstance,
LPSTR lpCmdLine, int nCmdShow)
{
HANDLE hInst;
HWND hwndMain;
MSG msg;
UNREFERENCED_PARAMETER( lpCmdLine );
/* Check for previous instance. If none, then register class. */
if (!hPrevInstance) {
WNDCLASS wc;
wc.style = CS_VREDRAW;
wc.lpfnWndProc = (WNDPROC)MainWndProc;
wc.cbClsExtra = 0;
wc.cbWndExtra = 0;
wc.hInstance = hInstance;
wc.hCursor = LoadCursor(NULL, IDC_ARROW);
wc.hbrBackground = GetStockObject(LTGRAY_BRUSH);
wc.lpszMenuName = "SIMPLE_MENU";
wc.lpszClassName = "simple";
if (!RegisterClass(&wc)) return (FALSE);
} /* class registered o.k. */
/* Create the main window. Return false if CreateWindow() fails */
hInst = hInstance;
hwndMain = CreateWindow(
"simple",
"Amber Model Viewer",
WS_OVERLAPPEDWINDOW | WS_CLIPCHILDREN | WS_CLIPSIBLINGS,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
CW_USEDEFAULT,
NULL,
NULL,
hInstance,
NULL);
if (!hwndMain) return (FALSE);
ShowWindow(hwndMain, nCmdShow);
UpdateWindow(hwndMain);
/* Loop getting messages and dispatching them. */
while (GetMessage(&msg,NULL, 0,0)) {
TranslateMessage(&msg);
DispatchMessage(&msg);
}
return (msg.wParam);
}
LRESULT CALLBACK MainWndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam)
{
static channelClass *ch;
universeClass *univ;
V3 pos;
switch (message) {
/**********************************************************************\
* WM_CREATE
*
* Initialize the static variables.
\**********************************************************************/
case WM_CREATE:
popFileInitialize(hwnd);
amber = new amberClass();
univ = new universeClass();
ch = new channelClass(hwnd);
V3_set(pos, 0.0, 0.0, 10.0);
ch->setPosition(pos);
platter = new platterClass(hwnd);
mouse = new mouseClass(hwnd);
mouse->attachChannel(ch);
init(ch);
break;
case WM_CLOSE:
cleanup();
PostQuitMessage(0);
break;
case WM_KEYDOWN:
processChar(wParam);
break;
case WM_SIZE:
if (!ch || !IsWindowVisible(hwnd)) break;
ch->resetPerspective();
break;
case WM_COMMAND: // message: command from application menu
processWMCMD(hwnd,wParam);
break;
} /* end switch */
return (DefWindowProc(hwnd, message, wParam, lParam));
}