From 4aed0fa4b6d63b739b5557ef16f6077988cd2758 Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Tue, 19 May 2020 20:01:55 +0200 Subject: Rename `window::Backend` to `Compositor` --- src/application.rs | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src/application.rs') diff --git a/src/application.rs b/src/application.rs index 689332f1..0ae2ec55 100644 --- a/src/application.rs +++ b/src/application.rs @@ -216,7 +216,7 @@ impl iced_winit::Application for Instance where A: Application, { - type Backend = iced_wgpu::window::Backend; + type Compositor = iced_wgpu::window::Compositor; type Executor = A::Executor; type Flags = A::Flags; type Message = A::Message; -- cgit From e0e4ee73feead3f05730625c7e1917b63f0b384e Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 21 May 2020 00:37:47 +0200 Subject: Implement `iced_glutin` :tada: --- src/application.rs | 20 ++++++++++---------- 1 file changed, 10 insertions(+), 10 deletions(-) (limited to 'src/application.rs') diff --git a/src/application.rs b/src/application.rs index 0ae2ec55..644a4824 100644 --- a/src/application.rs +++ b/src/application.rs @@ -188,19 +188,19 @@ pub trait Application: Sized { { #[cfg(not(target_arch = "wasm32"))] { - let wgpu_settings = iced_wgpu::Settings { + let glow_settings = iced_glow::Settings { default_font: settings.default_font, antialiasing: if settings.antialiasing { - Some(iced_wgpu::settings::Antialiasing::MSAAx4) + Some(iced_glow::settings::Antialiasing::MSAAx4) } else { None }, - ..iced_wgpu::Settings::default() + ..iced_glow::Settings::default() }; - as iced_winit::Application>::run( + as iced_glutin::Application>::run( settings.into(), - wgpu_settings, + glow_settings, ); } @@ -212,11 +212,11 @@ pub trait Application: Sized { struct Instance(A); #[cfg(not(target_arch = "wasm32"))] -impl iced_winit::Application for Instance +impl iced_glutin::Application for Instance where A: Application, { - type Compositor = iced_wgpu::window::Compositor; + type Compositor = iced_glow::window::Compositor; type Executor = A::Executor; type Flags = A::Flags; type Message = A::Message; @@ -231,10 +231,10 @@ where self.0.title() } - fn mode(&self) -> iced_winit::Mode { + fn mode(&self) -> iced_glutin::Mode { match self.0.mode() { - window::Mode::Windowed => iced_winit::Mode::Windowed, - window::Mode::Fullscreen => iced_winit::Mode::Fullscreen, + window::Mode::Windowed => iced_glutin::Mode::Windowed, + window::Mode::Fullscreen => iced_glutin::Mode::Fullscreen, } } -- cgit From ae5e2c6c734894d71b2034a498a858b7997c5d3d Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Thu, 21 May 2020 04:27:31 +0200 Subject: Introduce `Program` and `State` --- src/application.rs | 37 ++++++++++++++++++++++--------------- 1 file changed, 22 insertions(+), 15 deletions(-) (limited to 'src/application.rs') diff --git a/src/application.rs b/src/application.rs index 644a4824..b6f2227e 100644 --- a/src/application.rs +++ b/src/application.rs @@ -198,10 +198,11 @@ pub trait Application: Sized { ..iced_glow::Settings::default() }; - as iced_glutin::Application>::run( - settings.into(), - glow_settings, - ); + iced_glutin::application::run::< + Instance, + Self::Executor, + iced_glow::window::Compositor, + >(settings.into(), glow_settings); } #[cfg(target_arch = "wasm32")] @@ -211,15 +212,29 @@ pub trait Application: Sized { struct Instance(A); +#[cfg(not(target_arch = "wasm32"))] +impl iced_glutin::Program for Instance +where + A: Application, +{ + type Renderer = iced_glow::Renderer; + type Message = A::Message; + + fn update(&mut self, message: Self::Message) -> Command { + self.0.update(message) + } + + fn view(&mut self) -> Element<'_, Self::Message> { + self.0.view() + } +} + #[cfg(not(target_arch = "wasm32"))] impl iced_glutin::Application for Instance where A: Application, { - type Compositor = iced_glow::window::Compositor; - type Executor = A::Executor; type Flags = A::Flags; - type Message = A::Message; fn new(flags: Self::Flags) -> (Self, Command) { let (app, command) = A::new(flags); @@ -238,17 +253,9 @@ where } } - fn update(&mut self, message: Self::Message) -> Command { - self.0.update(message) - } - fn subscription(&self) -> Subscription { self.0.subscription() } - - fn view(&mut self) -> Element<'_, Self::Message> { - self.0.view() - } } #[cfg(target_arch = "wasm32")] -- cgit From 22ced3485eb6f295faaab1e31d8d1b8d61fc422b Mon Sep 17 00:00:00 2001 From: Héctor Ramón Jiménez Date: Wed, 27 May 2020 05:05:13 +0200 Subject: Introduce feature flags to enable `iced_glow` Also keep `iced_wgpu` as the default renderer for the time being. --- src/application.rs | 24 ++++++++++++------------ 1 file changed, 12 insertions(+), 12 deletions(-) (limited to 'src/application.rs') diff --git a/src/application.rs b/src/application.rs index b6f2227e..19cab7da 100644 --- a/src/application.rs +++ b/src/application.rs @@ -188,21 +188,21 @@ pub trait Application: Sized { { #[cfg(not(target_arch = "wasm32"))] { - let glow_settings = iced_glow::Settings { + let renderer_settings = crate::renderer::Settings { default_font: settings.default_font, antialiasing: if settings.antialiasing { - Some(iced_glow::settings::Antialiasing::MSAAx4) + Some(crate::renderer::settings::Antialiasing::MSAAx4) } else { None }, - ..iced_glow::Settings::default() + ..crate::renderer::Settings::default() }; - iced_glutin::application::run::< + crate::runtime::application::run::< Instance, Self::Executor, - iced_glow::window::Compositor, - >(settings.into(), glow_settings); + crate::renderer::window::Compositor, + >(settings.into(), renderer_settings); } #[cfg(target_arch = "wasm32")] @@ -213,11 +213,11 @@ pub trait Application: Sized { struct Instance(A); #[cfg(not(target_arch = "wasm32"))] -impl iced_glutin::Program for Instance +impl iced_winit::Program for Instance where A: Application, { - type Renderer = iced_glow::Renderer; + type Renderer = crate::renderer::Renderer; type Message = A::Message; fn update(&mut self, message: Self::Message) -> Command { @@ -230,7 +230,7 @@ where } #[cfg(not(target_arch = "wasm32"))] -impl iced_glutin::Application for Instance +impl crate::runtime::Application for Instance where A: Application, { @@ -246,10 +246,10 @@ where self.0.title() } - fn mode(&self) -> iced_glutin::Mode { + fn mode(&self) -> iced_winit::Mode { match self.0.mode() { - window::Mode::Windowed => iced_glutin::Mode::Windowed, - window::Mode::Fullscreen => iced_glutin::Mode::Fullscreen, + window::Mode::Windowed => iced_winit::Mode::Windowed, + window::Mode::Fullscreen => iced_winit::Mode::Fullscreen, } } -- cgit