The backends need to have no dependency on the engine, otherwise
there'll be conflicts when we do stuff like include `window.h` in a
file that also happens to include "WindowsWrapper.h" somewhere.
Previously, the font batching system was very shoddy: basically,
glyph bitmaps would be cached to system memory, and uploaded
on-demand to the GPU.
The OpenGL3, OpenGLES2, and SDLTexture backends relied on
`cute_spritebatch.h` to handle batching. While nice, this library is
overkill: it's intended for managing a whole game, not just a couple
of glyphs. It also depends on C++11, which is something I'd rather be
without.
Being so complex, it appears that internally it spams the backend
when merging atlases together. According to bug reports, this causes
the game to skip a lot of frames.
Instead, I've ditched the system-memory-side caching, and made the
game maintain its own atlas. Unlike `cute_spritebatch.h`, this one
doesn't purge glyphs after they've gone unused for 30(?) seconds -
instead, glyphs are only purged when room in the atlas runs out, at
which point the oldest glyph is replaced. This method doesn't involve
creating or destroying atlases at runtime, avoiding the overhead of
whatever OpenGL/DirectX do internally when that happens.
Currently only the OpenGL3, OpenGLES2, and Software renderers have
been updated with this - the others will fail to build.
I know immediate-mode renderers won't benefit from this, but it
replaces the leaky old caching system, so it's still an improvement.
CSE2 Portable is meant to be a purist thing - experiencing Cave Story
the way it was meant to be. The crappy font rendering was definitely
not how it was meant to be.