mirror of
https://github.com/lubosz/overte.git
synced 2025-08-07 19:21:16 +02:00
Merge pull request #7517 from zzmp/fix/qml-renderer
Check for valid qml gl context creation
This commit is contained in:
commit
30cb62f1aa
2 changed files with 7 additions and 10 deletions
|
@ -38,11 +38,13 @@ bool OffscreenGLCanvas::create(QOpenGLContext* sharedContext) {
|
||||||
_context->setShareContext(sharedContext);
|
_context->setShareContext(sharedContext);
|
||||||
}
|
}
|
||||||
_context->setFormat(getDefaultOpenGLSurfaceFormat());
|
_context->setFormat(getDefaultOpenGLSurfaceFormat());
|
||||||
|
|
||||||
if (_context->create()) {
|
if (_context->create()) {
|
||||||
_offscreenSurface->setFormat(_context->format());
|
_offscreenSurface->setFormat(_context->format());
|
||||||
_offscreenSurface->create();
|
_offscreenSurface->create();
|
||||||
return true;
|
return _offscreenSurface->isValid();
|
||||||
}
|
}
|
||||||
|
qWarning("Failed to create OffscreenGLCanvas context");
|
||||||
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -134,14 +134,13 @@ QEvent* OffscreenQmlRenderThread::Queue::take() {
|
||||||
}
|
}
|
||||||
|
|
||||||
OffscreenQmlRenderThread::OffscreenQmlRenderThread(OffscreenQmlSurface* surface, QOpenGLContext* shareContext) : _surface(surface) {
|
OffscreenQmlRenderThread::OffscreenQmlRenderThread(OffscreenQmlSurface* surface, QOpenGLContext* shareContext) : _surface(surface) {
|
||||||
qDebug() << "Building QML Renderer: creating context";
|
qDebug() << "Building QML Renderer";
|
||||||
if (!_canvas.create(shareContext)) {
|
if (!_canvas.create(shareContext)) {
|
||||||
static const char* error = "Failed to create OffscreenGLCanvas";
|
qWarning("Failed to create OffscreenGLCanvas");
|
||||||
qWarning() << error;
|
_quit = true;
|
||||||
throw error;
|
return;
|
||||||
};
|
};
|
||||||
|
|
||||||
qDebug() << "Building QML Renderer: creating render control";
|
|
||||||
_renderControl = new QMyQuickRenderControl();
|
_renderControl = new QMyQuickRenderControl();
|
||||||
QQuickWindow::setDefaultAlphaBuffer(true);
|
QQuickWindow::setDefaultAlphaBuffer(true);
|
||||||
// Create a QQuickWindow that is associated with our render control.
|
// Create a QQuickWindow that is associated with our render control.
|
||||||
|
@ -149,19 +148,15 @@ OffscreenQmlRenderThread::OffscreenQmlRenderThread(OffscreenQmlSurface* surface,
|
||||||
// NOTE: Must be created on the main thread so that OffscreenQmlSurface can send it events
|
// NOTE: Must be created on the main thread so that OffscreenQmlSurface can send it events
|
||||||
// NOTE: Must be created on the rendering thread or it will refuse to render,
|
// NOTE: Must be created on the rendering thread or it will refuse to render,
|
||||||
// so we wait until after its ctor to move object/context to this thread.
|
// so we wait until after its ctor to move object/context to this thread.
|
||||||
qDebug() << "Building QML Renderer: creating window";
|
|
||||||
_quickWindow = new QQuickWindow(_renderControl);
|
_quickWindow = new QQuickWindow(_renderControl);
|
||||||
_quickWindow->setColor(QColor(255, 255, 255, 0));
|
_quickWindow->setColor(QColor(255, 255, 255, 0));
|
||||||
_quickWindow->setFlags(_quickWindow->flags() | static_cast<Qt::WindowFlags>(Qt::WA_TranslucentBackground));
|
_quickWindow->setFlags(_quickWindow->flags() | static_cast<Qt::WindowFlags>(Qt::WA_TranslucentBackground));
|
||||||
|
|
||||||
// We can prepare, but we must wait to start() the thread until after the ctor
|
// We can prepare, but we must wait to start() the thread until after the ctor
|
||||||
qDebug() << "Building QML Renderer: moving to own thread";
|
|
||||||
_renderControl->prepareThread(this);
|
_renderControl->prepareThread(this);
|
||||||
_canvas.getContextObject()->moveToThread(this);
|
_canvas.getContextObject()->moveToThread(this);
|
||||||
moveToThread(this);
|
moveToThread(this);
|
||||||
|
|
||||||
qDebug() << "Building QML Renderer: complete";
|
|
||||||
|
|
||||||
_queue.add(INIT);
|
_queue.add(INIT);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue