Skip to content

Commit

Permalink
dynamic load gl functions, removed workaround with scons OpenGLES fea…
Browse files Browse the repository at this point in the history
…ture
  • Loading branch information
daschuer committed May 7, 2019
1 parent 452f64d commit b7ce277
Show file tree
Hide file tree
Showing 22 changed files with 108 additions and 130 deletions.
7 changes: 2 additions & 5 deletions SConstruct
Original file line number Diff line number Diff line change
Expand Up @@ -56,15 +56,12 @@ available_features = [features.Mad,
features.LocaleCompare,
features.Lilv,
features.Battery,
features.QtKeychain,

# "Features" of dubious quality
features.PerfTools,
features.AsmLib,
features.FFMPEG,

# Experimental features
features.OpenGLES,
features.QtKeychain
features.FFMPEG
]

build = mixxx.MixxxBuild(target, machine, build_type,
Expand Down
20 changes: 0 additions & 20 deletions build/features.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,26 +6,6 @@
import SCons.Script as SCons
from . import depends

class OpenGLES(Feature):
def description(self):
return "OpenGL-ES >= 2.0 support [Experimental]"

def enabled(self, build):
build.flags['opengles'] = util.get_flags(build.env, 'opengles', 0)
return int(build.flags['opengles'])

def add_options(self, build, vars):
vars.Add('opengles', 'Set to 1 to enable OpenGL-ES >= 2.0 support [Experimental]', 0)

def configure(self, build, conf):
if not self.enabled(build):
return
if build.flags['opengles']:
build.env.Append(CPPDEFINES='__OPENGLES__')

def sources(self, build):
return []

class HSS1394(Feature):
def description(self):
return "HSS1394 MIDI device support"
Expand Down
8 changes: 1 addition & 7 deletions src/waveform/renderers/glslwaveformrenderersignal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ GLSLWaveformRendererSignal::GLSLWaveformRendererSignal(WaveformWidgetRenderer* w
m_bDumpPng(false),
m_shadersValid(false),
m_rgbShader(rgbShader) {
initializeOpenGLFunctions();
}

GLSLWaveformRendererSignal::~GLSLWaveformRendererSignal() {
Expand Down Expand Up @@ -138,8 +139,6 @@ void GLSLWaveformRendererSignal::createGeometry() {
return;
}

#ifndef __OPENGLES__

glMatrixMode(GL_PROJECTION);
glLoadIdentity();
glOrtho(-1.0, 1.0, -1.0, 1.0, -10.0, 10.0);
Expand Down Expand Up @@ -167,7 +166,6 @@ void GLSLWaveformRendererSignal::createGeometry() {
}
glEndList();

#endif
}

void GLSLWaveformRendererSignal::createFrameBuffers() {
Expand Down Expand Up @@ -290,8 +288,6 @@ void GLSLWaveformRendererSignal::draw(QPainter* painter, QPaintEvent* /*event*/)

//qDebug() << "GAIN" << allGain << lowGain << midGain << highGain;

#ifndef __OPENGLES__

//paint into frame buffer
{
glMatrixMode(GL_PROJECTION);
Expand Down Expand Up @@ -446,7 +442,5 @@ void GLSLWaveformRendererSignal::draw(QPainter* painter, QPaintEvent* /*event*/)
glMatrixMode(GL_PROJECTION);
glPopMatrix();

#endif

painter->endNativePainting();
}
17 changes: 11 additions & 6 deletions src/waveform/renderers/glslwaveformrenderersignal.h
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,15 @@
#include <QGLFramebufferObject>
#include <QGLShaderProgram>
#include <QtOpenGL>
#include <QOpenGLFunctions_2_1>

#include "track/track.h"
#include "util/memory.h"
#include "waveform/renderers/waveformrenderersignalbase.h"

class GLSLWaveformRendererSignal : public QObject, public WaveformRendererSignalBase {
class GLSLWaveformRendererSignal: public QObject,
public WaveformRendererSignalBase,
protected QOpenGLFunctions_2_1 {
Q_OBJECT
public:
GLSLWaveformRendererSignal(WaveformWidgetRenderer* waveformWidgetRenderer,
Expand Down Expand Up @@ -51,12 +54,14 @@ class GLSLWaveformRendererSignal : public QObject, public WaveformRendererSignal
std::unique_ptr<QGLShaderProgram> m_frameShaderProgram;
};

class GLSLWaveformRendererFilteredSignal : public GLSLWaveformRendererSignal {
public:
class GLSLWaveformRendererFilteredSignal: public GLSLWaveformRendererSignal {
public:
GLSLWaveformRendererFilteredSignal(
WaveformWidgetRenderer* waveformWidgetRenderer)
: GLSLWaveformRendererSignal(waveformWidgetRenderer, false) {}
~GLSLWaveformRendererFilteredSignal() override {}
WaveformWidgetRenderer* waveformWidgetRenderer) :
GLSLWaveformRendererSignal(waveformWidgetRenderer, false) {
}
~GLSLWaveformRendererFilteredSignal() override {
}
};

class GLSLWaveformRendererRGBSignal : public GLSLWaveformRendererSignal {
Expand Down
7 changes: 1 addition & 6 deletions src/waveform/renderers/glvsynctestrenderer.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <qgl.h>

#include "waveform/renderers/glvsynctestrenderer.h"

#include "waveform/renderers/waveformwidgetrenderer.h"
Expand All @@ -11,6 +9,7 @@ GLVSyncTestRenderer::GLVSyncTestRenderer(
WaveformWidgetRenderer* waveformWidgetRenderer)
: WaveformRendererSignalBase(waveformWidgetRenderer),
m_drawcount(0) {
initializeOpenGLFunctions();
}

GLVSyncTestRenderer::~GLVSyncTestRenderer() {
Expand Down Expand Up @@ -72,8 +71,6 @@ void GLVSyncTestRenderer::draw(QPainter* painter, QPaintEvent* /*event*/) {
glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

#ifndef __OPENGLES__

//t7 = timer.restart(); // 5,770 ns

glMatrixMode(GL_PROJECTION);
Expand Down Expand Up @@ -119,8 +116,6 @@ void GLVSyncTestRenderer::draw(QPainter* painter, QPaintEvent* /*event*/) {
glMatrixMode(GL_PROJECTION);
glPopMatrix();

#endif

//t12 = timer.restart(); // 22,426 ns
painter->endNativePainting();

Expand Down
12 changes: 8 additions & 4 deletions src/waveform/renderers/glvsynctestrenderer.h
Original file line number Diff line number Diff line change
@@ -1,18 +1,22 @@
#ifndef GLVSYNCTESTRENDERER_H
#define GLVSYNCTESTRENDERER_H

#include <QOpenGLFunctions_2_1>

#include "waveformrenderersignalbase.h"

class ControlObject;

class GLVSyncTestRenderer : public WaveformRendererSignalBase {
public:
explicit GLVSyncTestRenderer(WaveformWidgetRenderer* waveformWidgetRenderer);
class GLVSyncTestRenderer: public WaveformRendererSignalBase,
protected QOpenGLFunctions_2_1 {
public:
explicit GLVSyncTestRenderer(
WaveformWidgetRenderer* waveformWidgetRenderer);
virtual ~GLVSyncTestRenderer();

virtual void onSetup(const QDomNode &node);
virtual void draw(QPainter* painter, QPaintEvent* event);
private:
private:
int m_drawcount;
};

Expand Down
10 changes: 2 additions & 8 deletions src/waveform/renderers/glwaveformrendererfilteredsignal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,12 +7,10 @@

#include <QDomNode>

#include <qgl.h>

GLWaveformRendererFilteredSignal::GLWaveformRendererFilteredSignal(
WaveformWidgetRenderer* waveformWidgetRenderer)
: WaveformRendererSignalBase(waveformWidgetRenderer) {

: WaveformRendererSignalBase(waveformWidgetRenderer) {
initializeOpenGLFunctions();
}

GLWaveformRendererFilteredSignal::~GLWaveformRendererFilteredSignal() {
Expand Down Expand Up @@ -65,8 +63,6 @@ void GLWaveformRendererFilteredSignal::draw(QPainter* painter, QPaintEvent* /*ev
float allGain(1.0), lowGain(1.0), midGain(1.0), highGain(1.0);
getGains(&allGain, &lowGain, &midGain, &highGain);

#ifndef __OPENGLES__

if (m_alignment == Qt::AlignCenter) {
glMatrixMode(GL_PROJECTION);
glPushMatrix();
Expand Down Expand Up @@ -225,7 +221,5 @@ void GLWaveformRendererFilteredSignal::draw(QPainter* painter, QPaintEvent* /*ev
glMatrixMode(GL_PROJECTION);
glPopMatrix();

#endif

painter->endNativePainting();
}
10 changes: 7 additions & 3 deletions src/waveform/renderers/glwaveformrendererfilteredsignal.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
#ifndef GLWAVEFROMRENDERERFILTEREDSIGNAL_H
#define GLWAVEFROMRENDERERFILTEREDSIGNAL_H

#include <QOpenGLFunctions_2_1>

#include "waveformrenderersignalbase.h"

class ControlObject;

class GLWaveformRendererFilteredSignal : public WaveformRendererSignalBase {
public:
explicit GLWaveformRendererFilteredSignal(WaveformWidgetRenderer* waveformWidgetRenderer);
class GLWaveformRendererFilteredSignal: public WaveformRendererSignalBase,
protected QOpenGLFunctions_2_1 {
public:
explicit GLWaveformRendererFilteredSignal(
WaveformWidgetRenderer* waveformWidgetRenderer);
virtual ~GLWaveformRendererFilteredSignal();

virtual void onSetup(const QDomNode &node);
Expand Down
10 changes: 2 additions & 8 deletions src/waveform/renderers/glwaveformrendererrgb.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
#include <qgl.h>

#include "glwaveformrendererrgb.h"
#include "waveformwidgetrenderer.h"
#include "waveform/waveform.h"
Expand All @@ -10,8 +8,8 @@

GLWaveformRendererRGB::GLWaveformRendererRGB(
WaveformWidgetRenderer* waveformWidgetRenderer)
: WaveformRendererSignalBase(waveformWidgetRenderer) {

: WaveformRendererSignalBase(waveformWidgetRenderer) {
initializeOpenGLFunctions();
}

GLWaveformRendererRGB::~GLWaveformRendererRGB() {
Expand Down Expand Up @@ -63,8 +61,6 @@ void GLWaveformRendererRGB::draw(QPainter* painter, QPaintEvent* /*event*/) {

const float kHeightScaleFactor = 255.0 / sqrtf(255 * 255 * 3);

#ifndef __OPENGLES__

if (m_alignment == Qt::AlignCenter) {
glMatrixMode(GL_PROJECTION);
glPushMatrix();
Expand Down Expand Up @@ -194,7 +190,5 @@ void GLWaveformRendererRGB::draw(QPainter* painter, QPaintEvent* /*event*/) {
glMatrixMode(GL_PROJECTION);
glPopMatrix();

#endif

painter->endNativePainting();
}
8 changes: 6 additions & 2 deletions src/waveform/renderers/glwaveformrendererrgb.h
Original file line number Diff line number Diff line change
@@ -1,13 +1,17 @@
#ifndef GLWAVEFORMRENDERERRGB_H
#define GLWAVEFORMRENDERERRGB_H

#include <QOpenGLFunctions_2_1>

#include "waveformrenderersignalbase.h"

class ControlObject;

class GLWaveformRendererRGB : public WaveformRendererSignalBase {
class GLWaveformRendererRGB: public WaveformRendererSignalBase,
protected QOpenGLFunctions_2_1 {
public:
explicit GLWaveformRendererRGB(WaveformWidgetRenderer* waveformWidgetRenderer);
explicit GLWaveformRendererRGB(
WaveformWidgetRenderer* waveformWidgetRenderer);
virtual ~GLWaveformRendererRGB();

virtual void onSetup(const QDomNode& node);
Expand Down
9 changes: 2 additions & 7 deletions src/waveform/renderers/glwaveformrenderersimplesignal.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -6,12 +6,11 @@
#include "waveform/waveformwidgetfactory.h"
#include "util/math.h"

#include <qgl.h>

GLWaveformRendererSimpleSignal::GLWaveformRendererSimpleSignal(
WaveformWidgetRenderer* waveformWidgetRenderer)
: WaveformRendererSignalBase(waveformWidgetRenderer) {

: WaveformRendererSignalBase(waveformWidgetRenderer) {
initializeOpenGLFunctions();
}

GLWaveformRendererSimpleSignal::~GLWaveformRendererSimpleSignal() {
Expand Down Expand Up @@ -60,8 +59,6 @@ void GLWaveformRendererSimpleSignal::draw(QPainter* painter, QPaintEvent* /*even
// Reset device for native painting
painter->beginNativePainting();

#ifndef __OPENGLES__

glEnable(GL_BLEND);
glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);

Expand Down Expand Up @@ -159,7 +156,5 @@ void GLWaveformRendererSimpleSignal::draw(QPainter* painter, QPaintEvent* /*even
glMatrixMode(GL_PROJECTION);
glPopMatrix();

#endif

painter->endNativePainting();
}
4 changes: 3 additions & 1 deletion src/waveform/renderers/glwaveformrenderersimplesignal.h
Original file line number Diff line number Diff line change
@@ -1,11 +1,13 @@
#ifndef GLWAVEFORMRENDERERSIMPLESIGNAL_H
#define GLWAVEFORMRENDERERSIMPLESIGNAL_H

#include <QOpenGLFunctions_2_1>

#include "waveformrenderersignalbase.h"

class ControlObject;

class GLWaveformRendererSimpleSignal : public WaveformRendererSignalBase {
class GLWaveformRendererSimpleSignal : public WaveformRendererSignalBase, protected QOpenGLFunctions_2_1 {
public:
explicit GLWaveformRendererSimpleSignal(WaveformWidgetRenderer* waveformWidgetRenderer);
virtual ~GLWaveformRendererSimpleSignal();
Expand Down
13 changes: 7 additions & 6 deletions src/waveform/widgets/glrgbwaveformwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ GLRGBWaveformWidget::GLRGBWaveformWidget(const char* group, QWidget* parent)
: QGLWidget(parent, SharedGLContext::getWidget()),
WaveformWidgetAbstract(group) {

qDebug() << "Created QGLWidget. Context"
<< "Valid:" << context()->isValid()
<< "Sharing:" << context()->isSharing();
if (QGLContext::currentContext() != context()) {
makeCurrent();
}

addRenderer<WaveformRenderBackground>();
addRenderer<WaveformRendererEndOfTrack>();
addRenderer<WaveformRendererPreroll>();
Expand All @@ -29,12 +36,6 @@ GLRGBWaveformWidget::GLRGBWaveformWidget(const char* group, QWidget* parent)

setAutoBufferSwap(false);

qDebug() << "Created QGLWidget. Context"
<< "Valid:" << context()->isValid()
<< "Sharing:" << context()->isSharing();
if (QGLContext::currentContext() != context()) {
makeCurrent();
}
m_initSuccess = init();
}

Expand Down
13 changes: 7 additions & 6 deletions src/waveform/widgets/glsimplewaveformwidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,13 @@
GLSimpleWaveformWidget::GLSimpleWaveformWidget(const char* group, QWidget* parent)
: QGLWidget(parent, SharedGLContext::getWidget()),
WaveformWidgetAbstract(group) {
qDebug() << "Created QGLWidget. Context"
<< "Valid:" << context()->isValid()
<< "Sharing:" << context()->isSharing();
if (QGLContext::currentContext() != context()) {
makeCurrent();
}

addRenderer<WaveformRenderBackground>();
addRenderer<WaveformRendererEndOfTrack>();
addRenderer<WaveformRendererPreroll>();
Expand All @@ -31,12 +38,6 @@ GLSimpleWaveformWidget::GLSimpleWaveformWidget(const char* group, QWidget* paren

setAutoBufferSwap(false);

qDebug() << "Created QGLWidget. Context"
<< "Valid:" << context()->isValid()
<< "Sharing:" << context()->isSharing();
if (QGLContext::currentContext() != context()) {
makeCurrent();
}
m_initSuccess = init();
}

Expand Down
Loading

0 comments on commit b7ce277

Please sign in to comment.