From 0ff3e7d155967e6a0ffe7836d9fc133ca08e2302 Mon Sep 17 00:00:00 2001 From: Laszlo Agocs Date: Thu, 16 Oct 2014 13:35:33 +0200 Subject: Make hellowindow multi display capable on embedded Platforms like eglfs allow a single window per screen. Thus the behavior of --multiple is not suitable since it tries to open multiple windows on the primary screen. Instead, introduce --multiscreen. Add also --timeout to quit the app after 10 seconds. This is essential on platforms that do not have windows with decorations that can be used to close windows. With eglfs' kms/drm hooks, starting with --multiscreen will now show a rotating logo on all connected displays, with some random background color. Change-Id: I53f2651f05620e752c289038a9b3ff4508273173 Reviewed-by: Louai Al-Khanji Reviewed-by: Andy Nichols --- examples/opengl/hellowindow/hellowindow.cpp | 16 ++++++++++++++-- 1 file changed, 14 insertions(+), 2 deletions(-) (limited to 'examples/opengl/hellowindow/hellowindow.cpp') diff --git a/examples/opengl/hellowindow/hellowindow.cpp b/examples/opengl/hellowindow/hellowindow.cpp index 57eb111edbf..ac5bfea2805 100644 --- a/examples/opengl/hellowindow/hellowindow.cpp +++ b/examples/opengl/hellowindow/hellowindow.cpp @@ -56,9 +56,14 @@ Renderer::Renderer(const QSurfaceFormat &format, Renderer *share, QScreen *scree if (share) m_context->setShareContext(share->m_context); m_context->create(); + + m_backgroundColor = QColor::fromRgbF(0.1f, 0.1f, 0.2f, 1.0f); + m_backgroundColor.setRed(qrand() % 64); + m_backgroundColor.setGreen(qrand() % 128); + m_backgroundColor.setBlue(qrand() % 256); } -HelloWindow::HelloWindow(const QSharedPointer &renderer) +HelloWindow::HelloWindow(const QSharedPointer &renderer, QScreen *screen) : m_colorIndex(0), m_renderer(renderer) { setSurfaceType(QWindow::OpenGLSurface); @@ -67,6 +72,8 @@ HelloWindow::HelloWindow(const QSharedPointer &renderer) setGeometry(QRect(10, 10, 640, 480)); setFormat(renderer->format()); + if (screen) + setScreen(screen); create(); @@ -147,7 +154,7 @@ void Renderer::render() f->glViewport(0, 0, viewSize.width() * surface->devicePixelRatio(), viewSize.height() * surface->devicePixelRatio()); f->glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); - f->glClearColor(0.1f, 0.1f, 0.2f, 1.0f); + f->glClearColor(m_backgroundColor.redF(), m_backgroundColor.greenF(), m_backgroundColor.blueF(), m_backgroundColor.alphaF()); f->glFrontFace(GL_CW); f->glCullFace(GL_FRONT); f->glEnable(GL_CULL_FACE); @@ -180,8 +187,13 @@ void Renderer::render() QTimer::singleShot(0, this, SLOT(render())); } +Q_GLOBAL_STATIC(QMutex, initMutex) + void Renderer::initialize() { + // Threaded shader compilation can confuse some drivers. Avoid it. + QMutexLocker lock(initMutex()); + QOpenGLShader *vshader = new QOpenGLShader(QOpenGLShader::Vertex, this); vshader->compileSourceCode( "attribute highp vec4 vertex;" -- cgit v1.2.3