-
-
Notifications
You must be signed in to change notification settings - Fork 1.7k
Replace use of QGLWidget with QOpenGLWidget #1863
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
This file was deleted.
This file was deleted.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -4,9 +4,10 @@ | |
| #include <QWidget> | ||
| #include <QtDebug> | ||
| #include <QGLFormat> | ||
| #include <QGLShaderProgram> | ||
| #include <QOpenGLShaderProgram> | ||
| #include <QGuiApplication> | ||
| #include <QWindow> | ||
| #include <QOpenGLContext> | ||
|
|
||
| #include "waveform/waveformwidgetfactory.h" | ||
|
|
||
|
|
@@ -170,12 +171,12 @@ WaveformWidgetFactory::WaveformWidgetFactory() : | |
|
|
||
| m_openGLAvailable = true; | ||
|
|
||
| QGLWidget* glWidget = new QGLWidget(); // create paint device | ||
| QOpenGLWidget* glWidget = new QOpenGLWidget(); // create paint device | ||
| // QGLShaderProgram::hasOpenGLShaderPrograms(); valgind error | ||
| // Without a makeCurrent, hasOpenGLShaderPrograms returns false on Qt 5. | ||
| glWidget->context()->makeCurrent(); | ||
| glWidget->makeCurrent(); | ||
| m_openGLShaderAvailable = | ||
| QGLShaderProgram::hasOpenGLShaderPrograms(glWidget->context()); | ||
| QOpenGLShaderProgram::hasOpenGLShaderPrograms(glWidget->context()); | ||
| delete glWidget; | ||
| } | ||
|
|
||
|
|
@@ -565,7 +566,7 @@ void WaveformWidgetFactory::swap() { | |
| for (int i = 0; i < m_waveformWidgetHolders.size(); i++) { | ||
| WaveformWidgetAbstract* pWaveformWidget = m_waveformWidgetHolders[i].m_waveformWidget; | ||
| if (pWaveformWidget->getWidth() > 0) { | ||
| QGLWidget* glw = dynamic_cast<QGLWidget*>(pWaveformWidget->getWidget()); | ||
| QOpenGLWidget* glw = dynamic_cast<QOpenGLWidget*>(pWaveformWidget->getWidget()); | ||
| // Don't swap invalid / invisible widgets or widgets with an | ||
| // unexposed window. Prevents continuous log spew of | ||
| // "QOpenGLContext::swapBuffers() called with non-exposed | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Replacing |
||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,5 @@ | ||
| #include "glrgbwaveformwidget.h" | ||
|
|
||
| #include "waveform/sharedglcontext.h" | ||
| #include "waveform/renderers/waveformwidgetrenderer.h" | ||
| #include "waveform/renderers/waveformrenderbackground.h" | ||
| #include "waveform/renderers/glwaveformrendererrgb.h" | ||
|
|
@@ -12,8 +11,10 @@ | |
|
|
||
| #include "util/performancetimer.h" | ||
|
|
||
| #include <QOpenGLContext> | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We conventionally put Qt includes above Mixxx includes. |
||
|
|
||
| GLRGBWaveformWidget::GLRGBWaveformWidget(const char* group, QWidget* parent) | ||
| : QGLWidget(parent, SharedGLContext::getWidget()), | ||
| : QOpenGLWidget(parent), | ||
| WaveformWidgetAbstract(group) { | ||
|
|
||
| addRenderer<WaveformRenderBackground>(); | ||
|
|
@@ -27,12 +28,7 @@ GLRGBWaveformWidget::GLRGBWaveformWidget(const char* group, QWidget* parent) | |
| setAttribute(Qt::WA_NoSystemBackground); | ||
| setAttribute(Qt::WA_OpaquePaintEvent); | ||
|
|
||
| setAutoBufferSwap(false); | ||
|
|
||
| qDebug() << "Created QGLWidget. Context" | ||
| << "Valid:" << context()->isValid() | ||
| << "Sharing:" << context()->isSharing(); | ||
| if (QGLContext::currentContext() != context()) { | ||
| if (QOpenGLContext::currentContext() != context()) { | ||
| makeCurrent(); | ||
| } | ||
| m_initSuccess = init(); | ||
|
|
@@ -43,7 +39,7 @@ GLRGBWaveformWidget::~GLRGBWaveformWidget() { | |
| } | ||
|
|
||
| void GLRGBWaveformWidget::castToQWidget() { | ||
| m_widget = static_cast<QWidget*>(static_cast<QGLWidget*>(this)); | ||
| m_widget = static_cast<QWidget*>(static_cast<QOpenGLWidget*>(this)); | ||
| } | ||
|
|
||
| void GLRGBWaveformWidget::paintEvent(QPaintEvent* event) { | ||
|
|
@@ -55,7 +51,7 @@ mixxx::Duration GLRGBWaveformWidget::render() { | |
| mixxx::Duration t1; | ||
| //mixxx::Duration t2, t3; | ||
| timer.start(); | ||
| // QPainter makes QGLContext::currentContext() == context() | ||
| // QPainter makes QOpenGLContext::currentContext() == context() | ||
| // this may delayed until previous buffer swap finished | ||
| QPainter painter(this); | ||
| t1 = timer.restart(); | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.