Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add gamma correction to simple_demo_qml example #1019

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
9 changes: 6 additions & 3 deletions examples/simple_demo_qml/ThreadRenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -346,7 +349,7 @@ void TextureNode::PrepareNode()
QQuickWindow::NativeObjectTexture,
static_cast<void *>(&newId),
0,
size);
newSize);
#endif
this->setTexture(this->texture);

Expand Down