//----------------------------------------------------------------------------- // main application //----------------------------------------------------------------------------- void CVsVGuiWindow::PaintWindow() { if ( m_nCurrentTick == m_nLastRenderedTick || !g_pVGui->IsRunning() ) { ValidateRect( m_hWnd, NULL ); return; } m_nCurrentTick = m_nLastRenderedTick; vgui::VPANEL root = g_pVGuiSurface->GetEmbeddedPanel(); g_pVGuiSurface->Invalidate( root ); RECT windowRect; CMatRenderContextPtr pRenderContext( g_pMaterialSystem ); ::GetClientRect( m_hWnd, &windowRect ); g_pMaterialSystem->SetView( m_hWnd ); pRenderContext->Viewport( 0, 0, windowRect.right, windowRect.bottom ); float flStartTime = Plat_FloatTime(); pRenderContext->ClearColor4ub( 76, 88, 68, 255 ); pRenderContext->ClearBuffers( true, true ); g_pMaterialSystem->BeginFrame( 0 ); // draw from the main panel down if ( m_hMainPanel.Get() ) { int w, h; m_hMainPanel->GetSize( w, h ); if ( w != windowRect.right || h != windowRect.bottom ) { m_hMainPanel->SetBounds( 0, 0, windowRect.right, windowRect.bottom ); m_hMainPanel->Repaint(); } g_pVGuiSurface->RestrictPaintToSinglePanel( m_hMainPanel->GetVPanel() ); g_pVGuiSurface->PaintTraverseEx( root, true ); g_pVGuiSurface->RestrictPaintToSinglePanel( 0 ); } g_pMaterialSystem->EndFrame(); g_pMaterialSystem->SwapBuffers(); g_pMaterialSystem->SetView( NULL ); ValidateRect( m_hWnd, NULL ); m_flRenderDelayTime = Plat_FloatTime() - flStartTime; m_flRenderDelayTime = max( m_flRenderDelayTime, 0.015f ); }