Seems transparency does not work on wgpu, is this normal ?
I would happily use glow, but fonts are a bit aliased. Is there a workaround this ?
features = ["wgpu", "default_system_font", "debug", "palette" ]features = ["glow", "glow_default_system_font", "debug", "palette" ]See https://github.com/hecrj/iced/pull/371 / https://github.com/gfx-rs/wgpu/issues/687
tl;dr for now wgpu hardcodes opaque mode, so it needs to be patched. You can use my fork:
[patch.crates-io]
# patch: transparency (config.composite_alpha_mode = hal::window::CompositeAlphaMode::PREMULTIPLIED)
wgpu-core = { git = "https://github.com/myfreeweb/wgpu", branch = "v0.6-alpha" }
wgpu-types = { git = "https://github.com/myfreeweb/wgpu", branch = "v0.6-alpha" }
See #371 / gfx-rs/wgpu#687
tl;dr for now wgpu hardcodes opaque mode, so it needs to be patched. You can use my fork:
[patch.crates-io] # patch: transparency (config.composite_alpha_mode = hal::window::CompositeAlphaMode::PREMULTIPLIED) wgpu-core = { git = "https://github.com/myfreeweb/wgpu", branch = "v0.6-alpha" } wgpu-types = { git = "https://github.com/myfreeweb/wgpu", branch = "v0.6-alpha" }
I've followed this & used your fork, modified the examples, but the transparency still seems not working on macOS 11.0.1 Big Sur:
diff --git a/Cargo.toml b/Cargo.toml
index 6221ae4..6bbfb22 100644
--- a/Cargo.toml
+++ b/Cargo.toml
@@ -100,3 +100,8 @@ iced_web = { version = "0.3", path = "web" }
[package.metadata.docs.rs]
rustdoc-args = ["--cfg", "docsrs"]
features = ["image", "svg", "canvas"]
+
+[patch.crates-io]
+# patch: transparency (config.composite_alpha_mode = hal::window::CompositeAlphaMode::PREMULTIPLIED)
+wgpu-core = { git = "https://github.com/myfreeweb/wgpu", branch = "v0.6-alpha" }
+wgpu-types = { git = "https://github.com/myfreeweb/wgpu", branch = "v0.6-alpha" }
\ No newline at end of file
diff --git a/examples/clock/Cargo.toml b/examples/clock/Cargo.toml
index c6e3237..b2a819a 100644
--- a/examples/clock/Cargo.toml
+++ b/examples/clock/Cargo.toml
@@ -7,4 +7,4 @@ publish = false
[dependencies]
iced = { path = "../..", features = ["canvas", "tokio", "debug"] }
-chrono = "0.4"
+chrono = "0.4"
\ No newline at end of file
diff --git a/examples/clock/src/main.rs b/examples/clock/src/main.rs
index b317ac0..3a52ff2 100644
--- a/examples/clock/src/main.rs
+++ b/examples/clock/src/main.rs
@@ -1,3 +1,5 @@
+
use iced::{
canvas::{self, Cache, Canvas, Cursor, Geometry, LineCap, Path, Stroke},
executor, time, Application, Color, Command, Container, Element, Length,
@@ -6,6 +8,11 @@ use iced::{
pub fn main() -> iced::Result {
Clock::run(Settings {
+ window: iced::window::Settings{
+ decorations: false,
+ transparent: true,
+ ..iced::window::Settings::default()
+ },
antialiasing: true,
..Settings::default()
})
@@ -32,7 +39,7 @@ impl Application for Clock {
now: chrono::Local::now(),
clock: Default::default(),
},
- Command::none(),
+ Command::none()
)
}
@@ -55,6 +62,10 @@ impl Application for Clock {
Command::none()
}
+ fn background_color(&self) -> Color {
+ Color::TRANSPARENT
+ }
+

But switching to glow works:
diff --git a/examples/clock/Cargo.toml b/examples/clock/Cargo.toml
index c6e3237..fce87f2 100644
--- a/examples/clock/Cargo.toml
+++ b/examples/clock/Cargo.toml
@@ -6,5 +6,5 @@ edition = "2018"
publish = false
[dependencies]
-iced = { path = "../..", features = ["canvas", "tokio", "debug"] }
-chrono = "0.4"
+iced = { path = "../..", features = ["glow", "glow_canvas", "tokio", "debug"] }
+chrono = "0.4"

Most helpful comment
See https://github.com/hecrj/iced/pull/371 / https://github.com/gfx-rs/wgpu/issues/687
tl;dr for now wgpu hardcodes opaque mode, so it needs to be patched. You can use my fork: