Add config option to determin if srgb frame buffer format should be used

This commit is contained in:
2021-01-30 03:25:11 +01:00
parent 3c2ece3338
commit 824c42ef00
2 changed files with 23 additions and 4 deletions

View File

@@ -19,9 +19,10 @@ namespace openVulkanoCpp
uint32_t numThreads = 1;
std::array<float, 4> frameBufferClearColor = { 0.39f, 0.58f, 0.93f, 1.0f };
bool preferFramebufferFormatSRGB = true;
public:
static EngineConfiguration* GetEngineConfiguration()
[[nodiscard]] static EngineConfiguration* GetEngineConfiguration()
{
static EngineConfiguration* config = new EngineConfiguration();
return config;
@@ -32,7 +33,7 @@ namespace openVulkanoCpp
this->numThreads = numThreads;
}
uint32_t GetNumThreads() const
[[nodiscard]] uint32_t GetNumThreads() const
{
return std::max(static_cast<uint32_t>(1), numThreads);
}
@@ -42,9 +43,19 @@ namespace openVulkanoCpp
this->frameBufferClearColor = frameBufferClearColor;
}
std::array<float, 4> GetFrameBufferClearColor() const
[[nodiscard]] std::array<float, 4> GetFrameBufferClearColor() const
{
return frameBufferClearColor;
}
[[nodiscard]] bool GetPreferFramebufferFormatSRGB() const
{
return preferFramebufferFormatSRGB;
}
void SetPreferFramebufferFormatSRGB(bool sRGB)
{
preferFramebufferFormatSRGB = sRGB;
}
};
}

View File

@@ -8,6 +8,7 @@
#include "Base/Logger.hpp"
#include "Base/Utils.hpp"
#include "Base/UI/IVulkanWindow.hpp"
#include "Base/EngineConfiguration.hpp"
#include "Scene/DataFormat.hpp"
#include <algorithm>
@@ -174,6 +175,13 @@ namespace openVulkanoCpp::Vulkan
}
else
{ //TODO chose best fitting
for (const auto& format : surfaceFormats)
{
if (DataFormat(static_cast<DataFormat::Format>(format.format)).IsSRGB() == EngineConfiguration::GetEngineConfiguration()->GetPreferFramebufferFormatSRGB())
{
return format;
}
}
return surfaceFormats[0];
}
}
@@ -188,4 +196,4 @@ namespace openVulkanoCpp::Vulkan
}
return imgs;
}
}
}