1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-11-25 17:28:50 -05:00

Use integers for OpenGL version

This commit is contained in:
Jon Beniston 2022-06-19 00:11:46 +01:00
parent e13e919012
commit e31880fc66
10 changed files with 38 additions and 36 deletions

View File

@ -156,7 +156,8 @@ void GLScope::newTraces(std::vector<float *> *traces, int traceIndex, std::vecto
void GLScope::initializeGL()
{
QOpenGLContext *glCurrentContext = QOpenGLContext::currentContext();
float openGLVersion = 0.0f;
int majorVersion = 0;
int minorVersion = 0;
if (glCurrentContext)
{
@ -166,8 +167,8 @@ void GLScope::initializeGL()
<< " major: " << (QOpenGLContext::currentContext()->format()).majorVersion()
<< " minor: " << (QOpenGLContext::currentContext()->format()).minorVersion()
<< " ES: " << (QOpenGLContext::currentContext()->isOpenGLES() ? "yes" : "no");
openGLVersion = (QOpenGLContext::currentContext()->format()).majorVersion()
+ ((QOpenGLContext::currentContext()->format()).minorVersion() / 10.0);
majorVersion = (QOpenGLContext::currentContext()->format()).majorVersion();
minorVersion = (QOpenGLContext::currentContext()->format()).minorVersion();
}
else
{
@ -208,14 +209,14 @@ void GLScope::initializeGL()
glFunctions->initializeOpenGLFunctions();
//glDisable(GL_DEPTH_TEST);
m_glShaderSimple.initializeGL(openGLVersion);
m_glShaderColors.initializeGL(openGLVersion);
m_glShaderLeft1Scale.initializeGL(openGLVersion);
m_glShaderBottom1Scale.initializeGL(openGLVersion);
m_glShaderLeft2Scale.initializeGL(openGLVersion);
m_glShaderBottom2Scale.initializeGL(openGLVersion);
m_glShaderPowerOverlay.initializeGL(openGLVersion);
m_glShaderTextOverlay.initializeGL(openGLVersion);
m_glShaderSimple.initializeGL(majorVersion, minorVersion);
m_glShaderColors.initializeGL(majorVersion, minorVersion);
m_glShaderLeft1Scale.initializeGL(majorVersion, minorVersion);
m_glShaderBottom1Scale.initializeGL(majorVersion, minorVersion);
m_glShaderLeft2Scale.initializeGL(majorVersion, minorVersion);
m_glShaderBottom2Scale.initializeGL(majorVersion, minorVersion);
m_glShaderPowerOverlay.initializeGL(majorVersion, minorVersion);
m_glShaderTextOverlay.initializeGL(majorVersion, minorVersion);
}
void GLScope::resizeGL(int width, int height)

View File

@ -36,11 +36,11 @@ GLShaderColors::~GLShaderColors()
cleanup();
}
void GLShaderColors::initializeGL(float openGLVersion)
void GLShaderColors::initializeGL(int majorVersion, int minorVersion)
{
m_program = new QOpenGLShaderProgram;
if (openGLVersion >= 3.3)
if ((majorVersion > 3) || ((majorVersion == 3) && (minorVersion >= 3)))
{
if (!m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, m_vertexShaderSourceSimple)) {
qDebug() << "GLShaderColors::initializeGL: error in vertex shader: " << m_program->log();

View File

@ -37,7 +37,7 @@ public:
GLShaderColors();
~GLShaderColors();
void initializeGL(float openGLVersion);
void initializeGL(int majorVersion, int minorVersion);
void drawPoints(const QMatrix4x4& transformMatrix, GLfloat *vertices, GLfloat *colors, GLfloat alpha, int nbVertices);
void drawPolyline(const QMatrix4x4& transformMatrix, GLfloat *vertices, GLfloat *colors, GLfloat alpha, int nbVertices);
void drawSegments(const QMatrix4x4& transformMatrix, GLfloat *vertices, GLfloat *colors, GLfloat alpha, int nbVertices);

View File

@ -36,11 +36,11 @@ GLShaderSimple::~GLShaderSimple()
cleanup();
}
void GLShaderSimple::initializeGL(float openGLVersion)
void GLShaderSimple::initializeGL(int majorVersion, int minorVersion)
{
m_program = new QOpenGLShaderProgram;
if (openGLVersion >= 3.3)
if ((majorVersion > 3) || ((majorVersion == 3) && (minorVersion >= 3)))
{
if (!m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, m_vertexShaderSourceSimple)) {
qDebug() << "GLShaderSimple::initializeGL: error in vertex shader: " << m_program->log();

View File

@ -34,7 +34,7 @@ public:
GLShaderSimple();
~GLShaderSimple();
void initializeGL(float openGLVersion);
void initializeGL(int majorVersion, int minorVersion);
void drawPoints(const QMatrix4x4& transformMatrix, const QVector4D& color, GLfloat *vertices, int nbVertices, int nbComponents=2);
void drawPolyline(const QMatrix4x4& transformMatrix, const QVector4D& color, GLfloat *vertices, int nbVertices, int nbComponents=2);
void drawSegments(const QMatrix4x4& transformMatrix, const QVector4D& color, GLfloat *vertices, int nbVertices, int nbComponents=2);

View File

@ -75,13 +75,13 @@ GLShaderSpectrogram::~GLShaderSpectrogram()
cleanup();
}
void GLShaderSpectrogram::initializeGL(float openGLVersion)
void GLShaderSpectrogram::initializeGL(int majorVersion, int minorVersion)
{
initializeOpenGLFunctions();
m_useImmutableStorage = useImmutableStorage();
qDebug() << "GLShaderSpectrogram::initializeGL: m_useImmutableStorage: " << m_useImmutableStorage;
if (openGLVersion >= 3.3)
if ((majorVersion > 3) || ((majorVersion == 3) && (minorVersion >= 3)))
{
m_programShaded = new QOpenGLShaderProgram;
if (!m_programShaded->addShaderFromSourceCode(QOpenGLShader::Vertex, m_vertexShader)) {

View File

@ -36,7 +36,7 @@ public:
GLShaderSpectrogram();
~GLShaderSpectrogram();
void initializeGL(float openGLVersion);
void initializeGL(int majorVersion, int minorVersion);
void initColorMapTexture(const QString &colorMapName);
void initTexture(const QImage& image);
void subTexture(int xOffset, int yOffset, int width, int height, const void *pixels);

View File

@ -40,14 +40,14 @@ GLShaderTextured::~GLShaderTextured()
cleanup();
}
void GLShaderTextured::initializeGL(float openGLVersion)
void GLShaderTextured::initializeGL(int majorVersion, int minorVersion)
{
initializeOpenGLFunctions();
m_useImmutableStorage = useImmutableStorage();
qDebug() << "GLShaderTextured::initializeGL: m_useImmutableStorage: " << m_useImmutableStorage;
m_program = new QOpenGLShaderProgram;
if (openGLVersion >= 3.3f)
if ((majorVersion > 3) || ((majorVersion == 3) && (minorVersion >= 3)))
{
if (!m_program->addShaderFromSourceCode(QOpenGLShader::Vertex, m_vertexShaderSourceTextured)) {
qDebug() << "GLShaderTextured::initializeGL: error in vertex shader: " << m_program->log();

View File

@ -38,7 +38,7 @@ public:
GLShaderTextured();
~GLShaderTextured();
void initializeGL(float openGLVersion);
void initializeGL(int majorVersion, int minorVersion);
void initTexture(const QImage& image, QOpenGLTexture::WrapMode wrapMode = QOpenGLTexture::Repeat);
void subTexture(int xOffset, int yOffset, int width, int height, const void *pixels);
void drawSurface(const QMatrix4x4& transformMatrix, GLfloat* textureCoords, GLfloat *vertices, int nbVertices, int nbComponents=2);

View File

@ -766,7 +766,8 @@ void GLSpectrum::updateHistogram(const Real *spectrum)
void GLSpectrum::initializeGL()
{
QOpenGLContext *glCurrentContext = QOpenGLContext::currentContext();
float openGLVersion = 0.0f;
int majorVersion = 0;
int minorVersion = 0;
if (glCurrentContext)
{
@ -776,8 +777,8 @@ void GLSpectrum::initializeGL()
<< " major: " << (QOpenGLContext::currentContext()->format()).majorVersion()
<< " minor: " << (QOpenGLContext::currentContext()->format()).minorVersion()
<< " ES: " << (QOpenGLContext::currentContext()->isOpenGLES() ? "yes" : "no");
openGLVersion = (QOpenGLContext::currentContext()->format()).majorVersion()
+ ((QOpenGLContext::currentContext()->format()).minorVersion() / 10.0);
majorVersion = (QOpenGLContext::currentContext()->format()).majorVersion();
minorVersion = (QOpenGLContext::currentContext()->format()).minorVersion();
}
else {
qDebug() << "GLSpectrum::initializeGL: current context is invalid";
@ -816,16 +817,16 @@ void GLSpectrum::initializeGL()
glFunctions->initializeOpenGLFunctions();
//glDisable(GL_DEPTH_TEST);
m_glShaderSimple.initializeGL(openGLVersion);
m_glShaderLeftScale.initializeGL(openGLVersion);
m_glShaderFrequencyScale.initializeGL(openGLVersion);
m_glShaderWaterfall.initializeGL(openGLVersion);
m_glShaderHistogram.initializeGL(openGLVersion);
m_glShaderTextOverlay.initializeGL(openGLVersion);
m_glShaderInfo.initializeGL(openGLVersion);
m_glShaderSpectrogram.initializeGL(openGLVersion);
m_glShaderSpectrogramTimeScale.initializeGL(openGLVersion);
m_glShaderSpectrogramPowerScale.initializeGL(openGLVersion);
m_glShaderSimple.initializeGL(majorVersion, minorVersion);
m_glShaderLeftScale.initializeGL(majorVersion, minorVersion);
m_glShaderFrequencyScale.initializeGL(majorVersion, minorVersion);
m_glShaderWaterfall.initializeGL(majorVersion, minorVersion);
m_glShaderHistogram.initializeGL(majorVersion, minorVersion);
m_glShaderTextOverlay.initializeGL(majorVersion, minorVersion);
m_glShaderInfo.initializeGL(majorVersion, minorVersion);
m_glShaderSpectrogram.initializeGL(majorVersion, minorVersion);
m_glShaderSpectrogramTimeScale.initializeGL(majorVersion, minorVersion);
m_glShaderSpectrogramPowerScale.initializeGL(majorVersion, minorVersion);
}
void GLSpectrum::openGLDebug(const QOpenGLDebugMessage &debugMessage)