alexheretic / glyph-brush

Fast GPU cached text rendering
Apache License 2.0
688 stars 52 forks source link

Precompute the number of GlyphVertex instances generated by a Section? #170

Open tareksander opened 10 months ago

tareksander commented 10 months ago

Is there a way to get the number of GlyphVertex instances that will be generated by the Section on the next process_queued call? I need to order the section drawing with other drawing operations, and for that I need to know which GlyphVertex instances came from which Section. I want to implement Skia-like SaveLayer functionality, which means I can't draw all the text at once, but have to switch rendering targets in between.

tareksander commented 10 months ago

Or do I have to do my own thing with glyph_brush_layout and glyph_brush_draw_cache instead?

alexheretic commented 10 months ago

GlyphBrush is designed to render all vertices in a single draw.

If you need to do multiple draws one option is multiple GlyphBrush instances, one for each draw. See https://github.com/alexheretic/glyph-brush/issues/157.

tareksander commented 10 months ago

Is there an option to share the cache between instances?

alexheretic commented 10 months ago

Currently it isn't possible to share a single texture between GlyphBrush instances.