RichardMarks / coin-collector-mobile

MIT License
0 stars 1 forks source link

better text handling #41

Closed RichardMarks closed 6 years ago

RichardMarks commented 6 years ago

With the discovery of the memory leak in the previous text renderer, I have taken it upon myself to develop a new text renderer module and this issue being created to reference once I am ready to push the code up.

Instead of procedurally calling out to render some text and relying on very buggy template programming and global instantiations for caching the text rendered like we had before, the new system is object oriented and very explicit about things.

We have the ability to use different fonts. We can position, scale, and align the text however we want, as well as change the color, and the text itself.

All TTF rendering is done only when certain properties are changed, and when you want to render to the screen, a simple texture copy will be performed. This is a huge performance boost from what we previously had.

One feature that was lost is the text outline. I cannot justify rendering the text multiple times just to get a drop shadow effect. If we really need drop shadows, then we should switch from TTF rendering to a glyph-based texture atlas like modern engines implement. This would be a massive undertaking for this game, so I don't see much benefit in this approach.