summaryrefslogtreecommitdiff
path: root/hw/vigs/vigs_qt5.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'hw/vigs/vigs_qt5.cpp')
-rw-r--r--hw/vigs/vigs_qt5.cpp96
1 files changed, 72 insertions, 24 deletions
diff --git a/hw/vigs/vigs_qt5.cpp b/hw/vigs/vigs_qt5.cpp
index 286014eff7..927d558320 100644
--- a/hw/vigs/vigs_qt5.cpp
+++ b/hw/vigs/vigs_qt5.cpp
@@ -27,26 +27,27 @@
*
*/
-#include <stdio.h>
+#include "vigs_qt5.h"
+#include "config-host.h"
#include <QGuiApplication>
#include <QOpenGLContext>
#include <qpa/qplatformnativeinterface.h>
-#include "config-host.h"
-#include "vigs_qt5.h"
+#include <stdio.h>
extern bool qt5IsOnscreen;
extern QApplication *qt5App;
extern QOpenGLContext *qt5GLContext;
+extern QSurfaceFormat qt5GLFormat;
extern void qt5_register_capture_request_listener(void *listener,
void (*handler)(void *));
extern void qt5_unregister_capture_request_listener(void *listener);
extern void qt5_process_captured(bool captured, void *pixels,
int width, int height);
-extern void qt5_update_texture(unsigned int tex_id);
bool vigs_qt5_onscreen_enabled(void)
{
+ // TODO: on Darwin?
if (qt5App != NULL && qt5IsOnscreen) {
return true;
}
@@ -66,7 +67,7 @@ void *vigs_qt5_display(void)
QGuiApplication::primaryScreen());
}
-void *vigs_qt5_gl_context_get(void)
+void *vigs_qt5_gl_context_create(bool is_gl2)
{
if (!qt5App) {
fprintf(stderr, "QT5 not enabled!\n");
@@ -74,27 +75,79 @@ void *vigs_qt5_gl_context_get(void)
}
if (qt5GLContext) {
- QPlatformNativeInterface *native =
- QGuiApplication::platformNativeInterface();
+ fprintf(stderr, "QT5 GL context already created!\n");
+ return NULL;
+ }
+
+ qt5GLContext = new QOpenGLContext();
+
+ QSurfaceFormat format;
+
+ format.setRedBufferSize(8);
+ format.setGreenBufferSize(8);
+ format.setBlueBufferSize(8);
+ format.setAlphaBufferSize(8);
+ format.setDepthBufferSize(24);
+ format.setStencilBufferSize(8);
+
+ if (!is_gl2) {
+ format.setMajorVersion(3);
+#ifdef CONFIG_DARWIN
+ format.setMinorVersion(2);
+ format.setProfile(QSurfaceFormat::CoreProfile);
+#else
+ format.setMinorVersion(1);
+#endif
+ }
+
+ qt5GLContext->setScreen(QGuiApplication::primaryScreen());
+ qt5GLContext->setFormat(format);
+
+ if (!qt5GLContext->create()) {
+ fprintf(stderr, "Cannot create QT5 GL context!\n");
+
+ delete qt5GLContext;
+ qt5GLContext = NULL;
+
+ return NULL;
+ }
+
+ if (!is_gl2) {
+ if ((qt5GLContext->format().majorVersion() < 3) ||
+ ((qt5GLContext->format().majorVersion() == 3) &&
+ (qt5GLContext->format().minorVersion() < 1))) {
+ fprintf(stderr, "Cannot create QT5 3.1 GL context!\n");
+
+ delete qt5GLContext;
+ qt5GLContext = NULL;
+
+ return NULL;
+ }
+ }
+
+ QPlatformNativeInterface *native =
+ QGuiApplication::platformNativeInterface();
- void *ret = NULL;
+ void *ret = NULL;
#if defined(CONFIG_LINUX)
- ret = native->nativeResourceForContext(QByteArray("glxcontext"),
- qt5GLContext);
+ ret = native->nativeResourceForContext(QByteArray("glxcontext"), qt5GLContext);
#elif defined(CONFIG_WIN32)
- ret = native->nativeResourceForContext(QByteArray("renderingContext"),
- qt5GLContext);
+ ret = native->nativeResourceForContext(QByteArray("renderingContext"), qt5GLContext);
#elif defined(CONFIG_DARWIN)
- ret = native->nativeResourceForContext(QByteArray("cglContextObj"),
- qt5GLContext);
+ ret = native->nativeResourceForContext(QByteArray("cglContextObj"), qt5GLContext);
#endif
- if (!ret) {
- fprintf(stderr, "Cannot get native QT5 GL context!\n");
- }
- return ret;
+
+ if (!ret) {
+ fprintf(stderr, "Cannot get native QT5 GL context!\n");
+
+ delete qt5GLContext;
+ qt5GLContext = NULL;
}
- return NULL;
+
+ qt5GLFormat = format;
+
+ return ret;
}
void vigs_qt5_register_capture_request_listener(void *listener,
@@ -113,8 +166,3 @@ void vigs_qt5_process_captured(bool captured, void *pixels,
{
qt5_process_captured(captured, pixels, width, height);
}
-
-void vigs_qt5_dpy_render_texture(uint32_t tex_id)
-{
- qt5_update_texture(tex_id);
-}