mirror of
https://github.com/f4exb/sdrangel.git
synced 2024-11-25 17:28:50 -05:00
Spectrum: Enable alpha blending on gradient fill, so channel markers are visible
This commit is contained in:
parent
b8576cf0ae
commit
5c214c0382
@ -37,6 +37,7 @@ GLShaderColorMap::GLShaderColorMap() :
|
|||||||
m_matrixLoc(0),
|
m_matrixLoc(0),
|
||||||
m_colorMapLoc(0),
|
m_colorMapLoc(0),
|
||||||
m_scaleLoc(0),
|
m_scaleLoc(0),
|
||||||
|
m_alphaLoc(0),
|
||||||
m_useImmutableStorage(true)
|
m_useImmutableStorage(true)
|
||||||
{ }
|
{ }
|
||||||
|
|
||||||
@ -86,6 +87,7 @@ void GLShaderColorMap::initializeGL(int majorVersion, int minorVersion)
|
|||||||
m_matrixLoc = m_program->uniformLocation("uMatrix");
|
m_matrixLoc = m_program->uniformLocation("uMatrix");
|
||||||
m_colorMapLoc = m_program->uniformLocation("colorMap");
|
m_colorMapLoc = m_program->uniformLocation("colorMap");
|
||||||
m_scaleLoc = m_program->uniformLocation("scale");
|
m_scaleLoc = m_program->uniformLocation("scale");
|
||||||
|
m_alphaLoc = m_program->uniformLocation("alpha");
|
||||||
if (m_vao)
|
if (m_vao)
|
||||||
{
|
{
|
||||||
m_verticesBuf = new QOpenGLBuffer(QOpenGLBuffer::VertexBuffer);
|
m_verticesBuf = new QOpenGLBuffer(QOpenGLBuffer::VertexBuffer);
|
||||||
@ -149,7 +151,7 @@ void GLShaderColorMap::initColorMapTextureMutable(const QString &colorMapName)
|
|||||||
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_T, QOpenGLTexture::Repeat);
|
glTexParameteri(GL_TEXTURE_1D, GL_TEXTURE_WRAP_T, QOpenGLTexture::Repeat);
|
||||||
}
|
}
|
||||||
|
|
||||||
void GLShaderColorMap::drawSurfaceStrip(const QMatrix4x4& transformMatrix, GLfloat *vertices, int nbVertices, float scale)
|
void GLShaderColorMap::drawSurfaceStrip(const QMatrix4x4& transformMatrix, GLfloat *vertices, int nbVertices, float scale, float alpha)
|
||||||
{
|
{
|
||||||
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
|
QOpenGLFunctions *f = QOpenGLContext::currentContext()->functions();
|
||||||
m_program->bind();
|
m_program->bind();
|
||||||
@ -157,6 +159,7 @@ void GLShaderColorMap::drawSurfaceStrip(const QMatrix4x4& transformMatrix, GLflo
|
|||||||
m_colorMapTexture->bind();
|
m_colorMapTexture->bind();
|
||||||
m_program->setUniformValue(m_colorMapLoc, 0); // Texture unit 0 for color map
|
m_program->setUniformValue(m_colorMapLoc, 0); // Texture unit 0 for color map
|
||||||
m_program->setUniformValue(m_scaleLoc, scale);
|
m_program->setUniformValue(m_scaleLoc, scale);
|
||||||
|
m_program->setUniformValue(m_alphaLoc, alpha);
|
||||||
if (m_vao)
|
if (m_vao)
|
||||||
{
|
{
|
||||||
m_vao->bind();
|
m_vao->bind();
|
||||||
@ -172,6 +175,8 @@ void GLShaderColorMap::drawSurfaceStrip(const QMatrix4x4& transformMatrix, GLflo
|
|||||||
f->glVertexAttribPointer(m_vertexLoc, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
f->glVertexAttribPointer(m_vertexLoc, 2, GL_FLOAT, GL_FALSE, 0, vertices);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
f->glEnable(GL_BLEND);
|
||||||
|
f->glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
|
||||||
f->glDrawArrays(GL_TRIANGLE_STRIP, 0, nbVertices);
|
f->glDrawArrays(GL_TRIANGLE_STRIP, 0, nbVertices);
|
||||||
|
|
||||||
if (m_vao)
|
if (m_vao)
|
||||||
@ -256,21 +261,23 @@ const QString GLShaderColorMap::m_vertexShaderSourceColorMap = QString(
|
|||||||
);
|
);
|
||||||
|
|
||||||
const QString GLShaderColorMap::m_fragmentShaderSourceColorMap2 = QString(
|
const QString GLShaderColorMap::m_fragmentShaderSourceColorMap2 = QString(
|
||||||
|
"uniform float alpha;\n"
|
||||||
"uniform float scale;\n"
|
"uniform float scale;\n"
|
||||||
"uniform highp sampler1D colorMap;\n"
|
"uniform highp sampler1D colorMap;\n"
|
||||||
"varying float y;\n"
|
"varying float y;\n"
|
||||||
"void main() {\n"
|
"void main() {\n"
|
||||||
" gl_FragColor = texture1D(colorMap, 1.0-(y/scale));\n"
|
" gl_FragColor = vec4(texture1D(colorMap, 1.0-(y/scale)).rgb, alpha);\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
);
|
);
|
||||||
|
|
||||||
const QString GLShaderColorMap::m_fragmentShaderSourceColorMap = QString(
|
const QString GLShaderColorMap::m_fragmentShaderSourceColorMap = QString(
|
||||||
"#version 330\n"
|
"#version 330\n"
|
||||||
|
"uniform float alpha;\n"
|
||||||
"uniform float scale;\n"
|
"uniform float scale;\n"
|
||||||
"uniform sampler1D colorMap;\n"
|
"uniform sampler1D colorMap;\n"
|
||||||
"in float y;\n"
|
"in float y;\n"
|
||||||
"out vec4 fragColor;\n"
|
"out vec4 fragColor;\n"
|
||||||
"void main() {\n"
|
"void main() {\n"
|
||||||
" fragColor = texture(colorMap, 1.0-(y/scale));\n"
|
" fragColor = vec4(texture(colorMap, 1.0-(y/scale)).rgb, alpha);\n"
|
||||||
"}\n"
|
"}\n"
|
||||||
);
|
);
|
||||||
|
@ -41,7 +41,7 @@ public:
|
|||||||
|
|
||||||
void initializeGL(int majorVersion, int minorVersion);
|
void initializeGL(int majorVersion, int minorVersion);
|
||||||
void initColorMapTexture(const QString &colorMapName);
|
void initColorMapTexture(const QString &colorMapName);
|
||||||
void drawSurfaceStrip(const QMatrix4x4& transformMatrix, GLfloat *vertices, int nbVertices, float scale);
|
void drawSurfaceStrip(const QMatrix4x4& transformMatrix, GLfloat *vertices, int nbVertices, float scale, float alpha);
|
||||||
void cleanup();
|
void cleanup();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
@ -58,6 +58,7 @@ private:
|
|||||||
int m_matrixLoc;
|
int m_matrixLoc;
|
||||||
int m_colorMapLoc;
|
int m_colorMapLoc;
|
||||||
int m_scaleLoc;
|
int m_scaleLoc;
|
||||||
|
int m_alphaLoc;
|
||||||
bool m_useImmutableStorage;
|
bool m_useImmutableStorage;
|
||||||
static const QString m_vertexShaderSourceColorMap2;
|
static const QString m_vertexShaderSourceColorMap2;
|
||||||
static const QString m_vertexShaderSourceColorMap;
|
static const QString m_vertexShaderSourceColorMap;
|
||||||
|
@ -1345,7 +1345,7 @@ void GLSpectrum::paintGL()
|
|||||||
|
|
||||||
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);
|
||||||
if (m_spectrumStyle == SpectrumSettings::Gradient) {
|
if (m_spectrumStyle == SpectrumSettings::Gradient) {
|
||||||
m_glShaderColorMap.drawSurfaceStrip(m_glHistogramSpectrumMatrix, q3, 2*m_nbBins, bottom);
|
m_glShaderColorMap.drawSurfaceStrip(m_glHistogramSpectrumMatrix, q3, 2*m_nbBins, bottom, 0.75f);
|
||||||
} else {
|
} else {
|
||||||
m_glShaderSimple.drawSurfaceStrip(m_glHistogramSpectrumMatrix, color, q3, 2*m_nbBins);
|
m_glShaderSimple.drawSurfaceStrip(m_glHistogramSpectrumMatrix, color, q3, 2*m_nbBins);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user