This mirrors the previous refactor of the TextRenderer. All calls to
draw_rect and draw_triangle now buffer vertex data (position and color).
A begin()/flush() system is introduced to manage batching.
Overhauls text rendering to improve performance.
Renderer was really ineffient, sending a separate GPU draw call for
every character rendered. This created a bottleneck, especially with
text-heavy UI stuff like the wallpaper.
- The 'TextRenderer' now generates a single texture atlas for all font
glyhs on load so all characters share a single texture.
- 'begin()' / 'flush()' was added to the 'TextRenderer'. Calls to
'render_text' now buffer vertex data (position, texture coords,
colour) instead of drawing immediately. A single 'flush()' call at the
end of a pass draws all buffered text in one draw call.
- A simple batching introduced some shitty visual layering bugs. to
solve this, a staged flushing architecture has been implemented. Each
logical UI component is now responsible for managing its own rendering
passes, beginning and flushing text batches as needed to ensure correct
back-to-front layering.
The UI codebase was suffering with complexity due to the need to
manually convert between two different coordinate systems:
- Top-down "screen coordinates" used by SDL for input and windowing.
- Bottom-up "GL coordinates" used by low-level renderers.
This was making layout calculations diffucult and is bug prone.
With this commit, I'm introducing a 'UIRenderer' abstraction layer that
wraps the low-level 'ShapeRenderer' and 'TextRenderer'. This is
responsible for centralising all coordinate system conversations.
All UI components has been refactored to use the 'UIRenderer' so the
entire UI code opeates exclusively in a single, top-down screen
coordinate system as one would expect.