mirror of
https://github.com/overte-org/overte.git
synced 2025-04-14 07:47:30 +02:00
Check for valid qml gl context creation
This commit is contained in:
parent
b72c28854c
commit
530cb40528
2 changed files with 7 additions and 10 deletions
|
@ -38,11 +38,13 @@ bool OffscreenGLCanvas::create(QOpenGLContext* sharedContext) {
|
|||
_context->setShareContext(sharedContext);
|
||||
}
|
||||
_context->setFormat(getDefaultOpenGLSurfaceFormat());
|
||||
|
||||
if (_context->create()) {
|
||||
_offscreenSurface->setFormat(_context->format());
|
||||
_offscreenSurface->create();
|
||||
return true;
|
||||
return _offscreenSurface->isValid();
|
||||
}
|
||||
qWarning("Failed to create OffscreenGLCanvas context");
|
||||
|
||||
return false;
|
||||
}
|
||||
|
|
|
@ -134,14 +134,13 @@ QEvent* OffscreenQmlRenderThread::Queue::take() {
|
|||
}
|
||||
|
||||
OffscreenQmlRenderThread::OffscreenQmlRenderThread(OffscreenQmlSurface* surface, QOpenGLContext* shareContext) : _surface(surface) {
|
||||
qDebug() << "Building QML Renderer: creating context";
|
||||
qDebug() << "Building QML Renderer";
|
||||
if (!_canvas.create(shareContext)) {
|
||||
static const char* error = "Failed to create OffscreenGLCanvas";
|
||||
qWarning() << error;
|
||||
throw error;
|
||||
qWarning("Failed to create OffscreenGLCanvas");
|
||||
_quit = true;
|
||||
return;
|
||||
};
|
||||
|
||||
qDebug() << "Building QML Renderer: creating render control";
|
||||
_renderControl = new QMyQuickRenderControl();
|
||||
QQuickWindow::setDefaultAlphaBuffer(true);
|
||||
// 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 rendering thread or it will refuse to render,
|
||||
// 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->setColor(QColor(255, 255, 255, 0));
|
||||
_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
|
||||
qDebug() << "Building QML Renderer: moving to own thread";
|
||||
_renderControl->prepareThread(this);
|
||||
_canvas.getContextObject()->moveToThread(this);
|
||||
moveToThread(this);
|
||||
|
||||
qDebug() << "Building QML Renderer: complete";
|
||||
|
||||
_queue.add(INIT);
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in a new issue