Skip to content

Commit

Permalink
SwapChainGL: correct color format if sRGB framebuffers are not enabled
Browse files Browse the repository at this point in the history
  • Loading branch information
TheMostDiligent committed Sep 16, 2023
1 parent 9b82c58 commit 74a926d
Showing 1 changed file with 14 additions and 1 deletion.
15 changes: 14 additions & 1 deletion Graphics/GraphicsEngineOpenGL/src/SwapChainGLImpl.cpp
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
/*
* Copyright 2019-2022 Diligent Graphics LLC
* Copyright 2019-2023 Diligent Graphics LLC
* Copyright 2015-2019 Egor Yusov
*
* Licensed under the Apache License, Version 2.0 (the "License");
Expand Down Expand Up @@ -50,6 +50,19 @@ SwapChainGLImpl::SwapChainGLImpl(IReferenceCounters* pRefCounters,
}
// clang-format on
{
if (m_SwapChainDesc.ColorBufferFormat == TEX_FORMAT_RGBA8_UNORM_SRGB ||
m_SwapChainDesc.ColorBufferFormat == TEX_FORMAT_BGRA8_UNORM_SRGB)
{
if (glIsEnabled(GL_FRAMEBUFFER_SRGB) == GL_FALSE)
{
auto ColorFmt = m_SwapChainDesc.ColorBufferFormat == TEX_FORMAT_RGBA8_UNORM_SRGB ?
TEX_FORMAT_RGBA8_UNORM :
TEX_FORMAT_BGRA8_UNORM;
LOG_WARNING_MESSAGE("Changing swap chain color format to ", GetTextureFormatAttribs(ColorFmt).Name, " because sRGB framebuffers are not enabled.");
m_SwapChainDesc.ColorBufferFormat = ColorFmt;
}
}

if (m_DesiredPreTransform != SURFACE_TRANSFORM_OPTIMAL &&
m_DesiredPreTransform != SURFACE_TRANSFORM_IDENTITY)
{
Expand Down

0 comments on commit 74a926d

Please sign in to comment.