1
0
Fork 0

Port more HUD code to use line-segment list.

This commit is contained in:
James Turner 2016-07-31 22:12:26 +01:00
parent c17c3595c8
commit b8e2fb07df
2 changed files with 22 additions and 28 deletions

View file

@ -147,18 +147,12 @@ void HUD::Gauge::draw(void)
text_y = _y + ((cur_value - vmin) * factor() /*+.5f*/);
if (option_right()) {
glBegin(GL_LINE_STRIP);
glVertex2f(_x, text_y + 5);
glVertex2f(marker_xe, text_y);
glVertex2f(_x, text_y - 5);
glEnd();
_hud->_line_list.add(LineSegment(_x, text_y + 5, marker_xe, text_y));
_hud->_line_list.add(LineSegment(marker_xe, text_y, _x, text_y - 5));
}
if (option_left()) {
glBegin(GL_LINE_STRIP);
glVertex2f(right, text_y + 5);
glVertex2f(marker_xs, text_y);
glVertex2f(right, text_y - 5);
glEnd();
_hud->_line_list.add(LineSegment(right, text_y + 5, marker_xs, text_y));
_hud->_line_list.add(LineSegment(marker_xs, text_y, right, text_y - 5));
}
// End if VERTICAL SCALE TYPE
@ -179,11 +173,8 @@ void HUD::Gauge::draw(void)
marker_ye = _y + _h / 2.0; // Tick point adjust
// Bottom arrow
glBegin(GL_LINE_STRIP);
glVertex2f(marker_xs - bottom_4, _y);
glVertex2f(marker_xs, marker_ye);
glVertex2f(marker_xs + bottom_4, _y);
glEnd();
_hud->_line_list.add(LineSegment(marker_xs - bottom_4, _y, marker_xs, marker_ye));
_hud->_line_list.add(LineSegment(marker_xs, marker_ye, marker_xs + bottom_4, _y));
}
if (option_bottom()) {
@ -193,11 +184,8 @@ void HUD::Gauge::draw(void)
marker_ys = top - _h / 2.0;
// Top arrow
glBegin(GL_LINE_STRIP);
glVertex2f(marker_xs + bottom_4, top);
glVertex2f(marker_xs, marker_ys );
glVertex2f(marker_xs - bottom_4, top);
glEnd();
_hud->_line_list.add(LineSegment(marker_xs + bottom_4, top, marker_xs, marker_ys));
_hud->_line_list.add(LineSegment(marker_xs, marker_ys, marker_xs - bottom_4, top));
}

View file

@ -114,29 +114,35 @@ void HUD::Item::draw_text(float x, float y, const char *msg, int align, int digi
void HUD::Item::draw_circle(float xoffs, float yoffs, float r) const
{
glBegin(GL_LINE_LOOP);
float step = SG_PI / r;
for (float alpha = 0; alpha < SG_PI * 2.0; alpha += step) {
double prevX = r;
double prevY = 0.0;
for (float alpha = step; alpha < SG_PI * 2.0; alpha += step) {
float x = r * cos(alpha);
float y = r * sin(alpha);
glVertex2f(x + xoffs, y + yoffs);
_hud->_line_list.add(LineSegment(prevX + xoffs, prevY + yoffs,
x + xoffs, y + yoffs));
prevX = x;
prevY = y;
}
glEnd();
}
void HUD::Item::draw_arc(float xoffs, float yoffs, float t0, float t1, float r) const
{
glBegin(GL_LINE_STRIP);
float step = SG_PI / r;
t0 = t0 * SG_DEGREES_TO_RADIANS;
t1 = t1 * SG_DEGREES_TO_RADIANS;
for (float alpha = t0; alpha < t1; alpha += step) {
double prevX = r * cos(t0);
double prevY = r * sin(t0);
for (float alpha = t0 + step; alpha < t1; alpha += step) {
float x = r * cos(alpha);
float y = r * sin(alpha);
glVertex2f(x + xoffs, y + yoffs);
_hud->_line_list.add(LineSegment(prevX + xoffs, prevY + yoffs,
x + xoffs, y + yoffs));
prevX = x;
prevY = y;
}
glEnd();
}
void HUD::Item::draw_bullet(float x, float y, float size)