コード例 #1
0
	void CoreDelegateImpl::Draw()
	{
		static float x = 50;
		static float y = 600;
		auto p_renderer = Core::GetRenderer();
		IRect rect = p_renderer->GetTargetRectangle();
		p_renderer->SetMatrix(MatrixMode::Projection, Matrix4f::CreateOrtho(0, rect.Width(), 0, rect.Height()));
		std::wstring message = L"FPS: " + std::to_wstring(Core::GetApplication()->GetCurrentFPS());
		auto en_font = Core::GetGlobalObject<Resources::ResourceManager>()->GetHandleToResource<Render::Font>("Arial_en");
		auto arial_font = Core::GetGlobalObject<Resources::ResourceManager>()->GetHandleToResource<Render::Font>("Arial");
		Core::GetGlobalObject<Render::FontManager>()->Render({ x, y }, 1.f, message, arial_font);
		Core::GetGlobalObject<Render::FontManager>()->Render({ x, y - 50 }, 1.f, message_num_0, en_font);
		Core::GetGlobalObject<Render::FontManager>()->Render({ x, y - 100 }, 1.f, L"Мама мыла раму!", arial_font);
	}
コード例 #2
0
	void CoreDelegateImpl::Draw()
	{
		auto p_lights = Core::GetRenderer()->GetLightsController();
		p_lights->DisableLighting();
		drawGrid(100, 4);
		p_lights->EnableLighting();
		static float x = 50;
		static float y = 600;
		auto p_renderer = Core::GetRenderer();
		IRect rect = p_renderer->GetTargetRectangle();
		p_renderer->SetMatrix(MatrixMode::Projection, Matrix4f::CreateOrtho(0, rect.Width(), 0, rect.Height()));
		std::wstring message = L"FPS: " + std::to_wstring(Core::GetApplication()->GetCurrentFPS());
		auto en_font = Core::GetGlobalObject<Resources::ResourceManager>()->GetHandleToResource<Render::Font>("Arial_en");

		auto p_font_mgr = Core::GetGlobalObject<Render::FontManager>();
		p_font_mgr->Render({ x, 900 }, 0.6f, message, en_font);
		p_font_mgr->Render({ x, 865 }, 0.6f, L"Vertices: " + std::to_wstring(Core::GetGlobalObject<Render::MeshSystem>()->GetVerticesRendered()), en_font);
		p_font_mgr->Render({ x, 830 }, 0.6f, L"Trigs: " + std::to_wstring(Core::GetGlobalObject<Render::MeshSystem>()->GetTrianglesRendered()), en_font);
		/*message = L"asdqwetbij[we6  ewrgasdf";
		for (int i = 0; i < 100; ++i)
			p_font_mgr->Render({ x, y }, 1.f, message, en_font);*/
	}
