1
0
mirror of https://github.com/f4exb/sdrangel.git synced 2024-09-28 15:56:33 -04:00

OpenGL modernization: various fixes

This commit is contained in:
f4exb 2016-03-06 09:33:10 +01:00
parent f002d8daa6
commit ca49e2d990
4 changed files with 38 additions and 6 deletions

View File

@ -200,6 +200,7 @@ private:
void drawPowerOverlay();
protected slots:
void cleanup();
void tick();
};

View File

@ -209,9 +209,8 @@ private:
void enterEvent(QEvent* event);
void leaveEvent(QEvent* event);
void cleanup();
private slots:
void cleanup();
void tick();
void channelMarkerChanged();
void channelMarkerDestroyed(QObject* object);

View File

@ -19,16 +19,13 @@
#include <QPainter>
#include <QMouseEvent>
#include <QOpenGLContext>
#include "gui/glscope.h"
#include "dsp/dspengine.h"
#include <algorithm>
#include <QDebug>
#ifdef GL_ANDROID
#include "util/gleshelp.h"
#endif
/*
#ifdef _WIN32
static double log2f(double n)
@ -237,6 +234,25 @@ void GLScope::newTrace(const std::vector<Complex>& trace, int sampleRate)
void GLScope::initializeGL()
{
QOpenGLContext *glCurrentContext = QOpenGLContext::currentContext();
if (glCurrentContext) {
if (QOpenGLContext::currentContext()->isValid()) {
qDebug() << "GLScope::initializeGL: context:"
<< " major: " << (QOpenGLContext::currentContext()->format()).majorVersion()
<< " minor: " << (QOpenGLContext::currentContext()->format()).minorVersion()
<< " ES: " << (QOpenGLContext::currentContext()->isOpenGLES() ? "yes" : "no");
}
else {
qDebug() << "GLScope::initializeGL: current context is invalid";
}
} else {
qCritical() << "GLScope::initializeGL: no current context";
return;
}
connect(glCurrentContext, &QOpenGLContext::aboutToBeDestroyed, this, &GLScope::cleanup); // TODO: when migrating to QOpenGLWidget
glDisable(GL_DEPTH_TEST);
m_glShaderSimple.initializeGL();
m_glShaderLeft1Scale.initializeGL();
@ -2797,3 +2813,15 @@ void GLScope::connectTimer(const QTimer& timer)
connect(&timer, SIGNAL(timeout()), this, SLOT(tick()));
m_timer.stop();
}
void GLScope::cleanup()
{
makeCurrent();
m_glShaderSimple.cleanup();
m_glShaderBottom1Scale.cleanup();
m_glShaderBottom2Scale.cleanup();
m_glShaderLeft1Scale.cleanup();
m_glShaderPowerOverlay.cleanup();
doneCurrent();
}

View File

@ -2274,5 +2274,9 @@ void GLSpectrum::cleanup()
{
makeCurrent();
m_glShaderSimple.cleanup();
m_glShaderFrequencyScale.cleanup();
m_glShaderHistogram.cleanup();
m_glShaderLeftScale.cleanup();
m_glShaderWaterfall.cleanup();
doneCurrent();
}