1
0
mirror of https://github.com/emilk/egui.git synced 2026-09-01 22:30:03 -04:00

Clear color values are now explicitely sent to the rendering backend as-is. (#2666)

* Clear color values are not explicitely sent to the rendering backend as-is.
Previously, converting from Color32 to Rgba caused an srgb->linear conversion. This conversion is incorrect if the backbuffer doesn't perform automatic conversion from linear->srgb (lack of this conversion is generally what egui assumes!).

* fill in pr numbers in changelog

* Epi comment fix

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* Color32 comment fix

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>

* move changelog line

* rename fix

* use backticks in doc

---------

Co-authored-by: Emil Ernerfeldt <emil.ernerfeldt@gmail.com>
This commit is contained in:
Andreas Reich
2023-02-04 11:02:15 +01:00
committed by GitHub
parent a6b60d5d58
commit 8aa07e9d43
10 changed files with 52 additions and 42 deletions

View File

@@ -5,7 +5,7 @@ use std::{collections::HashMap, sync::Arc};
use egui::{
emath::Rect,
epaint::{Color32, Mesh, PaintCallbackInfo, Primitive, Vertex},
epaint::{Mesh, PaintCallbackInfo, Primitive, Vertex},
};
use glow::HasContext as _;
use memoffset::offset_of;
@@ -665,7 +665,7 @@ impl Painter {
}
}
pub fn clear(gl: &glow::Context, screen_size_in_pixels: [u32; 2], clear_color: egui::Rgba) {
pub fn clear(gl: &glow::Context, screen_size_in_pixels: [u32; 2], clear_color: [f32; 4]) {
crate::profile_function!();
unsafe {
gl.disable(glow::SCISSOR_TEST);
@@ -676,24 +676,12 @@ pub fn clear(gl: &glow::Context, screen_size_in_pixels: [u32; 2], clear_color: e
screen_size_in_pixels[0] as i32,
screen_size_in_pixels[1] as i32,
);
if true {
// verified to be correct on eframe native (on Mac).
gl.clear_color(
clear_color[0],
clear_color[1],
clear_color[2],
clear_color[3],
);
} else {
let clear_color: Color32 = clear_color.into();
gl.clear_color(
clear_color[0] as f32 / 255.0,
clear_color[1] as f32 / 255.0,
clear_color[2] as f32 / 255.0,
clear_color[3] as f32 / 255.0,
);
}
gl.clear_color(
clear_color[0],
clear_color[1],
clear_color[2],
clear_color[3],
);
gl.clear(glow::COLOR_BUFFER_BIT);
}
}