hajimehoshi / ebiten

Ebitengine - A dead simple 2D game engine for Go
https://ebitengine.org
Apache License 2.0
11.12k stars 664 forks source link

text/v2: deprecate `CacheGlyphs` by reordering draw calls in `DrawText` #3069

Closed hajimehoshi closed 3 months ago

hajimehoshi commented 3 months ago

Operating System

What feature would you like to be added?

CacheGlyphs was introduced since DrawText might send draw calls for writing pixels and multiple drawing triangles in turn, which prevented automatic batching.

However, wouldn't it be possible to reorder draw calls in DrawText so that the same type of draw calls become adjacent and automatically batched?

Why is this needed?

No response

hajimehoshi commented 3 months ago

Hm, CacheGlyphs caches all the variations of glyphs (#2528), so this might be needed for this purpose...

tinne26 commented 3 months ago

Being able to cache the glyph masks is always a relevant feature. For example, that could be desirable after changing the UI font or before entering a menu with a lot of text. You could do some "fake draw", but that's not very clean.

Additionally, there's a risk with reordering the draws: glyphs can overlap, so draw order is not necessarily superfluous. This shouldn't have much impact on the current contexts, but it could be a problem with certain blend modes or more complex text rendering operations.