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

Text rendering #12

Open
dhardy opened this issue Oct 14, 2019 · 7 comments
Open

Text rendering #12

dhardy opened this issue Oct 14, 2019 · 7 comments

Comments

@dhardy
Copy link
Contributor

dhardy commented Oct 14, 2019

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

@cloudhead
Copy link
Owner

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.

@dhardy
Copy link
Contributor Author

dhardy commented Oct 21, 2019

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
Copy link
Contributor Author

dhardy commented Oct 21, 2019

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.

@cloudhead
Copy link
Owner

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.

@skyne98
Copy link

skyne98 commented Mar 16, 2020

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.

@cloudhead
Copy link
Owner

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
Copy link
Owner

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

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants