From 23665560a433082878de3e40f861bfff43e120ff Mon Sep 17 00:00:00 2001 From: Ian Douglas Scott Date: Thu, 2 Feb 2023 09:59:14 -0800 Subject: [PATCH] dyrend: Support glow renderer --- dyrend/Cargo.toml | 9 +++++++-- dyrend/src/window/compositor.rs | 23 ++++++++++++++--------- 2 files changed, 21 insertions(+), 11 deletions(-) diff --git a/dyrend/Cargo.toml b/dyrend/Cargo.toml index 29769cb5f0..30ef6f6430 100644 --- a/dyrend/Cargo.toml +++ b/dyrend/Cargo.toml @@ -23,6 +23,12 @@ path = "../glow" default-features = false optional = true +[dependencies.iced_glutin] +path = "../glutin" +default-features = false +optional = true + + [dependencies.iced_softbuffer] path = "../softbuffer" default-features = false @@ -37,8 +43,7 @@ optional = true default = ["softbuffer"] image = ["iced_graphics/image", "iced_glow?/image", "iced_softbuffer?/image", "iced_wgpu?/image"] svg = ["iced_graphics/svg", "iced_glow?/svg", "iced_softbuffer?/svg", "iced_wgpu?/svg"] -#TODO: implement Compositor for glow Backend -#glow = ["iced_glow"] +glow = ["iced_glow", "iced_glutin"] softbuffer = ["iced_softbuffer"] wgpu = ["iced_wgpu"] diff --git a/dyrend/src/window/compositor.rs b/dyrend/src/window/compositor.rs index 4a9ec657d5..477ba2105e 100644 --- a/dyrend/src/window/compositor.rs +++ b/dyrend/src/window/compositor.rs @@ -1,5 +1,7 @@ #[cfg(feature = "glow")] use iced_glow::window::Compositor as GlowCompositor; +#[cfg(feature = "glow")] +use iced_glutin::Compositor as GlutinCompositor; use iced_graphics::{ compositor::{self, Compositor as _, Information, SurfaceError}, Color, Error, Viewport, @@ -16,7 +18,7 @@ use crate::Renderer; /// A window graphics backend for iced powered by `glow`. pub enum Compositor { #[cfg(feature = "glow")] - Glow(GlowCompositor), + Glow(GlutinCompositor>), #[cfg(feature = "softbuffer")] softbuffer(softbufferCompositor), #[cfg(feature = "wgpu")] @@ -25,7 +27,7 @@ pub enum Compositor { pub enum Surface { #[cfg(feature = "glow")] - Glow( as compositor::Compositor>::Surface), + Glow(> as compositor::Compositor>::Surface), #[cfg(feature = "softbuffer")] softbuffer( as compositor::Compositor>::Surface, @@ -40,13 +42,16 @@ impl Compositor { settings: crate::Settings, compatible_window: Option<&W>, ) -> Result<(Self, Renderer), Error> { - match GlowCompositor::new( - iced_glow::Settings { - default_font: settings.default_font, - default_text_size: settings.default_text_size, - text_multithreading: settings.text_multithreading, - antialiasing: settings.antialiasing, - ..iced_glow::Settings::from_env() + match GlutinCompositor::new( + iced_glutin::Settings { + gl_settings: iced_glow::Settings { + default_font: settings.default_font, + default_text_size: settings.default_text_size, + text_multithreading: settings.text_multithreading, + antialiasing: settings.antialiasing, + ..iced_glow::Settings::from_env() + }, + try_opengles_first: false, // XXX }, compatible_window, ) {