diff --git a/imgui-examples/examples/hello_gfx.rs b/imgui-examples/examples/hello_gfx.rs index cda16b9..f406fc3 100644 --- a/imgui-examples/examples/hello_gfx.rs +++ b/imgui-examples/examples/hello_gfx.rs @@ -4,6 +4,7 @@ extern crate glutin; #[macro_use] extern crate imgui; extern crate imgui_gfx_renderer; +extern crate imgui_sys; use imgui::*; diff --git a/imgui-examples/examples/support_gfx/mod.rs b/imgui-examples/examples/support_gfx/mod.rs index 77cbf97..474e6e1 100644 --- a/imgui-examples/examples/support_gfx/mod.rs +++ b/imgui-examples/examples/support_gfx/mod.rs @@ -43,6 +43,23 @@ pub fn run bool>(title: String, clear_color: [f32; 4], mut run_ }; 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); let config = ImFontConfig::new().oversample_h(1).pixel_snap_h(true).size_pixels(13.0); config.rasterizer_multiply(1.75).add_font(