We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
@caelunshun Thanks for adding WASM support btw!
Texture colors appear to be inverted on the WASM target, using the latest experimental branch commit 26be4a0:
Native Vulkan target:
Inverted colors with same result on Chrome, Firefox, Edge:
Original texture:
Relevant code:
let mut texBuilder = cx.create_texture_set_builder(); texBuilder.add_texture(include_bytes!("../assets/crab.png"), "sprite1").unwrap(); let texSet = texBuilder.build(1024, 1024).unwrap(); cx.add_texture_set(texSet); let tex = Context::texture_for_name(canvas.context(), "sprite1").unwrap(); canvas.draw_sprite(tex, vec2(20., 20.), 400.);
The text was updated successfully, but these errors were encountered:
Thanks for the bug report!
Looks like wgpu doesn't implement BGRA textures on WebGL, so the BGRA texture atlas gets interpreted as RGBA—thus swapping the red and blue channels.
wgpu
As a workaround, we can use an RGBA format when on the Web.
Sorry, something went wrong.
@caelunshun Works, thanks!
#[cfg(target_arch = "wasm32")] pub fn add_web_texture( texBuilder: &mut TextureSetBuilder, data: &[u8], name: impl Into<String>, ) -> Result<(), image::ImageError> { let image = image::load_from_memory(data)?.to_rgba8(); texBuilder.add_raw_texture(image.width(), image.height(), image.into_raw(), name); Ok(()) }
No branches or pull requests
@caelunshun Thanks for adding WASM support btw!
Texture colors appear to be inverted on the WASM target, using the latest experimental branch commit 26be4a0:
Native Vulkan target:
![image](https://user-images.githubusercontent.com/31808141/139527914-27df2078-a20a-4e5e-8c4e-0ea5095e43b9.png)
Inverted colors with same result on Chrome, Firefox, Edge:
![image](https://user-images.githubusercontent.com/31808141/139527934-68ab30ee-d260-415b-9fc2-35c6565db3f0.png)
Original texture:
![crab](https://user-images.githubusercontent.com/31808141/139527999-c7d81e84-1f73-430f-a60b-1d0e631f9cdc.png)
Relevant code:
The text was updated successfully, but these errors were encountered: