1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
|
//========= Copyright Valve Corporation, All rights reserved. ============//
//
// Purpose:
//
// $NoKeywords: $
//=============================================================================//
#include "stdafx.h"
#include "Render2D.h"
#include "gameconfig.h"
#include "vgui_controls/Controls.h"
#include "HammerVGui.h"
#include "material.h"
#include <VGuiMatSurface/IMatSystemSurface.h>
#include "mapview2d.h"
#include "camera.h"
#include "vgui/IScheme.h"
// memdbgon must be the last include file in a .cpp file!!!
#include <tier0/memdbgon.h>
//-----------------------------------------------------------------------------
// Purpose: constructor - initialize all the member variables
//-----------------------------------------------------------------------------
CRender2D::CRender2D()
{
m_vCurLine.Init();
}
//-----------------------------------------------------------------------------
// Purpose: deconstructor - free all info that may need to be freed
//-----------------------------------------------------------------------------
CRender2D::~CRender2D()
{
}
void CRender2D::MoveTo( const Vector &vPoint )
{
m_vCurLine = vPoint;
}
void CRender2D::DrawLineTo( const Vector &vPoint )
{
DrawLine( m_vCurLine, vPoint );
m_vCurLine = vPoint;
}
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// Purpose:
// Input : ptCenter - the center point in client coordinates
// nRadiusX - the x radius in pixels
// nRadiusY - the y radius in pixels
// bFill - Whether to fill the ellipse with the fill color or not.
//-----------------------------------------------------------------------------
void CRender2D::DrawCircle( const Vector &vCenter, float fRadius )
{
Vector vNormal;
GetCamera()->GetViewForward( vNormal );
CRender::DrawCircle( vCenter, vNormal, fRadius, 32 );
}
void CRender2D::DrawRectangle( const Vector &vMins, const Vector &vMaxs, bool bFill, int extent )
{
Vector2D ptMin, ptMax;
TransformPoint( ptMin, vMins );
TransformPoint( ptMax, vMaxs );
if ( ptMin.x > ptMax.x )
V_swap( ptMin.x, ptMax.x );
if ( ptMin.y > ptMax.y )
V_swap( ptMin.y, ptMax.y );
if ( extent != 0 )
{
ptMin.x -= extent;
ptMin.y -= extent;
ptMax.x += extent;
ptMax.y += extent;
}
bool bPopMode = BeginClientSpace();
if ( bFill )
{
CRender::DrawFilledRect( ptMin, ptMax, (byte*)&m_DrawColor, false );
}
else
{
CRender::DrawRect( ptMin, ptMax, (byte*)&m_DrawColor );
}
if ( bPopMode )
EndClientSpace();
}
void CRender2D::DrawBox( const Vector &vMins, const Vector &vMaxs, bool bFill)
{
Vector points[8];
PointsFromBox( vMins, vMaxs, points );
meshBuilder.Begin( m_pMesh, MATERIAL_LINE_LOOP, 6 );
meshBuilder.Position3fv( &points[0].x );
meshBuilder.Color4ubv( (byte*)&m_DrawColor );
meshBuilder.AdvanceVertex();
meshBuilder.Position3fv( &points[4].x );
meshBuilder.Color4ubv( (byte*)&m_DrawColor );
meshBuilder.AdvanceVertex();
meshBuilder.Position3fv( &points[6].x );
meshBuilder.Color4ubv( (byte*)&m_DrawColor );
meshBuilder.AdvanceVertex();
meshBuilder.Position3fv( &points[7].x );
meshBuilder.Color4ubv( (byte*)&m_DrawColor );
meshBuilder.AdvanceVertex();
meshBuilder.Position3fv( &points[3].x );
meshBuilder.Color4ubv( (byte*)&m_DrawColor );
meshBuilder.AdvanceVertex();
meshBuilder.Position3fv( &points[1].x );
meshBuilder.Color4ubv( (byte*)&m_DrawColor );
meshBuilder.AdvanceVertex();
meshBuilder.End();
m_pMesh->Draw();
}
|