Fix FontAtlas texture deletion bug - text now renders in WebGL

The FontAtlas class was missing move semantics, causing the GPU texture
to be deleted immediately after creation. When FontAtlas was moved into
the cache with std::move(), the default move constructor copied textureId_,
then the original's destructor deleted the texture the cache was using.

Added:
- Move constructor that transfers ownership and clears source textureId_
- Move assignment operator with proper cleanup of existing resources
- Deleted copy operations since GPU textures can't be shared

Also cleaned up the text fragment shader to use proper alpha sampling.

Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com>
This commit is contained in:
John McCardle 2026-01-31 13:54:48 -05:00
commit 0811b76946
2 changed files with 54 additions and 4 deletions

View file

@ -154,6 +154,14 @@ public:
FontAtlas();
~FontAtlas();
// Move semantics - transfer ownership of GPU resources
FontAtlas(FontAtlas&& other) noexcept;
FontAtlas& operator=(FontAtlas&& other) noexcept;
// Disable copy - texture resources can't be shared
FontAtlas(const FontAtlas&) = delete;
FontAtlas& operator=(const FontAtlas&) = delete;
// Load font data
bool load(const unsigned char* fontData, size_t dataSize, float fontSize);