diff --git a/examples/simple_demo_qml/GzRenderer.cc b/examples/simple_demo_qml/GzRenderer.cc index 4b4756d02..85bd4aa58 100644 --- a/examples/simple_demo_qml/GzRenderer.cc +++ b/examples/simple_demo_qml/GzRenderer.cc @@ -222,13 +222,20 @@ void GzRenderer::InitialiseOnMainThread() ////////////////////////////////////////////////// void GzRenderer::Render() { - // pre-render may regenerate textureId if the size changes - this->camera->PreRender(); - this->textureId = this->camera->RenderTextureGLId(); - // render to texture this->camera->Update(); + GLuint texIdSrgb = this->camera->RenderTextureGLId(); + + if (this->textureId != texIdSrgb) + { + glBindTexture(GL_TEXTURE_2D, texIdSrgb); + glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SRGB_DECODE_EXT, + GL_SKIP_DECODE_EXT); + } + + this->textureId = texIdSrgb; + // Move camera this->UpdateCamera(); } @@ -276,10 +283,6 @@ void GzRenderer::InitEngine() // quick check on sizing... gzmsg << "imageW: " << this->camera->ImageWidth() << "\n"; gzmsg << "imageH: " << this->camera->ImageHeight() << "\n"; - - // pre-render will force texture creation and may update texture id - this->camera->PreRender(); - this->textureId = this->camera->RenderTextureGLId(); } ////////////////////////////////////////////////// diff --git a/examples/simple_demo_qml/ThreadRenderer.cpp b/examples/simple_demo_qml/ThreadRenderer.cpp index 4aff4dee6..5eb75f97c 100644 --- a/examples/simple_demo_qml/ThreadRenderer.cpp +++ b/examples/simple_demo_qml/ThreadRenderer.cpp @@ -321,22 +321,25 @@ void TextureNode::NewTexture(int _id, const QSize &_size) void TextureNode::PrepareNode() { this->mutex.lock(); + // new render engine texture ID int newId = this->id; - QSize size = this->size; + QSize newSize = this->size; this->id = 0; this->mutex.unlock(); + if (newId) { delete this->texture; this->texture = nullptr; // note: include QQuickWindow::TextureHasAlphaChannel if the rendered content // has alpha. + #if QT_VERSION < QT_VERSION_CHECK(5, 14, 0) # ifndef _WIN32 # pragma GCC diagnostic push # pragma GCC diagnostic ignored "-Wdeprecated-declarations" # endif - this->texture = this->window->createTextureFromId(newId, size); + this->texture = this->window->createTextureFromId(newId, newSize); # ifndef _WIN32 # pragma GCC diagnostic pop # endif @@ -346,7 +349,7 @@ void TextureNode::PrepareNode() QQuickWindow::NativeObjectTexture, static_cast(&newId), 0, - size); + newSize); #endif this->setTexture(this->texture);