Text rendering
Are there plans to include this functionality?
It could be done using wgpu_glyph, but this requires the wgpu::Device handle to be exposed (a simple method on rgx::core::Device would suffice I think).
Yeah I've been thinking about this. Exposing Device is not a problem - my only concern would be to not introduce too many new dependencies.
Well, ~the first blocker to using wgpu_glyph is that it uses wgpu from git, not the published version~ (not an issue: wgpu_glyph 0.4.0 depends on wgpu 0.3.0). After that, one needs:
- the
wgpu::Devicehandle - the
wgpu::Queue(separate from theDevicein the git version, but looks like it can be stored alongside it) - a
wgpu::SwapChainOutput(encapsulated byrgx::core::SwapChainTextureso easy to expose)
Other than the wgpu version mis-match, I don't think exposing these would be difficult (optionally they could be feature-gated; this essentially makes wgpu part of the public API).
Alternatively, depending on wgpu_glyph behind a feature-gate (or possibly even embedding the code; there isn't all that much) allows a more convenient solution, if you want to do that (I'm not sure what your goals with this project are).
Another complication: glyph_brush uses position measured from the top-left, while rgx places the origin in the bottom-left. Still, it's easy enough to translate.
Alternatively, depending on wgpu_glyph behind a feature-gate (or possibly even embedding the code; there isn't all that much) allows a more convenient solution, if you want to do that (I'm not sure what your goals with this project are).
This is what I was thinking initially - text is a very complicated thing, and not all projects will want to do it this way. I avoided the concern for this reason, but having --feature text for a lightweight solution may not be a bad idea.
In my opinion, from a point of usability, such code should be a part of rgx. It might still be a good idea to put it behind a feature flag, as some users wouldn't need text rendering in their projects. However, it will make the library much easier to use for any kind of apps that require simple graphical UIs (think games, simple editors).
I see it as a special kit alongside shape and sprite rendering.
Yeah I've been thinking about this, and I'd be open to have bitmap text rendering built-in. This is how rx works, and it's fairly simple, see here.
The question will remain: should rgx include a default bitmap font or not.
This is what the font looks like: https://github.com/cloudhead/rx/blob/master/assets/glyphs.png