summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorPaul Olav Tvete <paul.tvete@qt.io>2019-01-08 14:01:52 +0100
committerPaul Olav Tvete <paul.tvete@qt.io>2019-01-09 13:52:15 +0000
commit1e29215b2e40a38b9324a719888749e12a74e99c (patch)
treedace46839b2f1b465d6131a4c7766db58ae0823e
parent024be9dcae26a0d88ffb76f9fca252f2135ad7c9 (diff)
C++ examples: Delay compositor initialization until GL is ready
When running with xcb_egl, the platform plugin's native interface is not always ready immediately after the QGuiApplication constructor is done. Calling QWaylandCompositor::create() at the time of initializeGL() makes sure that everything is ready. Change-Id: I9e5e434ff85b92a45caddfd393439a4ffe3bcdc6 Reviewed-by: Johan Helsing <johan.helsing@qt.io>
-rw-r--r--examples/wayland/minimal-cpp/compositor.cpp1
-rw-r--r--examples/wayland/minimal-cpp/main.cpp1
-rw-r--r--examples/wayland/minimal-cpp/window.cpp1
-rw-r--r--examples/wayland/minimal-cpp/window.h4
-rw-r--r--examples/wayland/qwindow-compositor/main.cpp1
-rw-r--r--examples/wayland/qwindow-compositor/window.cpp1
6 files changed, 7 insertions, 2 deletions
diff --git a/examples/wayland/minimal-cpp/compositor.cpp b/examples/wayland/minimal-cpp/compositor.cpp
index 81b1be26..fa9ae2da 100644
--- a/examples/wayland/minimal-cpp/compositor.cpp
+++ b/examples/wayland/minimal-cpp/compositor.cpp
@@ -88,6 +88,7 @@ Compositor::Compositor(Window *window)
: m_window(window)
{
window->setCompositor(this);
+ connect(window, &Window::glReady, this, [this] { create(); });
}
Compositor::~Compositor()
diff --git a/examples/wayland/minimal-cpp/main.cpp b/examples/wayland/minimal-cpp/main.cpp
index 0b0b4b9d..226e8923 100644
--- a/examples/wayland/minimal-cpp/main.cpp
+++ b/examples/wayland/minimal-cpp/main.cpp
@@ -59,7 +59,6 @@ int main(int argc, char *argv[])
Window window;
window.resize(800,600);
Compositor compositor(&window);
- compositor.create();
window.show();
return app.exec();
diff --git a/examples/wayland/minimal-cpp/window.cpp b/examples/wayland/minimal-cpp/window.cpp
index 673e15fd..4dd7c149 100644
--- a/examples/wayland/minimal-cpp/window.cpp
+++ b/examples/wayland/minimal-cpp/window.cpp
@@ -68,6 +68,7 @@ void Window::setCompositor(Compositor *comp) {
void Window::initializeGL()
{
m_textureBlitter.create();
+ emit glReady();
}
void Window::paintGL()
diff --git a/examples/wayland/minimal-cpp/window.h b/examples/wayland/minimal-cpp/window.h
index 1a106da9..7711e0bd 100644
--- a/examples/wayland/minimal-cpp/window.h
+++ b/examples/wayland/minimal-cpp/window.h
@@ -60,10 +60,14 @@ class Compositor;
class Window : public QOpenGLWindow
{
+ Q_OBJECT
public:
Window();
void setCompositor(Compositor *comp);
+signals:
+ void glReady();
+
protected:
void initializeGL() override;
void paintGL() override;
diff --git a/examples/wayland/qwindow-compositor/main.cpp b/examples/wayland/qwindow-compositor/main.cpp
index f2b00e88..9d8c1f78 100644
--- a/examples/wayland/qwindow-compositor/main.cpp
+++ b/examples/wayland/qwindow-compositor/main.cpp
@@ -59,7 +59,6 @@ int main(int argc, char *argv[])
Window window;
Compositor compositor(&window);
window.setCompositor(&compositor);
- compositor.create();
window.resize(800,600);
window.show();
diff --git a/examples/wayland/qwindow-compositor/window.cpp b/examples/wayland/qwindow-compositor/window.cpp
index 80aeec4c..c8e5604b 100644
--- a/examples/wayland/qwindow-compositor/window.cpp
+++ b/examples/wayland/qwindow-compositor/window.cpp
@@ -78,6 +78,7 @@ void Window::initializeGL()
m_backgroundTexture->setMinificationFilter(QOpenGLTexture::Nearest);
m_backgroundImageSize = backgroundImage.size();
m_textureBlitter.create();
+ m_compositor->create(); // the compositor's hardware integration may depend on GL
}
void Window::drawBackground()