コード例 #1
0
//-----------------------------------------------------------------------------
// Paints the engine window	itself
//-----------------------------------------------------------------------------
void CMiniViewportEngineRenderArea::PaintEngineWindow( int x, int y, int w, int h )
{
	if ( !enginetools->IsInGame() )
	{
		surface()->DrawSetColor( Color( 127, 127, 200, 63 ) );
		surface()->DrawFilledRect( x, y, x + w, y + h );
	}
	else
	{
		CMatRenderContextPtr pRenderContext( g_pMaterialSystem );

		g_pMatSystemSurface->DrawSetTextureMaterial( m_nEngineOutputTexture, m_ScreenMaterial );
		surface()->DrawSetColor( Color( 0, 0, 0, 255 ) );

		int nTexWidth = m_ScreenBuffer->GetActualWidth();
		int nTexHeight = m_ScreenBuffer->GetActualHeight();
		float flOOWidth = 1.0f / nTexWidth;
		float flOOHeight = 1.0f / nTexHeight;

		float s0, s1, t0, t1;

		s0 = ( 0.5f ) * flOOWidth;
		t0 = ( 0.5f ) * flOOHeight;
		s1 = ( (float)w - 0.5f ) * flOOWidth;
		t1 = ( (float)h - 0.5f ) * flOOHeight;

		vgui::surface()->DrawTexturedSubRect( x, y, x+w, y+h, s0, t0, s1, t1 );

		PaintOverlayText();
	}
}