Adding sRGB colors to ImGui style.
This is a pull request to enable SRGB colors within ImGui for all 3 styles (dark, light, classic) All linear colors have been converted to sRGB formats. The reason sRGB colors are hardcoded instead of calculated at runtime from the linear colors is for performance reasons. This brings in extra maintance as when the default style colors are changed, both the linear and sRGB values need updating.
This PR got created to resolve the issue raised in https://github.com/ocornut/imgui/issues/578
To enable the sRGB colors, simply add ImGuiConfigFlags_IsSRGB to the config flags and update the style
ImGuiIO& io = ImGui::GetIO();
io.ConfigFlags |= ImGuiConfigFlags_IsSRGB;
ImGui::StyleColorsDark();
Normal dark theme
sRGB dark theme before change
sRGB dark theme after change
This can probably be merged with https://github.com/ocornut/imgui/pull/2943
this doesn't degamma color wheels, only theme colors so is an incomplete solution.
here's a generic, dynamic fix to the issue (dx12 only - other backends can be upgraded in a similar fashion)
https://github.com/ocornut/imgui/pull/7904
Working fine for me, haven't tested colorwheels tho.
There is one bug in your code however. You're using &= to validate the config flags, but this ERASES all configflags except for the srgb one. The correct way would be simply just a &.
Some of the colors in the gamma corrected version are quite different from the original ones. This seems to be caused by many of the colors being rendered with transparency, using the alpha values in the colors. Multiplying the rgb channels with with the alpha channel before performing the sRGB conversion, and then dividing the result with the alpha seems to produce colors much closer to the original values.