Skip to content

Commit

Permalink
WebGL power preferences should select the best gpu available
Browse files Browse the repository at this point in the history
  • Loading branch information
Nazariglez committed Jan 25, 2025
1 parent 181bb36 commit 791632a
Show file tree
Hide file tree
Showing 7 changed files with 73 additions and 55 deletions.
110 changes: 61 additions & 49 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

10 changes: 5 additions & 5 deletions Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -56,11 +56,11 @@ serde = { version = "1.0", features = ["serde_derive"] }
image = { version = "0.24.7", default-features = false, features = ["jpeg", "png", "ico"] }

# wasm deps
wasm-bindgen = "0.2.87"
wasm-bindgen-futures = "0.4.37"
futures-util = "0.3.28"
web-sys = "0.3.64"
js-sys = "0.3.64"
wasm-bindgen = "0.2.100"
wasm-bindgen-futures = "0.4.50"
futures-util = "0.3.31"
web-sys = "0.3.77"
js-sys = "0.3.77"

[dependencies]
notan_core.workspace = true
Expand Down
2 changes: 2 additions & 0 deletions crates/notan_egui/src/plugin.rs
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,8 @@ impl EguiPlugin {
viewport_output,
} = self.ctx.run(new_input, run_ui);

println!("pixels per point {pixels_per_point}");

let needs_update_textures = !textures_delta.is_empty();
let needs_repaint = viewport_output
.values()
Expand Down
2 changes: 1 addition & 1 deletion crates/notan_glow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -24,4 +24,4 @@ glow = "0.12.3"
[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen.workspace = true
js-sys.workspace = true
web-sys = { workspace = true, features = ["Window", "WebGlContextAttributes","HtmlCanvasElement","HtmlImageElement"] }
web-sys = { workspace = true, features = ["Window", "WebGlContextAttributes", "WebGlPowerPreference", "HtmlCanvasElement","HtmlImageElement"] }
1 change: 1 addition & 0 deletions crates/notan_glow/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ fn webgl_options(antialias: bool, transparent: bool) -> web_sys::WebGlContextAtt
opts.premultiplied_alpha(false);
opts.alpha(transparent);
opts.antialias(antialias);
opts.power_preference(web_sys::WebGlPowerPreference::HighPerformance);
opts
}

Expand Down
2 changes: 2 additions & 0 deletions crates/notan_web/src/lib.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
#![cfg(target_arch = "wasm32")]

mod backend;
mod clipboard;
mod keyboard;
Expand Down
1 change: 1 addition & 0 deletions examples/egui_basic.rs
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ fn main() -> Result<(), String> {

fn draw(app: &mut App, gfx: &mut Graphics, plugins: &mut Plugins) {
let mut output = plugins.egui(|ctx| {
// ctx.set_zoom_factor(10.0);
egui::SidePanel::left("side_panel").show(ctx, |ui| {
ui.heading("Egui Plugin Example");

Expand Down

0 comments on commit 791632a

Please sign in to comment.