/*------------------------------------------------------------------------ Parameters: Description: Return Values: 0 on success, < 0 otherwise. ------------------------------------------------------------------------*/ int WinCreate(char *pcName, int button_rows, int image_rows, int image_cols, int rows, int cols) { int iWin ; DIAG_WINDOW *pwin ; iWin = winNewHandle() ; if (iWin < 0) return(ErrorPrintf(ERROR_NO_MEMORY, "WinAlloc: could not allocate new window")); pwin = HandleToPtr(iWin) ; pwin->xvf = XValloc(rows, cols, button_rows, image_rows, image_cols, pcName, winPoll) ; XVsetParms(event_handler) ; if (!inited) { ThreadInit(0, MAX_WINDOWS, 10*1024, 1) ; inited = 1 ; } ThreadStart("window", winThread, pwin, MIN_PRIORITY) ; ThreadSuspend(TID_SELF, SIG_ANY) ; WinFlush(iWin) ; return(iWin) ; }
LRESULT CALLBACK WndProc(HWND hwnd, UINT message, WPARAM wParam, LPARAM lParam) { //HDC hdc; //PAINTSTRUCT ps; static RECT rect; //HBRUSH NewBrush; switch (message) { case WM_CREATE: //PlaySound(TEXT("hellowin.wav"), NULL, SND_FILENAME | SND_ASYNC); //do something //各种initialize trClearColor(0.0, 0.0, 0.0, 1.0); return 0; case WM_SIZE: GetWindowRect(hwnd,&rect); //设置相机 trViewport(0, 0, (TRint)(rect.right - rect.left), (TRint)(rect.bottom - rect.top));//重置当前视口 trMatrixMode(TR_PROJECTION);//选择投影矩阵 trLoadIdentity();//重置选择好的投影矩阵 case WM_PAINT: /*hdc = BeginPaint(hwnd, &ps); GetClientRect(hwnd, &rect); DrawText(hdc, TEXT("Hello, Windows 98!"), -1, &rect, DT_SINGLELINE | DT_CENTER | DT_VCENTER); EndPaint(hwnd, &ps);*/ //开始绘图 trClear(TR_COLOR_BUFFER_BIT | TR_DEPTH_BUFFER_BIT); trBegin(TR_POINTS); trVertex4d(0.5,0.5,0.0,1.0); trEnd(); WinFlush(hwnd, frontBuffer, rect.right - rect.left, rect.bottom - rect.top); return 0; case WM_DESTROY: PostQuitMessage(0); return 0; } return DefWindowProc(hwnd, message, wParam, lParam); }