mirror of
https://github.com/eliasstepanik/imgui-rs.git
synced 2026-01-22 19:08:37 +00:00
Fix color scheme with gfx
- gfx uses an sRGB framebuffer, which means it expects all vertex colors to be in linear space - imgui provides vertex colors in sRGB space! This causes the appearance of washed out colors - Fix the color space conflict by converting the imgui colors to linear space
This commit is contained in:
parent
1d64e4e185
commit
96b6f6b59c
@ -4,6 +4,7 @@ extern crate glutin;
|
|||||||
#[macro_use]
|
#[macro_use]
|
||||||
extern crate imgui;
|
extern crate imgui;
|
||||||
extern crate imgui_gfx_renderer;
|
extern crate imgui_gfx_renderer;
|
||||||
|
extern crate imgui_sys;
|
||||||
|
|
||||||
use imgui::*;
|
use imgui::*;
|
||||||
|
|
||||||
|
|||||||
@ -43,6 +43,23 @@ pub fn run<F: FnMut(&Ui) -> bool>(title: String, clear_color: [f32; 4], mut run_
|
|||||||
};
|
};
|
||||||
|
|
||||||
let mut imgui = ImGui::init();
|
let mut imgui = ImGui::init();
|
||||||
|
{
|
||||||
|
// Fix incorrect colors with sRGB framebuffer
|
||||||
|
use imgui_sys::ImVec4;
|
||||||
|
|
||||||
|
fn imgui_gamma_to_linear(col: ImVec4) -> ImVec4 {
|
||||||
|
let x = col.x.powf(2.2);
|
||||||
|
let y = col.y.powf(2.2);
|
||||||
|
let z = col.z.powf(2.2);
|
||||||
|
let w = 1.0 - (1.0 - col.w).powf(2.2);
|
||||||
|
ImVec4::new(x, y, z, w)
|
||||||
|
}
|
||||||
|
|
||||||
|
let style = imgui.style_mut();
|
||||||
|
for col in 0..style.colors.len() {
|
||||||
|
style.colors[col] = imgui_gamma_to_linear(style.colors[col]);
|
||||||
|
}
|
||||||
|
}
|
||||||
imgui.set_ini_filename(None);
|
imgui.set_ini_filename(None);
|
||||||
let config = ImFontConfig::new().oversample_h(1).pixel_snap_h(true).size_pixels(13.0);
|
let config = ImFontConfig::new().oversample_h(1).pixel_snap_h(true).size_pixels(13.0);
|
||||||
config.rasterizer_multiply(1.75).add_font(
|
config.rasterizer_multiply(1.75).add_font(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user