Skip to content

Commit

Permalink
Ensure that the param for sRGB decoding is only done once and not eve…
Browse files Browse the repository at this point in the history
…ry frame
  • Loading branch information
athenaz2 committed Jul 29, 2024
1 parent 2f407c6 commit 7c5ee65
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 13 deletions.
19 changes: 11 additions & 8 deletions examples/simple_demo_qml/GzRenderer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
Expand Down Expand Up @@ -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();
}

//////////////////////////////////////////////////
Expand Down
4 changes: 0 additions & 4 deletions examples/simple_demo_qml/ThreadRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -334,10 +334,6 @@ void TextureNode::PrepareNode()
// note: include QQuickWindow::TextureHasAlphaChannel if the rendered content
// has alpha.

QOpenGLFunctions *glFuncs = QOpenGLContext::currentContext()->functions();
glFuncs->glBindTexture(GL_TEXTURE_2D, newId);
glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_SRGB_DECODE_EXT, GL_SKIP_DECODE_EXT);

#if QT_VERSION < QT_VERSION_CHECK(5, 14, 0)
# ifndef _WIN32
# pragma GCC diagnostic push
Expand Down
1 change: 0 additions & 1 deletion examples/simple_demo_qml/ThreadRenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -80,7 +80,6 @@
#include <QQuickWindow>
#include <QSGSimpleTextureNode>
#include <QThread>
#include <QOpenGLFunctions>

//--------------------------------------------------------------------------
/*
Expand Down

0 comments on commit 7c5ee65

Please sign in to comment.