emilk / egui

egui: an easy-to-use immediate mode GUI in Rust that runs on both web and native
https://www.egui.rs/
Apache License 2.0
22.37k stars 1.61k forks source link

eframe use egui-winit for both native and web #2023

Open luiswirth opened 2 years ago

luiswirth commented 2 years ago

I believe that eframe should use egui-winit for both native and web. eframe should in my opinion be like my old crate eww (egui + winit + wgpu) (doesn't has to be wgpu). Meaning that eframe is only a wrapper around a platform crate (winit) and a renderer crate (wgpu, glium or glow).

This would streamline the egui ecosystem a lot I believe. Currently the step from eframe to a custom integration is still quite big. This would hopefully make this process a lot easier. This could probably also avoid code duplication in eframe as you wouldn't have to handle wasm support separately as winit would do it for you.

As mentioned in discord I got my own egui + winit + wgpu integration running on wasm. I know it's way to early to now make the switch to only using winit. But I think this goal is worth pursuing. I'll first provide an example like you @emilk asked on discord for #1755.

emilk commented 2 years ago

I agree that this is something worth investigating, but before we do we must first get egui-winit to work on web (https://github.com/emilk/egui/issues/1032). Once we have egui-winit working on web (with a working example in the egui repository) we can evaluate whether or not we should switch to it for eframe. You mention a lot of upsides (all of which I agree with), but there are some potential downsides:

A) more reliance on winit, making it more difficult to try out alternatives (like https://github.com/tauri-apps/tao) B) an extra layer (more overhead, more compilation time, with its own quirks, more difficult for us to fix, etc, etc)

luiswirth commented 2 years ago

I agree with everything you said.

luiswirth commented 2 years ago

As mentioned on discord, I got my application called carveout, which uses a custom egui + wgpu + winit integration, running on the web using wasm. You can check out a live web demo on https://lwirth.com/. It's a digital pen note taking application.

@coderedart also managed to create a running egui + wgpu + winit setup using his egui toolkit etk. Check out their live web demo https://coderedart.github.io/etk/!

In my setup I noticed some things aren't working right now:

I haven't investigated these problems so far.

HactarCE commented 8 months ago

What's the latest on this issue? My app Hyperspeedcube uses egui+winit+wgpu and works very well, with the only issues I notice being:

It even gets scancodes + virtual keycodes for key input! My app uses both depending on the context.