Native: Accept winit::WindowAttributes as a config value (#4364)

This commit is contained in:
Nico Burns authored and GitHub committed 2025-07-06 12:44:00 -04:00
1 parent 5495bcedb4
commit ddc94cf44c
4 files changed
+24 -2

No files matched your search

+1
View File
@@ -18,6 +18,7 @@ tracing = ["dep:tracing-subscriber", "dioxus-native/tracing"]
dioxus-native = { path = "../../packages/native" }
dioxus = { workspace = true }
wgpu = "24"
winit = "0.30"
bytemuck = "1"
color = "0.3"
tracing-subscriber = { workspace = true, optional = true }
+14 -1
View File
@@ -5,6 +5,8 @@ use dioxus::prelude::*;
use dioxus_native::use_wgpu;
use std::any::Any;
use wgpu::{Features, Limits};
use winit::dpi::LogicalSize;
use winit::window::WindowAttributes;
mod demo_renderer;
@@ -19,6 +21,13 @@ fn limits() -> Limits {
..Limits::default()
}
}
fn window_attributes() -> WindowAttributes {
// You can also use a `<title>` element to set the window title
// but this demonstrates the use of `WindowAttributes`
WindowAttributes::default()
.with_title("WGPU Example")
.with_inner_size(LogicalSize::new(800, 600))
}
type Color = OpaqueColor<Srgb>;
@@ -26,7 +35,11 @@ fn main() {
#[cfg(feature = "tracing")]
tracing_subscriber::fmt::init();
let config: Vec<Box<dyn Any>> = vec![Box::new(FEATURES), Box::new(limits())];
let config: Vec<Box<dyn Any>> = vec![
Box::new(FEATURES),
Box::new(limits()),
Box::new(window_attributes()),
];
dioxus_native::launch_cfg(app, Vec::new(), config);
}