CXX=g++
-CXXFLAGS := -O2 -march=native -g -std=gnu++11 -Wall -Wno-deprecated-declarations -fPIC $(shell pkg-config --cflags Qt5Core Qt5Gui Qt5Widgets Qt5OpenGLExtensions libusb-1.0 movit) -pthread -DMOVIT_SHADER_DIR=\"$(shell pkg-config --variable=shaderdir movit)\"
-LDFLAGS=$(shell pkg-config --libs Qt5Core Qt5Gui Qt5Widgets Qt5OpenGLExtensions libusb-1.0 movit) -lEGL -lGL -pthread -lva -lva-drm -lva-x11 -lX11 -lavformat -lavcodec -lavutil
+CXXFLAGS := -O2 -march=native -g -std=gnu++11 -Wall -Wno-deprecated-declarations -fPIC $(shell pkg-config --cflags Qt5Core Qt5Gui Qt5Widgets Qt5OpenGLExtensions Qt5OpenGL libusb-1.0 movit) -pthread -DMOVIT_SHADER_DIR=\"$(shell pkg-config --variable=shaderdir movit)\"
+LDFLAGS=$(shell pkg-config --libs Qt5Core Qt5Gui Qt5Widgets Qt5OpenGLExtensions Qt5OpenGL libusb-1.0 movit) -lEGL -lGL -pthread -lva -lva-drm -lva-x11 -lX11 -lavformat -lavcodec -lavutil
# Qt objects
OBJS=glwidget.o main.o mainwindow.o window.o
#include <QOpenGLContext>
#include <QOffscreenSurface>
#include <QWindow>
+#include <QGLWidget>
+
+QGLWidget *global_share_widget = nullptr;
QSurface *create_surface(const QSurfaceFormat &format)
{
QOpenGLContext *create_context()
{
QOpenGLContext *context = new QOpenGLContext;
- context->setShareContext(QOpenGLContext::globalShareContext());
+ context->setShareContext(global_share_widget->context()->contextHandle());
context->create();
return context;
}
class QSurface;
class QOpenGLContext;
class QSurfaceFormat;
+class QGLWidget;
+extern QGLWidget *global_share_widget;
QSurface *create_surface(const QSurfaceFormat &format);
QOpenGLContext *create_context();
bool make_current(QOpenGLContext *context, QSurface *surface);
#include <movit/util.h>
GLWidget::GLWidget(QWidget *parent)
- : QOpenGLWidget(parent),
+ : QGLWidget(parent, global_share_widget),
resource_pool(new movit::ResourcePool)
{
}
QMetaObject::invokeMethod(t, "update", Qt::AutoConnection);
});
- QSurface *surface = create_surface(format());
- QSurface *surface2 = create_surface(format());
- QSurface *surface3 = create_surface(format());
- QSurface *surface4 = create_surface(format());
+ QSurfaceFormat fmt = QGLFormat::toSurfaceFormat(format());
+ QSurface *surface = create_surface(fmt);
+ QSurface *surface2 = create_surface(fmt);
+ QSurface *surface3 = create_surface(fmt);
+ QSurface *surface4 = create_surface(fmt);
start_mixer(surface, surface2, surface3, surface4);
// Prepare the shaders to actually get the texture shown (ick).
#endif
}
+void GLWidget::resizeGL(int width, int height)
+{
+ glViewport(0, 0, width, height);
+}
+
void GLWidget::paintGL()
{
DisplayFrame frame;
#ifndef GLWIDGET_H
#define GLWIDGET_H
-#include <QOpenGLWidget>
+#include <QGLWidget>
namespace movit {
class ResourcePool;
}
-class GLWidget : public QOpenGLWidget
+// Note: We use the older QGLWidget instead of QOpenGLWidget as it is
+// much faster (does not go through a separate offscreen rendering step).
+//
+// TODO: Consider if QOpenGLWindow could do what we want.
+class GLWidget : public QGLWidget
{
Q_OBJECT
protected:
void initializeGL() override;
+ void resizeGL(int width, int height) override;
void paintGL() override;
private:
#include <QDesktopWidget>
#include <QSurfaceFormat>
#include <QtGui/QOpenGLContext>
+#include <QGLFormat>
#include "mainwindow.h"
#include "mixer.h"
+#include "context.h"
int main(int argc, char *argv[])
{
fmt.setMinorVersion(1);
QSurfaceFormat::setDefaultFormat(fmt);
+ QGLFormat::setDefaultFormat(QGLFormat::fromSurfaceFormat(fmt));
+
+ global_share_widget = new QGLWidget();
+
MainWindow mainWindow;
mainWindow.resize(QSize(1280, 720));
mainWindow.show();
<number>0</number>
</property>
<item>
- <widget class="QOpenGLWidget" name="me_preview">
+ <widget class="QGLWidget" name="me_preview">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>1</horstretch>
<number>0</number>
</property>
<item>
- <widget class="QOpenGLWidget" name="preview2">
+ <widget class="QGLWidget" name="preview2">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>1</horstretch>
</widget>
</item>
<item>
- <widget class="QOpenGLWidget" name="preview1">
+ <widget class="QGLWidget" name="preview1">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>1</horstretch>
</widget>
</item>
<item>
- <widget class="QOpenGLWidget" name="preview3">
+ <widget class="QGLWidget" name="preview3">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>1</horstretch>
</widget>
</item>
<item>
- <widget class="QOpenGLWidget" name="preview4">
+ <widget class="QGLWidget" name="preview4">
<property name="sizePolicy">
<sizepolicy hsizetype="Expanding" vsizetype="Expanding">
<horstretch>1</horstretch>
<customwidgets>
<customwidget>
<class>GLWidget</class>
- <extends>QOpenGLWidget</extends>
+ <extends>QGLWidget</extends>
<header>glwidget.h</header>
</customwidget>
</customwidgets>