Add background_color to Application and Sandbox

This commit is contained in:
Héctor Ramón Jiménez 2020-06-12 22:12:15 +02:00
parent 2a516dfc48
commit 4c0286e8ac
11 changed files with 81 additions and 17 deletions

View file

@ -1,4 +1,4 @@
use crate::{Backend, Renderer, Settings, Viewport};
use crate::{Backend, Color, Renderer, Settings, Viewport};
use core::ffi::c_void;
use glow::HasContext;
@ -21,8 +21,6 @@ impl iced_graphics::window::GLCompositor for Compositor {
) -> (Self, Self::Renderer) {
let gl = glow::Context::from_loader_function(loader_function);
gl.clear_color(1.0, 1.0, 1.0, 1.0);
// Enable auto-conversion from/to sRGB
gl.enable(glow::FRAMEBUFFER_SRGB);
@ -60,12 +58,16 @@ impl iced_graphics::window::GLCompositor for Compositor {
&mut self,
renderer: &mut Self::Renderer,
viewport: &Viewport,
color: Color,
output: &<Self::Renderer as iced_native::Renderer>::Output,
overlay: &[T],
) -> mouse::Interaction {
let gl = &self.gl;
let [r, g, b, a] = color.into_linear();
unsafe {
gl.clear_color(r, g, b, a);
gl.clear(glow::COLOR_BUFFER_BIT);
}