home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
VRML Tools for 3D Cyberspace
/
VRML_Tools_For_3D_Cyberspace.iso
/
amber
/
demos
/
piano
/
piano.cpp
< prev
next >
Wrap
C/C++ Source or Header
|
1996-07-01
|
3KB
|
140 lines
#include <windows.h>
#include "amber.hpp"
#include "piano.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 = "";
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",
"Simple",
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)
{
universeClass *univ;
V3 pos;
F2 angles = {10.0*DEG_TO_RAD, 0.0};
switch (message) {
/**********************************************************************\
* WM_CREATE
*
* Initialize the static variables.
* Then create three pens for drawing with later.
\**********************************************************************/
case WM_CREATE:
amber = new amberClass();
univ = new universeClass();
ch = new channelClass(hwnd);
mouse = new mouseClass(hwnd);
mouse->attachChannel(ch);
init(ch);
break;
/**********************************************************************\
* WM_DESTROY
*
* Complement of the WM_CREATE message. Delete the pens that were
* created and then call postquitmessage.
\**********************************************************************/
case WM_DESTROY:
cleanup();
delete mouse;
delete amber;
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
switch(wParam)
{
case ID_PROGRAM_EXIT:
cleanup();
delete mouse;
delete amber;
PostQuitMessage(0);
break;
}
break;
} /* end switch */
return (DefWindowProc(hwnd, message, wParam, lParam));
}