mirror of
https://github.com/JulianGro/overte.git
synced 2025-04-29 19:22:57 +02:00
Only set the context once per QML surface
This commit is contained in:
parent
3e71316589
commit
b41c106f3c
1 changed files with 3 additions and 19 deletions
|
@ -214,22 +214,19 @@ void OffscreenQmlRenderThread::init() {
|
||||||
connect(_renderControl, &QQuickRenderControl::sceneChanged, _surface, &OffscreenQmlSurface::requestUpdate);
|
connect(_renderControl, &QQuickRenderControl::sceneChanged, _surface, &OffscreenQmlSurface::requestUpdate);
|
||||||
|
|
||||||
if (!_canvas.makeCurrent()) {
|
if (!_canvas.makeCurrent()) {
|
||||||
qWarning("Failed to make context current on render thread");
|
// Failed to make GL context current, this OffscreenQmlSurface is basically dead
|
||||||
|
qWarning("Failed to make context current on QML Renderer Thread");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
_renderControl->initialize(_canvas.getContext());
|
_renderControl->initialize(_canvas.getContext());
|
||||||
setupFbo();
|
setupFbo();
|
||||||
_escrow.setRecycler([this](GLuint texture){
|
_escrow.setRecycler([this](GLuint texture){
|
||||||
_textures.recycleTexture(texture);
|
_textures.recycleTexture(texture);
|
||||||
});
|
});
|
||||||
_canvas.doneCurrent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenQmlRenderThread::cleanup() {
|
void OffscreenQmlRenderThread::cleanup() {
|
||||||
if (!_canvas.makeCurrent()) {
|
|
||||||
qFatal("Failed to make context current on render thread");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
_renderControl->invalidate();
|
_renderControl->invalidate();
|
||||||
|
|
||||||
_fbo.reset();
|
_fbo.reset();
|
||||||
|
@ -237,7 +234,6 @@ void OffscreenQmlRenderThread::cleanup() {
|
||||||
_textures.clear();
|
_textures.clear();
|
||||||
|
|
||||||
_canvas.doneCurrent();
|
_canvas.doneCurrent();
|
||||||
|
|
||||||
_canvas.getContextObject()->moveToThread(QCoreApplication::instance()->thread());
|
_canvas.getContextObject()->moveToThread(QCoreApplication::instance()->thread());
|
||||||
|
|
||||||
_quit = true;
|
_quit = true;
|
||||||
|
@ -267,18 +263,11 @@ void OffscreenQmlRenderThread::resize() {
|
||||||
}
|
}
|
||||||
_size = newOffscreenSize;
|
_size = newOffscreenSize;
|
||||||
|
|
||||||
// Clear out any fbos with the old size
|
|
||||||
if (!_canvas.makeCurrent()) {
|
|
||||||
qWarning("Failed to make context current on render thread");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
qDebug() << "Offscreen UI resizing to " << _newSize.width() << "x" << _newSize.height() << " with pixel ratio " << pixelRatio;
|
qDebug() << "Offscreen UI resizing to " << _newSize.width() << "x" << _newSize.height() << " with pixel ratio " << pixelRatio;
|
||||||
|
|
||||||
locker.unlock();
|
locker.unlock();
|
||||||
|
|
||||||
setupFbo();
|
setupFbo();
|
||||||
_canvas.doneCurrent();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void OffscreenQmlRenderThread::render() {
|
void OffscreenQmlRenderThread::render() {
|
||||||
|
@ -287,11 +276,6 @@ void OffscreenQmlRenderThread::render() {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (!_canvas.makeCurrent()) {
|
|
||||||
qWarning("Failed to make context current on render thread");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
QMutexLocker locker(&_mutex);
|
QMutexLocker locker(&_mutex);
|
||||||
_renderControl->sync();
|
_renderControl->sync();
|
||||||
_waitCondition.wakeOne();
|
_waitCondition.wakeOne();
|
||||||
|
|
Loading…
Reference in a new issue