From f604261a6ae7e5f1759413e254dc589605b221ca Mon Sep 17 00:00:00 2001 From: James Turner Date: Sun, 31 Jul 2016 22:12:26 +0100 Subject: [PATCH] Port more HUD code to use line-segment list. --- src/Instrumentation/HUD/HUD_gauge.cxx | 28 +++++++--------------- src/Instrumentation/HUD/HUD_instrument.cxx | 22 ++++++++++------- 2 files changed, 22 insertions(+), 28 deletions(-) diff --git a/src/Instrumentation/HUD/HUD_gauge.cxx b/src/Instrumentation/HUD/HUD_gauge.cxx index b1fe5362f..d9e49e011 100644 --- a/src/Instrumentation/HUD/HUD_gauge.cxx +++ b/src/Instrumentation/HUD/HUD_gauge.cxx @@ -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)); } diff --git a/src/Instrumentation/HUD/HUD_instrument.cxx b/src/Instrumentation/HUD/HUD_instrument.cxx index 69fb3309c..ae0e30e5c 100644 --- a/src/Instrumentation/HUD/HUD_instrument.cxx +++ b/src/Instrumentation/HUD/HUD_instrument.cxx @@ -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) -- 2.39.5