From 1e81969fca71a606f281608e61417908374e9ba4 Mon Sep 17 00:00:00 2001 From: Thomas Wilshaw Date: Tue, 5 May 2020 11:29:15 +0100 Subject: [PATCH] Waveform fixes - Due to a floating point division error not all the bars on the waveform were being drawn. - Fix ratio in the fragment shader --- app/shaders/rgbwaveform.frag | 2 +- app/widget/scope/waveform/waveform.cpp | 3 ++- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/app/shaders/rgbwaveform.frag b/app/shaders/rgbwaveform.frag index 3e839b386..4e6b13f08 100644 --- a/app/shaders/rgbwaveform.frag +++ b/app/shaders/rgbwaveform.frag @@ -52,7 +52,7 @@ void main(void) { float waveform_x = (ove_texcoord.x - waveform_uv.x) / waveform_scale; float waveform_y = (ove_texcoord.y - waveform_uv.y) / waveform_scale; for (int i = 0; i < waveform_dims.y; i++) { - ratio = float(i) / float(waveform_dims.y); + ratio = float(i) / float(waveform_dims.y - 1); cur_col = texture( ove_maintex, vec2(waveform_x, ratio) diff --git a/app/widget/scope/waveform/waveform.cpp b/app/widget/scope/waveform/waveform.cpp index 6c3c43fc7..842cc678c 100644 --- a/app/widget/scope/waveform/waveform.cpp +++ b/app/widget/scope/waveform/waveform.cpp @@ -98,7 +98,8 @@ void WaveformScope::DrawScope() QFontMetrics font_metrics = QFontMetrics(QFont()); QString label; float ire_increment = 0.1f; - float ire_steps = int(1.0 / ire_increment); + // Cast required to avoid floating point errors + int ire_steps = static_cast(std::round(1.0 / ire_increment)); QVector ire_lines(ire_steps + 1); int font_x_offset = 0; int font_y_offset = font_metrics.capHeight() / 2.0f;