-
Notifications
You must be signed in to change notification settings - Fork 1.6k
New issue
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
Add screenshot support for eframe web #5438
Conversation
Preview available at https://egui-pr-preview.github.io/pr/5438-lucaseframe-web-screenshots |
9abe20e
to
278616b
Compare
I put this back to draft because I'll need to update this to render the texture to the surface via a triangle instead of using copy_texture_to_texture, so we can properly support all platforms. I'll also do this for the native implementation, since there screenshots also don't work with the wgpu gl backend. |
Related wgpu things:
... but really the problem is that |
40f0999
to
289559a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nice!
PR description is now outdated.
Comments are mostly nits about styling and efficiency (if anything the encoder one bugs me most actually) but what I'd like to insist on is refactoring/removing the blocking path - this code dupl doesn't really make sense and I don't think we should have a blocking path in the first place.
crates/egui-wgpu/src/capture.rs
Outdated
wgpu::TextureFormat::Rgba8Unorm => [0, 1, 2, 3], | ||
wgpu::TextureFormat::Bgra8Unorm => [2, 1, 0, 3], |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
as noted above, it would be faster & easier to force the temp texture to be rgba
@Wumpf I've implemented everything you asked for (except for the texture_format changes, as discussed) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
thank you so much for addressing all those! 🚢
### Related * Part of #8264 * Using emilk/egui#5438 Still missing: copy screenshot to clipboard Also fixes a crash when screenshotting graph views. ### Usage ![image](https://github.com/user-attachments/assets/88948342-8279-4bf6-9bc6-13722229dc44) ### Result ![Node-link diagram](https://github.com/user-attachments/assets/b2ff8dd5-ae55-436a-9cd2-263eeb72a0df)
This implements web support for taking screenshots in an eframe app (and adds a nice demo).
It also updates the native screenshot implementation to work with the wgpu gl backend.
The wgpu implementation is quite different than the native one because we can't block to wait for the screenshot result, so instead I use a channel to pass the result to a future frame asynchronously.
ViewportCommand::Screenshot
on web #5425Bildschirmaufnahme.2024-12-05.um.15.27.52.mov