cl_cross updates. circle outline added

This commit is contained in:
pierow 2021-02-03 01:11:46 -05:00
parent 418b053e61
commit 01ac6359fa
3 changed files with 29 additions and 4 deletions

View file

@ -20,6 +20,7 @@ int CHudCrosshairs::Init()
cl_cross_outline_alpha = CVAR_CREATE("cl_cross_outline_alpha", "255", FCVAR_ARCHIVE);
cl_cross_outline_inner = CVAR_CREATE("cl_cross_outline_inner", "0", FCVAR_ARCHIVE);
cl_cross_circle_radius = CVAR_CREATE("cl_cross_circle_radius", "0", FCVAR_ARCHIVE);
cl_cross_circle_thickness = CVAR_CREATE("cl_cross_circle_thickness", "1", FCVAR_ARCHIVE);
cl_cross_dot_size = CVAR_CREATE("cl_cross_dot_size", "0", FCVAR_ARCHIVE);
cl_cross_dot_color = CVAR_CREATE("cl_cross_dot_color", "", FCVAR_ARCHIVE);
cl_cross_dot_outline = CVAR_CREATE("cl_cross_dot_outline", "0", FCVAR_ARCHIVE);
@ -164,6 +165,29 @@ int CHudCrosshairs::Draw(float time)
gl.line(Vector2D(center.x - offset.x, center.y - offset.y + dot_half_width), Vector2D(center.x - offset.x, center.y + offset.y - dot_half_width));
gl.line(Vector2D(center.x - offset.x - dot_half_width, center.y + offset.y), Vector2D(center.x + offset.x + dot_half_width, center.y + offset.y));
}
// Circle
if (cl_cross_circle_radius->value > 0.0f && cl_cross_circle_thickness->value > 0.0f) {
auto radius = cl_cross_circle_radius->value;
if (cl_cross_outline_inner->value == 0.0f)
{
radius += (cl_cross_circle_thickness->value * 0.5f) + (cl_cross_outline->value * 0.5f);
gl.line_width(cl_cross_outline->value);
}
else
{
gl.line_width(cl_cross_circle_thickness->value + cl_cross_outline->value);
}
if (old_circle_radius != radius) {
// Recompute the circle points.
circle_points = HudGL::compute_circle(radius);
old_circle_radius = radius;
}
gl.circle(center, circle_points);
}
}
gl.color(r, g, b, alpha);

View file

@ -16,6 +16,7 @@ class CHudCrosshairs : public CHudBase
cvar_t* cl_cross_outline_alpha;
cvar_t* cl_cross_outline_inner;
cvar_t* cl_cross_circle_radius;
cvar_t* cl_cross_circle_thickness;
cvar_t* cl_cross_dot_size;
cvar_t* cl_cross_dot_color;
cvar_t* cl_cross_dot_outline;

View file

@ -52,9 +52,9 @@ void HudGL::line(const Vector2D& start, const Vector2D& end) const {
glEnd();
}
#ifdef __APPLE__
//Remove when OSX builds with c++11
#else
//#ifdef __APPLE__
////Remove when OSX builds with c++11
//#else
void HudGL::circle(const Vector2D& center, const std::vector<Vector2D>& points) const {
glBegin(GL_LINE_STRIP);
@ -64,7 +64,7 @@ void HudGL::circle(const Vector2D& center, const std::vector<Vector2D>& points)
glVertex2f(center.x + points[0].x, center.y + points[0].y);
glEnd();
}
#endif
//#endif
void HudGL::rectangle(const Vector2D& corner_a, const Vector2D& corner_b) const {
glBegin(GL_QUADS);