Fixed two critical bugs preventing multiple textured sprites from rendering correctly:
1. **setState consumed by submit**: Render state was set once at the beginning,
but bgfx consumes state at each submit(). Batches 2+ had no state → invisible.
FIX: Call setState() before EACH batch, not once globally.
2. **Buffer overwrite race condition**: updateBuffer() is immediate but submit()
is deferred. When batch 2 called updateBuffer(), it overwrote batch 1's data
BEFORE bgfx executed the draw calls. All batches used the last batch's data
→ all sprites rendered at the same position (superimposed).
FIX: Use transient buffers (one per batch, frame-local) instead of reusing
the same dynamic buffer. Each batch gets its own isolated memory.
Changes:
- SpritePass: setState before each batch + transient buffer allocation per batch
- UIRenderer: Retained mode rendering (render:sprite:add/update/remove)
- test_ui_showcase: Added 3 textured buttons demo section
- test_3buttons_minimal: Minimal test case for multi-texture debugging
Tested: 3 textured buttons now render at correct positions with correct textures.
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
- Fix JsonDataNode::getChildReadOnly() to handle JSON array access by numeric index
- Fix test_ui_showcase to use JSON array for children (matching test_single_button pattern)
- Add visual test files: test_single_button, test_ui_showcase, test_sprite_debug
- Clean up debug logging from SpritePass, SceneCollector, UIButton, BgfxDevice
The root cause was that UITree couldn't access array children in JSON layouts.
UIButton hover/click now works correctly in both test files.
🤖 Generated with [Claude Code](https://claude.com/claude-code)
Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>