mirror of
https://github.com/emilk/egui.git
synced 2026-08-31 22:00:03 -04:00
Improve text redering and do all color operation in gamma space (#2071)
This commit is contained in:
@@ -117,7 +117,9 @@ impl<'a> Painter<'a> {
|
||||
|
||||
if self.render_state.is_none() {
|
||||
let adapter = self.adapter.as_ref().unwrap();
|
||||
let swapchain_format = surface.get_supported_formats(adapter)[0];
|
||||
|
||||
let swapchain_format =
|
||||
select_framebuffer_format(&surface.get_supported_formats(adapter));
|
||||
|
||||
let rs = pollster::block_on(self.init_render_state(adapter, swapchain_format));
|
||||
self.render_state = Some(rs);
|
||||
@@ -322,3 +324,15 @@ impl<'a> Painter<'a> {
|
||||
// TODO(emilk): something here?
|
||||
}
|
||||
}
|
||||
|
||||
fn select_framebuffer_format(formats: &[wgpu::TextureFormat]) -> wgpu::TextureFormat {
|
||||
for &format in formats {
|
||||
if matches!(
|
||||
format,
|
||||
wgpu::TextureFormat::Rgba8Unorm | wgpu::TextureFormat::Bgra8Unorm
|
||||
) {
|
||||
return format;
|
||||
}
|
||||
}
|
||||
formats[0] // take the first
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user