summaryrefslogtreecommitdiffstats
path: root/src/waveform/renderers/glwaveformrenderersimplesignal.cpp
diff options
context:
space:
mode:
authorDaniel Schürmann <daschuer@mixxx.org>2018-04-03 00:33:43 +0200
committerDaniel Schürmann <daschuer@mixxx.org>2018-04-03 00:33:43 +0200
commit5b05339c7710ebe096da467b810d29bfafa435a8 (patch)
treecfb0b8d45c7b06dfe059ea77a1b87a429bd6d6f3 /src/waveform/renderers/glwaveformrenderersimplesignal.cpp
parent9f96292b83964dc5242bec21b589d86d600a0911 (diff)
Fix shimmering of GL Waveforms
Diffstat (limited to 'src/waveform/renderers/glwaveformrenderersimplesignal.cpp')
-rw-r--r--src/waveform/renderers/glwaveformrenderersimplesignal.cpp68
1 files changed, 32 insertions, 36 deletions
diff --git a/src/waveform/renderers/glwaveformrenderersimplesignal.cpp b/src/waveform/renderers/glwaveformrenderersimplesignal.cpp
index f825058d86..4ac046a589 100644
--- a/src/waveform/renderers/glwaveformrenderersimplesignal.cpp
+++ b/src/waveform/renderers/glwaveformrenderersimplesignal.cpp
@@ -49,6 +49,7 @@ void GLWaveformRendererSimpleSignal::draw(QPainter* painter, QPaintEvent* /*even
double firstVisualIndex = m_waveformRenderer->getFirstDisplayedPosition() * dataSize;
double lastVisualIndex = m_waveformRenderer->getLastDisplayedPosition() * dataSize;
+ double lineWidth = (1.0 / m_waveformRenderer->getVisualSamplePerPixel()) + 1.0;
const int firstIndex = int(firstVisualIndex+0.5);
firstVisualIndex = firstIndex - firstIndex%2;
@@ -67,8 +68,6 @@ void GLWaveformRendererSimpleSignal::draw(QPainter* painter, QPaintEvent* /*even
float allGain(1.0);
getGains(&allGain, NULL, NULL, NULL);
- float maxAll[2];
-
if (m_alignment == Qt::AlignCenter) {
glMatrixMode(GL_PROJECTION);
glPushMatrix();
@@ -97,24 +96,22 @@ void GLWaveformRendererSimpleSignal::draw(QPainter* painter, QPaintEvent* /*even
}
glEnd();
- glBegin(GL_QUADS); {
- for (int visualIndex = firstVisualIndex;
- visualIndex < lastVisualIndex;
- visualIndex += 2) {
-
- if (visualIndex < 0)
- continue;
+ glLineWidth(lineWidth);
+ glEnable(GL_LINE_SMOOTH);
- if (visualIndex > dataSize - 1)
- break;
-
- maxAll[0] = (float)data[visualIndex].filtered.all;
- maxAll[1] = (float)data[visualIndex+1].filtered.all;
- glColor4f(m_signalColor_r, m_signalColor_g, m_signalColor_b, 0.9);
- glVertex2f(visualIndex - 1.0f, maxAll[0]);
- glVertex2f(visualIndex - 1.0f, -1.0f * maxAll[1]);
- glVertex2f(visualIndex + 1.0f, -1.0f * maxAll[1]);
- glVertex2f(visualIndex + 1.0f, maxAll[0]);
+ glBegin(GL_LINES); {
+ int firstIndex = math_max(static_cast<int>(firstVisualIndex), 0);
+ int lastIndex = math_min(static_cast<int>(lastVisualIndex), dataSize);
+
+ glColor4f(m_signalColor_r, m_signalColor_g, m_signalColor_b, 0.9);
+ for (int visualIndex = firstIndex;
+ visualIndex < lastIndex;
+ visualIndex += 2) {
+
+ GLfloat maxAll0 = data[visualIndex].filtered.all;
+ GLfloat maxAll1 = data[visualIndex+1].filtered.all;
+ glVertex2f(visualIndex, maxAll0);
+ glVertex2f(visualIndex, -1.f * maxAll1);
}
}
glEnd();
@@ -137,24 +134,23 @@ void GLWaveformRendererSimpleSignal::draw(QPainter* painter, QPaintEvent* /*even
glScalef(1.f, allGain, 1.f);
- glBegin(GL_QUADS); {
- for (int visualIndex = firstVisualIndex;
- visualIndex < lastVisualIndex;
- visualIndex += 2) {
+ glLineWidth(lineWidth);
+ glEnable(GL_LINE_SMOOTH);
- if (visualIndex < 0)
- continue;
-
- if (visualIndex > dataSize - 1)
- break;
-
- maxAll[0] = (float)data[visualIndex].filtered.all;
- maxAll[1] = (float)data[visualIndex+1].filtered.all;
- glColor4f(m_signalColor_r, m_signalColor_g, m_signalColor_b, 0.8);
- glVertex2f(float(visualIndex) - 1.0f, 0.0f);
- glVertex2f(float(visualIndex) - 1.0f, math_max(maxAll[0], maxAll[1]));
- glVertex2f(float(visualIndex) + 1.0f, math_max(maxAll[0], maxAll[1]));
- glVertex2f(float(visualIndex) + 1.0f, 0.0f);
+ glBegin(GL_LINES); {
+ int firstIndex = math_max(static_cast<int>(firstVisualIndex), 0);
+ int lastIndex = math_min(static_cast<int>(lastVisualIndex), dataSize);
+
+ glColor4f(m_signalColor_r, m_signalColor_g, m_signalColor_b, 0.8);
+ for (int visualIndex = firstIndex;
+ visualIndex < lastIndex;
+ visualIndex += 2) {
+
+ GLfloat maxAll = math_max(
+ data[visualIndex].filtered.all,
+ data[visualIndex+1].filtered.all);
+ glVertex2f(float(visualIndex), 0.f);
+ glVertex2f(float(visualIndex), maxAll);
}
}
glEnd();