Open lngex opened 2 months ago
Have you tried implementing fn clear_color to MyEguiApp?
impl MyEquiApp {
fn new(...) {...}
fn clear_color(&self, _visuals: &egui::Visuals) -> [f32; 4] {
[0.0, 0.0, 0.0, 0.0]
}
}
This made the window completely transparent in another project I'm working on.
Have you tried implementing fn clear_color to MyEguiApp?
impl MyEquiApp { fn new(...) {...} fn clear_color(&self, _visuals: &egui::Visuals) -> [f32; 4] { [0.0, 0.0, 0.0, 0.0] } }
This made the window completely transparent in another project I'm working on.
Using this method will cause the window to be completely black
Implement clear color and return [0,0,0,0],But the window is not transparent
Try adding a CentralPanel with the frame filled with Color32::TRANSPARENT.
impl eframe::App for MyEguiApp {
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
egui::Window::new("test").show(ctx, |ui| {
ui.heading("hi");
};
egui::CentralPanel::default()
.frame(egui::Frame::default().fill(Color32::TRANSPARENT))
.show(ctx, |ui| {});
}
fn clear_color(...) {...}
I tried to do what you said, but it still didn't work as expected.
@jayy-ahn @lngex I'm curious if you're using the gl or the wgpu backend? Maybe that makes a difference?
@jayy-ahn@lngex我很好奇你是使用gl还是wgpu后端?也许这会有所不同? I turned on the log, and the log shows the glow used.
[2024-09-24T13:38:30Z DEBUG eframe] Using the glow renderer [2024-09-24T13:38:30Z TRACE eframe::native::run] Entering the winit event loop (run_on_demand)… [2024-09-24T13:38:30Z TRACE eframe::native::run] winit event: NewEvents(Init) [2024-09-24T13:38:30Z TRACE eframe::native::run] event_result: Wait [2024-09-24T13:38:30Z TRACE eframe::native::run] winit event: Resumed [2024-09-24T13:38:30Z DEBUG eframe::native::glow_integration] Event::Resumed
This works fine on my other computer, but on this one the background is always black
Please check if there are any problems as follows.
See Below:
use eframe::egui::*;
fn main() -> eframe::Result {
let options = eframe::NativeOptions {
viewport: egui::ViewportBuilder::default()
.with_inner_size([320.0, 240.0])
.with_transparent(true),
..Default::default()
};
eframe::run_native(
"My egui App",
options,
Box::new(|_cc| Ok(Box::<App>::default())),
)
}
#[derive(Default)]
struct App {
_temp_value: usize,
_text: String,
}
impl eframe::App for App {
fn clear_color(&self, _visuals: &egui::Visuals) -> [f32; 4] {
[0.0, 0.0, 0.0, 0.0]
}
fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) {
let panel_frame = Frame::default().fill(egui::Color32::TRANSPARENT);
egui::CentralPanel::default().frame(panel_frame).show(ctx, |ui| {
ui.label(RichText::new("Demo").background_color(egui::Color32::LIGHT_GREEN).color(Color32::RED));
});
}
}
Please check if there are any problems as follows.
See Below:
use eframe::egui::*; fn main() -> eframe::Result { let options = eframe::NativeOptions { viewport: egui::ViewportBuilder::default() .with_inner_size([320.0, 240.0]) .with_transparent(true), ..Default::default() }; eframe::run_native( "My egui App", options, Box::new(|_cc| Ok(Box::<App>::default())), ) } #[derive(Default)] struct App { _temp_value: usize, _text: String, } impl eframe::App for App { fn clear_color(&self, _visuals: &egui::Visuals) -> [f32; 4] { [0.0, 0.0, 0.0, 0.0] } fn update(&mut self, ctx: &egui::Context, _frame: &mut eframe::Frame) { let panel_frame = Frame::default().fill(egui::Color32::TRANSPARENT); egui::CentralPanel::default().frame(panel_frame).show(ctx, |ui| { ui.label(RichText::new("Demo").background_color(egui::Color32::LIGHT_GREEN).color(Color32::RED)); }); } }
There is no problem with the panel and font setting colors, but the window setting the background to transparent does not take effect
There is no problem with the panel and font setting colors, but the window setting the background to transparent does not take effect
The above source code works fine on Windows10
+ glow
.
Using "Viewport Builder::with transparent(true)" to set transparency will result in shadow or translucency. I hope a function can be provided to achieve complete transparency.