use a single glBegin/glEnd in spectrum and scope

This commit is contained in:
Christian Daniel 2013-02-12 15:54:58 +01:00
parent eb6ab41720
commit dcfc4ed31c
2 changed files with 10 additions and 31 deletions

View File

@ -203,25 +203,18 @@ void GLScope::paintGL()
int end = start + m_trace.size() / m_timeStep;
if(end - start < 2)
start--;
float prev = m_trace[start].real();
float posLimit = 1.0 / m_amp;
float negLimit = -1.0 / m_amp;
if(prev > posLimit)
prev = posLimit;
else if(prev < negLimit)
prev = negLimit;
for(int i = start + 1; i < end; i++) {
glBegin(GL_LINE_STRIP);
for(int i = start; i < end; i++) {
float v = m_trace[i].real();
if(v > posLimit)
v = posLimit;
else if(v < negLimit)
v = negLimit;
glBegin(GL_LINE_LOOP);
glVertex2f(i - 1 - start, prev);
glVertex2f(i - start, v);
glEnd();
prev = v;
}
glEnd();
glDisable(GL_LINE_SMOOTH);
glPopMatrix();
}
@ -297,25 +290,18 @@ void GLScope::paintGL()
int end = start + m_trace.size() / m_timeStep;
if(end - start < 2)
start--;
float prev = m_trace[start].imag();
float posLimit = 1.0 / m_amp;
float negLimit = -1.0 / m_amp;
if(prev > posLimit)
prev = posLimit;
else if(prev < negLimit)
prev = negLimit;
for(int i = start + 1; i < end; i++) {
glBegin(GL_LINE_STRIP);
for(int i = start; i < end; i++) {
float v = m_trace[i].imag();
if(v > posLimit)
v = posLimit;
else if(v < negLimit)
v = negLimit;
glBegin(GL_LINE_LOOP);
glVertex2f(i - 1 - start, prev);
glVertex2f(i - start, v);
glEnd();
prev = v;
}
glEnd();
glDisable(GL_LINE_SMOOTH);
glPopMatrix();
}

View File

@ -532,25 +532,18 @@ void GLSpectrum::paintGL()
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
glEnable(GL_LINE_SMOOTH);
glLineWidth(1.0f);
glColor4f(1, 1, 1, 0.5f);
glColor4f(1, 1, 1, 0.75f);
Real bottom = -m_powerRange;
Real prev = m_liveSpectrum[0] - m_referenceLevel;
if(prev > 0)
prev = 0;
else if(prev < bottom)
prev = bottom;
for(int i = 1; i < m_fftSize; i++) {
glBegin(GL_LINE_STRIP);
for(int i = 0; i < m_fftSize; i++) {
Real v = m_liveSpectrum[i] - m_referenceLevel;
if(v > 0)
v = 0;
else if(v < bottom)
v = bottom;
glBegin(GL_LINE_LOOP);
glVertex2f(i - 1, prev);
glVertex2f(i, v);
glEnd();
prev = v;
}
glEnd();
glDisable(GL_LINE_SMOOTH);
glPopMatrix();
}