diff --git a/examples/render-opengl/src/app_frame.rs b/examples/render-opengl/src/app_frame.rs index 97994b5..d6ceae7 100644 --- a/examples/render-opengl/src/app_frame.rs +++ b/examples/render-opengl/src/app_frame.rs @@ -37,23 +37,21 @@ pub struct AppFrame { impl AppFrame { pub fn init(window_builder: WindowBuilder) -> Result> { let event_loop = EventLoop::new()?; - let mut template = ConfigTemplateBuilder::new(); - // The template will match only the configurations supporting rendering - // to windows. - // - // XXX We force transparency only on macOS, given that EGL on X11 doesn't - // have it, but we still want to show window. The macOS situation is like - // that, because we can query only one config at a time on it, but all - // normal platforms will return multiple configs, so we can find the config - // with transparency ourselves inside the `reduce`. - if window_builder.transparent() { - template = template + // The template will match only the configurations supporting rendering to windows. + let template = if window_builder.transparent() { + // We force transparency only on macOS, given that EGL on X11 doesn't + // have it, but we still want to show window. The macOS situation is like + // that, because we can query only one config at a time on it, but all + // normal platforms will return multiple configs, so we can find the config + // with transparency ourselves inside the `reduce`. + + ConfigTemplateBuilder::new() .with_alpha_size(8) - .with_transparency(cfg!(all(macos_platform, not(wasm_platform)))); + .with_transparency(cfg!(target_os = "macos")) } else { - template = template.with_transparency(false); - } + ConfigTemplateBuilder::new().with_transparency(false) + }; // Only Windows requires the window to be present before creating the display. // Other platforms don't really need one. @@ -61,7 +59,7 @@ impl AppFrame { // XXX if you don't care about running on Android or so you can safely remove // this condition and always pass the window builder. let maydow_builder = { - let wgl_backend = cfg!(all(windows, not(wasm_platform))); + let wgl_backend = cfg!(target_os = "windows"); wgl_backend.then_some(window_builder.clone()) };