1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-26 17:58:43 -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 <QMutex>
#include <QOpenGLBuffer> #include <QOpenGLBuffer>
#include <QOpenGLVertexArrayObject> #include <QOpenGLVertexArrayObject>
#include <QMatrix4x4>
#include "dsp/dsptypes.h" #include "dsp/dsptypes.h"
#include "gui/scaleengine.h" #include "gui/scaleengine.h"
#include "dsp/channelmarker.h" #include "dsp/channelmarker.h"
@ -150,7 +151,7 @@ private:
int m_histogramLateHoldoff; int m_histogramLateHoldoff;
int m_histogramStroke; int m_histogramStroke;
QRectF m_glHistogramRect; QRectF m_glHistogramRect;
QRectF m_glHistogramRect2; QMatrix4x4 m_glHistogramMatrix;
bool m_displayHistogram; bool m_displayHistogram;
bool m_displayChanged; bool m_displayChanged;

View File

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