void vsDisplayList::AppendOp(vsDisplayList::op * o) { OpCode type = o->type; switch( type ) { case OpCode_SetColor: SetColor( o->data.GetColor() ); break; case OpCode_SetColors: SetColors( (vsColor*)o->data.p, o->data.GetUInt() ); break; case OpCode_SetColorsBuffer: SetColorsBuffer( (vsRenderBuffer*)o->data.p ); break; case OpCode_VertexArray: VertexArray( (vsVector3D *)o->data.p, o->data.GetUInt() ); break; case OpCode_NormalArray: NormalArray( (vsVector3D *)o->data.p, o->data.GetUInt() ); break; case OpCode_TexelArray: TexelArray( (vsVector2D *)o->data.p, o->data.GetUInt() ); break; case OpCode_ColorArray: ColorArray( (vsColor *)o->data.p, o->data.GetUInt() ); break; case OpCode_VertexBuffer: VertexBuffer( (vsRenderBuffer *)o->data.p ); break; case OpCode_TexelBuffer: TexelBuffer( (vsRenderBuffer *)o->data.p ); break; case OpCode_ColorBuffer: ColorBuffer( (vsRenderBuffer *)o->data.p ); break; case OpCode_BindBuffer: BindBuffer( (vsRenderBuffer *)o->data.p ); break; case OpCode_UnbindBuffer: UnbindBuffer( (vsRenderBuffer *)o->data.p ); break; case OpCode_ClearVertexArray: ClearVertexArray(); break; case OpCode_ClearNormalArray: ClearNormalArray(); break; case OpCode_ClearTexelArray: ClearTexelArray(); break; case OpCode_ClearColorArray: ClearColorArray(); break; case OpCode_ClearArrays: ClearArrays(); break; case OpCode_LineListArray: LineListArray( (int *)o->data.p, o->data.GetUInt() ); break; case OpCode_LineStripArray: LineStripArray( (int *)o->data.p, o->data.GetUInt() ); break; case OpCode_TriangleListArray: TriangleListArray( (int *)o->data.p, o->data.GetUInt() ); break; case OpCode_TriangleStripArray: TriangleStripArray( (int *)o->data.p, o->data.GetUInt() ); break; case OpCode_PointsArray: PointsArray( (int *)o->data.p, o->data.GetUInt() ); break; case OpCode_LineListBuffer: LineListBuffer( (vsRenderBuffer *)o->data.p ); break; case OpCode_LineStripBuffer: LineStripBuffer( (vsRenderBuffer *)o->data.p ); break; case OpCode_TriangleStripBuffer: TriangleStripBuffer( (vsRenderBuffer *)o->data.p ); break; case OpCode_TriangleFanArray: TriangleFanArray( (int *)o->data.p, o->data.GetUInt() ); break; case OpCode_PushTransform: PushTransform( o->data.GetTransform() ); break; case OpCode_SetCameraTransform: SetCameraTransform( o->data.GetTransform() ); break; case OpCode_SetMatrix4x4: SetMatrix4x4( o->data.GetMatrix4x4() ); break; case OpCode_PushMatrix4x4: PushMatrix4x4( o->data.GetMatrix4x4() ); break; case OpCode_SetMatrices4x4: SetMatrices4x4( (vsMatrix4x4*)o->data.p, o->data.i ); break; case OpCode_SetMatrices4x4Buffer: SetMatrices4x4Buffer( (vsRenderBuffer*)o->data.p ); break; case OpCode_SetWorldToViewMatrix4x4: SetWorldToViewMatrix4x4( o->data.GetMatrix4x4() ); break; case OpCode_Set3DProjection: Set3DProjection( o->data.fov, o->data.nearPlane, o->data.farPlane ); break; case OpCode_SetProjectionMatrix4x4: SetProjectionMatrix4x4( o->data.GetMatrix4x4() ); break; case OpCode_PopTransform: PopTransform(); break; case OpCode_EnableStencil: EnableStencil(); break; case OpCode_DisableStencil: DisableStencil(); break; case OpCode_EnableScissor: EnableScissor( o->data.GetBox2D() ); break; case OpCode_DisableScissor: DisableScissor(); break; case OpCode_ClearStencil: ClearStencil(); break; case OpCode_SetViewport: SetViewport( o->data.GetBox2D() ); break; case OpCode_ClearViewport: ClearViewport(); break; case OpCode_Debug: Debug( o->data.GetString() ); break; default: break; } }
//--------------------------------------------------------------------------- // ViewportWndProc // // This is the window procedure for the ViewPort window. It doesn't have to // do all that much, as is obvious... // // RETURNS: Per Windows convention //--------------------------------------------------------------------------- LONG APIENTRY ViewportWndProc (HWND hwnd, WORD msg, WPARAM wParam, LPARAM lParam) { PAINTSTRUCT ps; switch (msg) { case WM_CREATE: { RECT r; HMENU hSysMenu; HANDLE hScreen; // Here, we have to allocate memory for the "screen" memory and // clear it, and also set the "cursor" location and window size // and position monitors. All this stuff is stored in the extra // bytes list of this viewport window. //--------------------------------------------------------------- hScreen = GlobalAlloc (GMEM_MOVEABLE | GMEM_ZEROINIT, MAXLINES * (MAXLINELEN+1)); if (!hScreen) return (-1); SetWindowLong (hwnd, GWW_MEMHANDLE, (UINT)hScreen); SetWindowLong (hwnd, GWW_CURSOR, (UINT)0); SetWindowLong (hwnd, GWW_COMECHO, (UINT)0); GetClientRect (hwnd, &r); SetWindowLong (hwnd, GWW_WINDOWY, (UINT)r.bottom); hSysMenu = GetSystemMenu (hwnd, 0); AppendMenu (hSysMenu, MF_SEPARATOR, 0, NULL); AppendMenu (hSysMenu, MF_STRING, IDM_CLEARVP, "C&lear"); break; } case WM_SIZE: // Reset the WinY client-area variable to the new size //--------------------------------------------------------------- SetWindowLong (hwnd, GWW_WINDOWY, (DWORD)HIWORD(lParam)); break; case WM_GETMINMAXINFO: { POINT FAR *rgpt = (LPPOINT)lParam; TEXTMETRIC tm; HDC hDC; RECT r; HFONT hOldFont; INT maxx, maxy, t; // This is where we tell windows how large/small the window can // be grown/shrunk/maximized, etc. //--------------------------------------------------------------- hDC = GetDC (hwnd); hOldFont = SelectObject (hDC, GetStockObject (ANSI_FIXED_FONT)); GetTextMetrics (hDC, &tm); SelectObject (hDC, hOldFont); ReleaseDC (hwnd, hDC); GetWindowRect (hwnd, &r); maxx = MAXLINELEN * (tm.tmMaxCharWidth); maxy = MAXLINES * (tm.tmHeight + tm.tmExternalLeading); rgpt[1].x = min((GetSystemMetrics(SM_CXFRAME)*2) + maxx, rgpt[1].x); rgpt[1].y = min((GetSystemMetrics(SM_CYFRAME)*2) + GetSystemMetrics(SM_CYCAPTION) + maxy, rgpt[1].y); rgpt[2].x = min(r.left, GetSystemMetrics(SM_CXSCREEN)-rgpt[1].x); t = -GetSystemMetrics(SM_CXFRAME); if (rgpt[2].x < t) rgpt[2].x = t; rgpt[2].y = min(r.top, GetSystemMetrics(SM_CYSCREEN)-rgpt[1].y); t = -GetSystemMetrics(SM_CYFRAME); if (rgpt[2].y < t) rgpt[2].y = t; rgpt[4] = rgpt[1]; break; } case WM_CLOSE: ShowWindow (hwnd, SW_HIDE); break; case WM_SYSCOMMAND: // Closing the viewport by the system menu is actually a "hide" //--------------------------------------------------------------- if (wParam == SC_CLOSE) ShowWindow (hwnd, SW_HIDE); else if (wParam == IDM_CLEARVP) ClearViewport (hwnd); else return (DefWindowProc (hwnd, msg, wParam, lParam)); break; case WM_DESTROY: // Deallocate the screen memory before we die! //--------------------------------------------------------------- GlobalFree ((HANDLE)GetWindowLong (hwnd, GWW_MEMHANDLE)); break; case WM_PAINT: { HFONT hOldFont; // Refresh the client area ONLY IF not minimized //--------------------------------------------------------------- if (IsIconic(hwnd)) break; BeginPaint (hwnd, &ps); hOldFont = SelectObject(ps.hdc, GetStockObject(ANSI_FIXED_FONT)); if (GetWindowLong (hwnd, GWW_WINDOWY) == CW_USEDEFAULT) { RECT r; GetClientRect (hwnd, &r); SetWindowLong (hwnd, GWW_WINDOWY, (UINT)r.bottom); } PaintViewport (hwnd, &ps); SelectObject (ps.hdc, hOldFont); EndPaint (hwnd, &ps); break; } default: return (DefWindowProc (hwnd, msg, wParam, lParam)); } return FALSE; }