mirror of
https://github.com/overte-org/overte.git
synced 2025-08-06 16:36:54 +02:00
render issue fixes
This commit is contained in:
parent
44cb48b17d
commit
85813ac908
2 changed files with 21 additions and 7 deletions
|
@ -32,13 +32,17 @@ void ResourceImageItem::setReady(bool ready) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void ResourceImageItemRenderer::onUpdateTimer() {
|
void ResourceImageItemRenderer::onUpdateTimer() {
|
||||||
if (_ready && _networkTexture && _networkTexture->isLoaded()) {
|
if (_ready) {
|
||||||
if(_fboMutex.tryLock()) {
|
if (_networkTexture && _networkTexture->isLoaded()) {
|
||||||
invalidateFramebufferObject();
|
if(_fboMutex.tryLock()) {
|
||||||
qApp->getActiveDisplayPlugin()->copyTextureToQuickFramebuffer(_networkTexture, _copyFbo, &_fenceSync);
|
invalidateFramebufferObject();
|
||||||
_fboMutex.unlock();
|
qApp->getActiveDisplayPlugin()->copyTextureToQuickFramebuffer(_networkTexture, _copyFbo, &_fenceSync);
|
||||||
|
_fboMutex.unlock();
|
||||||
|
} else {
|
||||||
|
qDebug() << "couldn't get a lock, using last frame";
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
qDebug() << "couldn't get a lock, using last frame";
|
_networkTexture = DependencyManager::get<TextureCache>()->getTexture(_url);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
update();
|
update();
|
||||||
|
@ -76,6 +80,9 @@ void ResourceImageItemRenderer::synchronize(QQuickFramebufferObject* item) {
|
||||||
}
|
}
|
||||||
|
|
||||||
QOpenGLFramebufferObject* ResourceImageItemRenderer::createFramebufferObject(const QSize& size) {
|
QOpenGLFramebufferObject* ResourceImageItemRenderer::createFramebufferObject(const QSize& size) {
|
||||||
|
if (_copyFbo) {
|
||||||
|
delete _copyFbo;
|
||||||
|
}
|
||||||
QOpenGLFramebufferObjectFormat format;
|
QOpenGLFramebufferObjectFormat format;
|
||||||
format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
|
format.setAttachment(QOpenGLFramebufferObject::CombinedDepthStencil);
|
||||||
_copyFbo = new QOpenGLFramebufferObject(size, format);
|
_copyFbo = new QOpenGLFramebufferObject(size, format);
|
||||||
|
@ -100,7 +107,14 @@ void ResourceImageItemRenderer::render() {
|
||||||
_fboMutex.lock();
|
_fboMutex.lock();
|
||||||
_copyFbo->bind();
|
_copyFbo->bind();
|
||||||
QOpenGLFramebufferObject::blitFramebuffer(framebufferObject(), _copyFbo, GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT, GL_NEAREST);
|
QOpenGLFramebufferObject::blitFramebuffer(framebufferObject(), _copyFbo, GL_COLOR_BUFFER_BIT|GL_DEPTH_BUFFER_BIT, GL_NEAREST);
|
||||||
|
|
||||||
|
// this clears the copyFbo texture
|
||||||
|
// so next frame starts fresh - helps
|
||||||
|
// when aspect ratio changes
|
||||||
|
_copyFbo->takeTexture();
|
||||||
|
_copyFbo->bind();
|
||||||
_copyFbo->release();
|
_copyFbo->release();
|
||||||
|
|
||||||
_fboMutex.unlock();
|
_fboMutex.unlock();
|
||||||
if (doUpdate) {
|
if (doUpdate) {
|
||||||
update();
|
update();
|
||||||
|
|
|
@ -34,7 +34,7 @@ private:
|
||||||
NetworkTexturePointer _networkTexture;
|
NetworkTexturePointer _networkTexture;
|
||||||
QQuickWindow* _window;
|
QQuickWindow* _window;
|
||||||
QMutex _fboMutex;
|
QMutex _fboMutex;
|
||||||
QOpenGLFramebufferObject* _copyFbo;
|
QOpenGLFramebufferObject* _copyFbo { nullptr };
|
||||||
GLsync _fenceSync { 0 };
|
GLsync _fenceSync { 0 };
|
||||||
QTimer _updateTimer;
|
QTimer _updateTimer;
|
||||||
public slots:
|
public slots:
|
||||||
|
|
Loading…
Reference in a new issue