Skip to content
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

Find a graphics engine that works well on desktop environments and WASM #7

Closed
Woyten opened this issue Sep 17, 2020 · 11 comments
Closed
Labels
help wanted Extra attention is needed microwave Impact on microwave only

Comments

@Woyten
Copy link
Owner

Woyten commented Sep 17, 2020

Just waiting until nannou-org/nannou#657 is solved might be a solution.

@Woyten Woyten added help wanted Extra attention is needed microwave Impact on microwave only labels Sep 17, 2020
@Woyten
Copy link
Owner Author

Woyten commented May 24, 2021

@x31eq Do you have an opinion which GUI framework to use? ATM Nannou is used but I could switch to another framework. Being undecided about the framework is the reason why GUI-heavy issues like #9 are blocked.

@x31eq
Copy link

x31eq commented May 24, 2021

I got the Druid example from here working the other day (with the code from the website — the repo isn't quite the same):

https://dev.to/davidedelpapa/rust-gui-introduction-a-k-a-the-state-of-rust-gui-libraries-as-of-january-2021-40gl#druid

I like it and they say it works with Wasm. I haven't tried it on Wasm. There are other things that mention it on that page, including the comments. I know no more

@x31eq
Copy link

x31eq commented May 24, 2021

Got the egui template working as well, native and Wasm.

https://github.com/emilk/egui

Looks interesting, but it's one of these GUIs that completely ignores native conventions: double-click select is idiosyncratic, copy/paste doesn't work. The native one does at least use the window manager's frame. Both binaries about 4MB (stripped).

@Woyten
Copy link
Owner Author

Woyten commented May 24, 2021

@x31eq Thanks for digging into this! My feelings about the different frameworks are the following:

  • egui: Seems to be the new kid on the block. It's difficult to tell whether it's a dayfly or not. I should definitively keep an eye on it since idiomatic GUI concepts are not a goal for me right now.
  • Druid: I have seen a lot of positive feedback about it. A big plus is that its showcase is a font renderer which means that it has primary support for custom graphics, e.g. a virtual keyboard. What troubles me a bit is that a related project is moving away from it to Iced.
  • Iced: Gave it a try. Worked smoothly and seems to be the most promising candidate for a cross-platform GUI app. The drawback for me was that it has no support for physical keyboard events yet.

I chose Nannou arbitrarily because it was presented at RustFest. Do you think there is a compelling reason to switch to one of the other frameworks?

@x31eq
Copy link

x31eq commented May 24, 2021

The compelling reason for me is that it'd work on my desktop! I skipped Iced because of the OpenGL requirement. If I build the hello world I get

thread 'main' panicked at '0:1(10): error: GLSL 3.30 is not supported. Supported
versions are: 1.10, 1.20, and 1.00 ES

GLSL is a mathematics library. I don't know why this requires an older version.

@Woyten Woyten closed this as completed May 24, 2021
@Woyten Woyten reopened this May 24, 2021
@Woyten
Copy link
Owner Author

Woyten commented May 24, 2021

From what I know GLSL is a shading language. But unlike Vulkan, GLSL should work on any system...strange...! 😆

@x31eq
Copy link

x31eq commented May 25, 2021

It isn't normal for Debian stable to provide a too recent library version. I expect this was a sign of the immature OpenGL support in Iced. The repo I pulled is pointing to a specific commit from last November. I can build the latest Iced library, I think there's some OpenGL support in there. I don't know how to specify it.

Wouldn't keyboard events come from a different library?

Harmoxen looks good. It works for me with Druid. The Iced branch builds against Vulkan.

Egui looks promising for what it is. That isn't something I have a use for. I think I'll write something in Druid and find out what problems it has. I see it lists as a non-goal "Support rendering to HTML when targeting the web." That suggests Iced will be better on the Wasm side

@Woyten
Copy link
Owner Author

Woyten commented May 25, 2021

Wouldn't keyboard events come from a different library?

I am not sure how that would integrate with the event loops provided by the frameworks. Besides that, is there any cross-platform library for keyboard events? The closest candidate that I can think of is winit.

I might give egui a try this weekend although from reading the docs I can tell that the keyboard event model is too restricted.

By the way, Bevy looks very promising but has no official support for WASM as far as I can tell.

So, at the moment it looks as if Druid has all the required features: WASM and physical keyboard events. But before completely switching to another framework I will request some feedback in the Rust Subreddit.

@Woyten
Copy link
Owner Author

Woyten commented May 29, 2021

Current progress: I gave winit a try (wasm-new branch). It has access to physical key locations i.e. scancodes but those scancodes are platform dependent (rust-windowing/winit#1806). Druid scancodes might be platform independent and the Reddit community recommends it (https://www.reddit.com/r/rust/comments/nl0d3b).

@Woyten
Copy link
Owner Author

Woyten commented May 31, 2021

So, it seems that Druid is the most promising candidate: It comes with multi-platform support and it's designed with complex graphics in mind. The keyboard model is the best I could find in any of the GUI frameworks but I don't know how well the model works in practice. The only downside of Druid that I know of is that rendering to VST hosts is not possible at the moment (Azorlogh/harmoxen#6, @Azorlogh thanks for sharing your thoughts!). @x31eq Do you think this is a show stopper?

The second best option might be Iced. It worked smoothly in my expriments and can render to VST hosts. The big problems are that it has no access to physical key locations and, since it depends on wgpu, it somehow requires a platform with Vulkan support. I hope what I say here is correct...

@Woyten
Copy link
Owner Author

Woyten commented Jan 19, 2023

Bevy is by far the best suitable framework for the task. It is

  • well-maintained
  • fast
  • has explicit WASM support
  • supports all kinds of input events (physical keys, mouse, gamepad)
  • allows for custom graphics
  • has basic UI widgets
  • enables 3D graphics

Closing this ticket now since I made my decision.

@Woyten Woyten closed this as completed Jan 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted Extra attention is needed microwave Impact on microwave only
Projects
None yet
Development

No branches or pull requests

2 participants