Grokmoo / thyme

Themable Immediate Mode User Interface Toolkit in Rust
Apache License 2.0
96 stars 5 forks source link

Image widget/dynamic image loading #29

Open woelper opened 3 years ago

woelper commented 3 years ago

First of all, thanks for this amazing project! This is probably more a question, but I was wondering if there is an option to create an image widget directly or draw into an image resource? My use case would be to download images dynamically and insert them into the UI or render a 3d object into a texture inside the UI. I've seen the latest release notes from 0.5.0 and was excited about Thyme images can be defined without requiring an actual image on disk - but I could not find out how this can actually be done. Thanks in advance!

Grokmoo commented 3 years ago

Thyme doesn't quite do what you are after yet.

I think it is pretty close to the first part - download images dynamically and insert them into the UI. Right now, image data can only be specified in the ContextBuilder (so, before the app is created). This needs to be switched around so that image data can be specified at any time, just like is already possible with the theme files. Then live reload / asset rebuild just needs to account for this. This is definitely on my near-term to-do list.

Render to texture support is something that would need to be handled in the GliumRenderer and WgpuRenderer. Methods would need to be exposed to allow you to get a backend-specific handle to a particular texture which could then be used for a draw command. This doesn't sound to me like it would be difficult to accomplish. Potentially limiting in this approach is that the texture in question would probably need to be fixed in size. We probably would want a register_texture_empty method on the Context / ContextBuilder to give you a starting point.

Jared

woelper commented 3 years ago

Thanks for the reply Jared!

Both ideas sound absolutely great, especially the exposed texture to draw into - that sounds extremely flexible!

If I can somehow help, please let me know. Again, thanks for looking into this!

Johann