Skip to content

Commit

Permalink
dyrend: Support glow renderer
Browse files Browse the repository at this point in the history
  • Loading branch information
ids1024 committed Feb 2, 2023
1 parent 8d6d245 commit deb566a
Show file tree
Hide file tree
Showing 2 changed files with 21 additions and 11 deletions.
9 changes: 7 additions & 2 deletions dyrend/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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"]

Expand Down
23 changes: 14 additions & 9 deletions dyrend/src/window/compositor.rs
Original file line number Diff line number Diff line change
@@ -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,
Expand All @@ -16,7 +18,7 @@ use crate::Renderer;
/// A window graphics backend for iced powered by `glow`.
pub enum Compositor<Theme> {
#[cfg(feature = "glow")]
Glow(GlowCompositor<Theme>),
Glow(GlutinCompositor<GlowCompositor<Theme>>),
#[cfg(feature = "softbuffer")]
softbuffer(softbufferCompositor<Theme>),
#[cfg(feature = "wgpu")]
Expand All @@ -25,7 +27,7 @@ pub enum Compositor<Theme> {

pub enum Surface<Theme> {
#[cfg(feature = "glow")]
Glow(<GlowCompositor<Theme> as compositor::Compositor>::Surface),
Glow(<GlutinCompositor<GlowCompositor<Theme>> as compositor::Compositor>::Surface),
#[cfg(feature = "softbuffer")]
softbuffer(
<softbufferCompositor<Theme> as compositor::Compositor>::Surface,
Expand All @@ -40,13 +42,16 @@ impl<Theme> Compositor<Theme> {
settings: crate::Settings,
compatible_window: Option<&W>,
) -> Result<(Self, Renderer<Theme>), 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,
) {
Expand Down

0 comments on commit deb566a

Please sign in to comment.