コード例 #3
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : *panel - 
//-----------------------------------------------------------------------------
void CAxialLinePanelEffect::doPaint( vgui::Panel *panel )
{
	vgui::Panel *from = m_hPanel;
	if ( !from || !IsVisibleIncludingParent( from ) )
		return;

	int r, g, b;

	if ( m_bFlashing )
	{
		// Determine flash amount
		float frac = fmod( gpGlobals->curtime, EFFECT_FLASH_TIME );
		frac *= 2 * M_PI;
		frac = cos( frac );

		// Resample color
		r = EffectResampleColor( m_r, frac );
		g = EffectResampleColor( m_g, frac );
		b = EffectResampleColor( m_b, frac );
	}
	else
	{
		r = m_r;
		g = m_g;
		b = m_b;
	}

	int startx, starty, startw, starth;
	int endx, endy, endw, endh;

	PanelToPanelRectangle( startx, starty, startw, starth, panel, from );

	if ( !GetTargetRectangle( panel, endx, endy, endw, endh ) )
		return;

	CUtlVector< CConnectingLine > lines;

	FindConnectingLines_Axial( startx, starty, startw, starth, endx, endy, endw, endh, lines );

	int i;

	if ( m_bDrawBorder )
	{
		for ( i = 0; i < lines.Size(); i++ )
		{
			CConnectingLine *l = &lines[ i ];

			// Draw a black border
			for ( int x = -1; x <= 1; x ++ )
			{
				for ( int y = -1; y <= 1; y ++ )
				{
					if ( !x && !y )
						continue;

					DrawLine( l->m_ptStart[ 0 ] + x, l->m_ptStart[1] + y, l->m_ptEnd[0] + x, l->m_ptEnd[1] + y, 0, 0, 0, m_a );	
				}
			}
		}
	}

	// Draw actual lines
	for ( i = 0; i < lines.Size(); i++ )
	{
		CConnectingLine *l = &lines[ i ];
		DrawLine( l->m_ptStart[ 0 ], l->m_ptStart[ 1 ], l->m_ptEnd[ 0 ], l->m_ptEnd[ 1 ], r, g, b, m_a );
	}
}
コード例 #4
0
//-----------------------------------------------------------------------------
// Purpose: 
// Input  : *panel - 
//-----------------------------------------------------------------------------
void CArrowPanelEffect::doPaint( vgui::Panel *panel )
{
	vgui::Panel *from = m_hPanel;
	if ( !from || !IsVisibleIncludingParent( from ) )
		return;

	int r, g, b;
	// Determine flash amount
	if ( m_bFlashing )
	{
		float frac = fmod( gpGlobals->curtime, EFFECT_FLASH_TIME );
		frac *= 2 * M_PI;
		frac = cos( frac );

		// Resample color

		r = EffectResampleColor( m_r, frac );
		g = EffectResampleColor( m_g, frac );
		b = EffectResampleColor( m_b, frac );
	}
	else
	{
		r = m_r;
		g = m_g;
		b = m_b;
	}

	int startx, starty, startw, starth;
	int endx, endy, endw, endh;

	PanelToPanelRectangle( startx, starty, startw, starth, panel, from );

	if ( !GetTargetRectangle( panel, endx, endy, endw, endh ) )
		return;

	CUtlVector< CConnectingLine > lines;

	FindConnectingLines_Straight( startx, starty, startw, starth, endx, endy, endw, endh, lines );

	int i;

	if ( m_bDrawBorder )
	{
		for ( i = 0; i < lines.Size(); i++ )
		{
			CConnectingLine *l = &lines[ i ];

			// Make it thicker
			int hstep = 0;
			int vstep = 0;

			if ( abs( l->m_ptEnd[ 1 ] - l->m_ptStart[ 1 ] ) > abs( l->m_ptEnd[ 0 ] - l->m_ptStart[ 0 ] ) )
			{
				// Taller so draw horizontally
				hstep = 1;
			}
			else
			{
				vstep = 1;
			}

			// Draw a black border
			for ( int x = -1; x <= 1 + hstep; x ++ )
			{
				for ( int y = -1; y <= 1 + vstep; y ++ )
				{
					if ( !x && !y )
						continue;

					if ( i == lines.Size() - 1 )
					{
						DrawArrow( l->m_ptStart[ 0 ] + x, l->m_ptStart[1] + y, l->m_ptEnd[0] + x, l->m_ptEnd[1] + y, 0, 0, 0, m_a );	
					}
					else
					{
						DrawLine( l->m_ptStart[ 0 ] + x, l->m_ptStart[1] + y, l->m_ptEnd[0] + x, l->m_ptEnd[1] + y, 0, 0, 0, m_a );	
					}
				}
			}
		}
	}

	for ( i = 0; i < lines.Size(); i++ )
	{
		CConnectingLine *l = &lines[ i ];

		// Make it thicker
		int hstep = 0;
		int vstep = 0;

		if ( abs( l->m_ptEnd[ 1 ] - l->m_ptStart[ 1 ] ) > abs( l->m_ptEnd[ 0 ] - l->m_ptStart[ 0 ] ) )
		{
			// Taller so draw horizontally
			hstep = 1;
		}
		else
		{
			vstep = 1;
		}

		if ( i == lines.Size() - 1 )
		{
			// Draw arrow
			DrawArrow( l->m_ptStart[ 0 ], l->m_ptStart[ 1 ], l->m_ptEnd[ 0 ], l->m_ptEnd[ 1 ], r, g, b, m_a );
			// Draw a second time, but thicker
			DrawArrow( l->m_ptStart[ 0 ] + hstep, l->m_ptStart[ 1 ] + vstep, l->m_ptEnd[ 0 ] + hstep, l->m_ptEnd[ 1 ] + vstep, r, g, b, m_a );
		}
		else
		{
			// Draw arrow
			DrawLine( l->m_ptStart[ 0 ], l->m_ptStart[ 1 ], l->m_ptEnd[ 0 ], l->m_ptEnd[ 1 ], r, g, b, m_a );
			// Draw a second time, but thicker
			DrawLine( l->m_ptStart[ 0 ] + hstep, l->m_ptStart[ 1 ] + vstep, l->m_ptEnd[ 0 ] + hstep, l->m_ptEnd[ 1 ] + vstep, r, g, b, m_a );
		}
	}
}