diff options
author | Gunnar Sletta <gunnar.sletta@nokia.com> | 2011-09-13 08:54:45 +0200 |
---|---|---|
committer | Gunnar Sletta <gunnar.sletta@nokia.com> | 2011-09-13 08:54:45 +0200 |
commit | b62bd0584a7872b6917917009b707785b3abd077 (patch) | |
tree | 9981f274712c098cabbff0c4667672a3934e5393 /examples/opengl/hellowindow/main.cpp | |
parent | 5e10745dca1d10025404a9f268f03ae697fb10cc (diff) | |
parent | 97baad65f65783d2b5ff938f6217aec9434f2e5f (diff) |
Merge branch 'refactor'
Conflicts:
mkspecs/qws/linux-lsb-g++/qmake.conf
src/gui/image/qpixmap_mac.cpp
src/gui/painting/qpaintengine_x11.cpp
src/gui/painting/qtessellator.cpp
src/gui/text/qfontengine_qws.cpp
src/gui/text/qfontengine_x11.cpp
src/gui/widgets/qlinecontrol.cpp
src/opengl/qgl.h
src/opengl/qgl_x11egl.cpp
src/plugins/plugins.pro
Change-Id: If52dcd55cd55f2983a756c2f843967702b60a310
Diffstat (limited to 'examples/opengl/hellowindow/main.cpp')
-rw-r--r-- | examples/opengl/hellowindow/main.cpp | 50 |
1 files changed, 50 insertions, 0 deletions
diff --git a/examples/opengl/hellowindow/main.cpp b/examples/opengl/hellowindow/main.cpp new file mode 100644 index 0000000000..b247807019 --- /dev/null +++ b/examples/opengl/hellowindow/main.cpp @@ -0,0 +1,50 @@ +#include <QGuiApplication> +#include <QScreen> +#include <QThread> + +#include "hellowindow.h" + +int main(int argc, char **argv) +{ + QGuiApplication app(argc, argv); + + QScreen *screen = QGuiApplication::primaryScreen(); + + QRect screenGeometry = screen->availableGeometry(); + + QSurfaceFormat format; + format.setDepthBufferSize(16); + format.setSamples(4); + + QPoint center = QPoint(screenGeometry.center().x(), screenGeometry.top() + 80); + QSize windowSize(400, 320); + int delta = 40; + + Renderer rendererA(format); + Renderer rendererB(format, &rendererA); + + QThread renderThread; + rendererB.moveToThread(&renderThread); + renderThread.start(); + + QObject::connect(qGuiApp, SIGNAL(lastWindowClosed()), &renderThread, SLOT(quit())); + + HelloWindow windowA(&rendererA); + windowA.setGeometry(QRect(center, windowSize).translated(-windowSize.width() - delta / 2, 0)); + windowA.setWindowTitle(QLatin1String("Thread A - Context A")); + windowA.setVisible(true); + + HelloWindow windowB(&rendererA); + windowB.setGeometry(QRect(center, windowSize).translated(delta / 2, 0)); + windowB.setWindowTitle(QLatin1String("Thread A - Context A")); + windowB.setVisible(true); + + HelloWindow windowC(&rendererB); + windowC.setGeometry(QRect(center, windowSize).translated(-windowSize.width() / 2, windowSize.height() + delta)); + windowC.setWindowTitle(QLatin1String("Thread B - Context B")); + windowC.setVisible(true); + + app.exec(); + + renderThread.wait(); +} |