1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-29 19:28:47 -05:00

OpenGL modernization: draw the spectrum line in the new way. Use transformation matrix driectly

This commit is contained in:
f4exb 2016-03-02 22:50:05 +01:00
parent a1e2f541da
commit 79c717862c
2 changed files with 11 additions and 16 deletions

View File

@ -23,6 +23,7 @@
#include <QMutex>
#include <QOpenGLBuffer>
#include <QOpenGLVertexArrayObject>
#include <QMatrix4x4>
#include "dsp/dsptypes.h"
#include "gui/scaleengine.h"
#include "dsp/channelmarker.h"
@ -150,7 +151,7 @@ private:
int m_histogramLateHoldoff;
int m_histogramStroke;
QRectF m_glHistogramRect;
QRectF m_glHistogramRect2;
QMatrix4x4 m_glHistogramMatrix;
bool m_displayHistogram;
bool m_displayChanged;

View File

@ -1244,13 +1244,7 @@ void GLSpectrum::paintGL()
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
m_program->bind();
QVector4D color(1.0f, 1.0f, 0.25f, (float) m_displayTraceIntensity / 100.0f);
QMatrix4x4 tsMatrix;
tsMatrix.setToIdentity();
//qDebug("GLSpectrum::paintGL: %f %f %f %f", m_glHistogramRect.x(), m_glHistogramRect.y(), m_glHistogramRect.width(), m_glHistogramRect.height());
tsMatrix.translate(m_glHistogramRect2.x(), m_glHistogramRect2.y(), 0);
//tsMatrix.scale((2.0f * m_glHistogramRect.width()) / (float)(m_fftSize - 1), m_glHistogramRect2.height() / m_powerRange, 1);
tsMatrix.scale((2.0f * m_glHistogramRect.width()) / (float)(m_fftSize - 1), m_glHistogramRect2.height() / m_powerRange, 1);
m_program->setUniformValue(m_matrixLoc, tsMatrix);
m_program->setUniformValue(m_matrixLoc, m_glHistogramMatrix);
m_program->setUniformValue(m_colorLoc, color);
f->glEnable(GL_BLEND);
f->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
@ -1586,14 +1580,14 @@ void GLSpectrum::applyChanges()
(float)histogramHeight / (float)height()
);
float width2 = (float) width() / 2.0f;
float height2 = (float) height() / 2.0f;
m_glHistogramRect2 = QRectF(
-1.0f + ((float)leftMargin / width2),
1.0f - ((float)histogramTop / height2),
-1.0f + (((float) (width() - leftMargin - rightMargin)) / width2),
1.0f - ((float)histogramHeight / height2)
m_glHistogramMatrix.setToIdentity();
m_glHistogramMatrix.translate(
-1.0f + ((float)(2*leftMargin) / (float) width()),
1.0f - ((float)(2*histogramTop) / (float) height())
);
m_glHistogramMatrix.scale(
((float) 2 * (width() - leftMargin - rightMargin)) / ((float) width() * (float)(m_fftSize - 1)),
((float) 2*histogramHeight / height()) / m_powerRange
);
m_frequencyScaleRect = QRect(