Skip to content

Commit

Permalink
udpated glow to latest version and deny fallback renderers on webgl
Browse files Browse the repository at this point in the history
  • Loading branch information
Nazariglez committed Jan 26, 2025
1 parent 2e4bbc7 commit 8915acd
Show file tree
Hide file tree
Showing 5 changed files with 11 additions and 10 deletions.
4 changes: 2 additions & 2 deletions Cargo.lock

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

2 changes: 1 addition & 1 deletion crates/notan_glow/Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@ bytemuck.workspace = true
hashbrown.workspace = true
image.workspace = true

glow = "0.12.3"
glow = "0.16.0"

[target.'cfg(target_arch = "wasm32")'.dependencies]
wasm-bindgen.workspace = true
Expand Down
4 changes: 2 additions & 2 deletions crates/notan_glow/src/lib.rs
Original file line number Diff line number Diff line change
Expand Up @@ -575,7 +575,7 @@ impl DeviceBackend for GlowBackend {
opts.height as _,
texture_format(&opts.format),
texture_type(&opts.format),
PixelUnpackData::Slice(bytes),
PixelUnpackData::Slice(Some(bytes)),
);
}
TextureUpdaterSourceKind::Raw(source) => source.update(self, opts)?,
Expand Down Expand Up @@ -629,7 +629,7 @@ impl DeviceBackend for GlowBackend {
opts.height as _,
texture_format(&opts.format),
texture_type(&opts.format),
glow::PixelPackData::Slice(bytes),
glow::PixelPackData::Slice(Some(bytes)),
);

clean();
Expand Down
2 changes: 1 addition & 1 deletion crates/notan_glow/src/texture.rs
Original file line number Diff line number Diff line change
Expand Up @@ -182,7 +182,7 @@ pub(crate) unsafe fn create_texture(
0,
format,
texture_type(&info.format),
data,
PixelUnpackData::Slice(data),
);

post_create_texture(gl, info);
Expand Down
9 changes: 5 additions & 4 deletions crates/notan_glow/src/utils.rs
Original file line number Diff line number Diff line change
Expand Up @@ -23,6 +23,7 @@ fn webgl_options(antialias: bool, transparent: bool) -> web_sys::WebGlContextAtt
opts.set_alpha(transparent);
opts.set_antialias(antialias);
opts.set_power_preference(web_sys::WebGlPowerPreference::HighPerformance);
opts.set_fail_if_major_performance_caveat(true);
opts
}

Expand All @@ -35,9 +36,9 @@ fn create_webgl_context(
let gl = win
.get_context_with_context_options("webgl", webgl_options(antialias, transparent).as_ref())
.map_err(|e| format!("{e:?}"))?
.ok_or("Cannot adquire the Webgl context. Is the canvas already instantiated?")?
.ok_or("Cannot acquire the Webgl context. Is the canvas already instantiated?")?
.dyn_into::<web_sys::WebGlRenderingContext>()
.map_err(|_| "Cannot adquire WebGL context.")?;
.map_err(|_| "Cannot acquire WebGL context.")?;

let ctx = glow::Context::from_webgl1_context(gl);
Ok(ctx)
Expand All @@ -52,9 +53,9 @@ fn create_webgl2_context(
let gl = win
.get_context_with_context_options("webgl2", webgl_options(antialias, transparent).as_ref())
.map_err(|e| format!("{e:?}"))?
.ok_or("Cannot adquire the Webgl2 context. Is the canvas already instantiated?")?
.ok_or("Cannot acquire the Webgl2 context. Is the canvas already instantiated?")?
.dyn_into::<web_sys::WebGl2RenderingContext>()
.map_err(|_| "Cannot adquire WebGL2 context.")?;
.map_err(|_| "Cannot acquire WebGL2 context.")?;

let ctx = glow::Context::from_webgl2_context(gl);
Ok(ctx)
Expand Down

0 comments on commit 8915acd

Please sign in to comment.