mirror of
https://github.com/f4exb/sdrangel.git
synced 2025-05-24 03:02:29 -04:00
OpenGL modernization: GLScope: enhance openGL context checking and debugging at initializeGL time
This commit is contained in:
parent
264022d2ca
commit
92a588b060
@ -19,6 +19,7 @@
|
|||||||
#define INCLUDE_GUI_GLSHADERSIMPLE_H_
|
#define INCLUDE_GUI_GLSHADERSIMPLE_H_
|
||||||
|
|
||||||
#include <QString>
|
#include <QString>
|
||||||
|
#include <QOpenGLFunctions>
|
||||||
|
|
||||||
class QOpenGLShaderProgram;
|
class QOpenGLShaderProgram;
|
||||||
class QMatrix4x4;
|
class QMatrix4x4;
|
||||||
|
@ -21,6 +21,7 @@
|
|||||||
#include <QMouseEvent>
|
#include <QMouseEvent>
|
||||||
#include <QOpenGLContext>
|
#include <QOpenGLContext>
|
||||||
#include <QOpenGLFunctions>
|
#include <QOpenGLFunctions>
|
||||||
|
#include <QSurface>
|
||||||
#include "gui/glscope.h"
|
#include "gui/glscope.h"
|
||||||
#include "dsp/dspengine.h"
|
#include "dsp/dspengine.h"
|
||||||
|
|
||||||
@ -239,6 +240,7 @@ void GLScope::newTrace(const std::vector<Complex>& trace, int sampleRate)
|
|||||||
void GLScope::initializeGL()
|
void GLScope::initializeGL()
|
||||||
{
|
{
|
||||||
QOpenGLContext *glCurrentContext = QOpenGLContext::currentContext();
|
QOpenGLContext *glCurrentContext = QOpenGLContext::currentContext();
|
||||||
|
//QOpenGLContext *glCurrentContext = context();
|
||||||
|
|
||||||
if (glCurrentContext) {
|
if (glCurrentContext) {
|
||||||
if (QOpenGLContext::currentContext()->isValid()) {
|
if (QOpenGLContext::currentContext()->isValid()) {
|
||||||
@ -255,6 +257,28 @@ void GLScope::initializeGL()
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
QSurface *surface = glCurrentContext->surface();
|
||||||
|
|
||||||
|
if (surface == 0)
|
||||||
|
{
|
||||||
|
qCritical() << "GLScope::initializeGL: no surface attached";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
if (surface->surfaceType() != QSurface::OpenGLSurface)
|
||||||
|
{
|
||||||
|
qCritical() << "GLScope::initializeGL: surface is not an OpenGLSurface: " << surface->surfaceType()
|
||||||
|
<< " cannot use an OpenGL context";
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
qDebug() << "GLScope::initializeGL: OpenGL surface:"
|
||||||
|
<< " class: " << (surface->surfaceClass() == QSurface::Window ? "Window" : "Offscreen");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
connect(glCurrentContext, &QOpenGLContext::aboutToBeDestroyed, this, &GLScope::cleanup); // TODO: when migrating to QOpenGLWidget
|
connect(glCurrentContext, &QOpenGLContext::aboutToBeDestroyed, this, &GLScope::cleanup); // TODO: when migrating to QOpenGLWidget
|
||||||
|
|
||||||
QOpenGLFunctions *glFunctions = QOpenGLContext::currentContext()->functions();
|
QOpenGLFunctions *glFunctions = QOpenGLContext::currentContext()->functions();
|
||||||
@ -2825,12 +2849,12 @@ void GLScope::connectTimer(const QTimer& timer)
|
|||||||
|
|
||||||
void GLScope::cleanup()
|
void GLScope::cleanup()
|
||||||
{
|
{
|
||||||
makeCurrent();
|
//makeCurrent();
|
||||||
m_glShaderSimple.cleanup();
|
m_glShaderSimple.cleanup();
|
||||||
m_glShaderBottom1Scale.cleanup();
|
m_glShaderBottom1Scale.cleanup();
|
||||||
m_glShaderBottom2Scale.cleanup();
|
m_glShaderBottom2Scale.cleanup();
|
||||||
m_glShaderLeft1Scale.cleanup();
|
m_glShaderLeft1Scale.cleanup();
|
||||||
m_glShaderPowerOverlay.cleanup();
|
m_glShaderPowerOverlay.cleanup();
|
||||||
doneCurrent();
|
//doneCurrent();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user