rgx.legacy icon indicating copy to clipboard operation
rgx.legacy copied to clipboard

Text rendering

Open dhardy opened this issue 6 years ago • 7 comments

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).

dhardy avatar Oct 14 '19 17:10 dhardy

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.

cloudhead avatar Oct 17 '19 21:10 cloudhead

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::Device handle
  • the wgpu::Queue (separate from the Device in the git version, but looks like it can be stored alongside it)
  • a wgpu::SwapChainOutput (encapsulated by rgx::core::SwapChainTexture so 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).

dhardy avatar Oct 21 '19 13:10 dhardy

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.

dhardy avatar Oct 21 '19 15:10 dhardy

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.

cloudhead avatar Oct 22 '19 18:10 cloudhead

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.

skyne98 avatar Mar 16 '20 15:03 skyne98

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.

cloudhead avatar Mar 16 '20 20:03 cloudhead

This is what the font looks like: https://github.com/cloudhead/rx/blob/master/assets/glyphs.png

cloudhead avatar Mar 16 '20 20:03 cloudhead