feat(rendering): implement RenderTexture base infrastructure and UIFrame clipping (#6)
- Added RenderTexture support to UIDrawable base class - std::unique_ptr<sf::RenderTexture> for opt-in rendering - Dirty flag system for optimization - enableRenderTexture() and markDirty() methods - Implemented clip_children property for UIFrame - Python-accessible boolean property - Automatic RenderTexture creation when enabled - Proper coordinate transformation for nested frames - Updated UIFrame::render() for clipping support - Renders to RenderTexture when clip_children=true - Handles nested clipping correctly - Only re-renders when dirty flag is set - Added comprehensive dirty flag propagation - All property setters mark frame as dirty - Size changes recreate RenderTexture - Animation system integration - Created tests for clipping functionality - Basic clipping test with visual verification - Advanced nested clipping test - Dynamic resize handling test This is Phase 1 of the RenderTexture overhaul, providing the foundation for advanced rendering effects like blur, glow, and viewport rendering.
This commit is contained in:
parent
5e4224a4f8
commit
967ebcf478
7 changed files with 503 additions and 19 deletions
|
|
@ -1,5 +1,76 @@
|
|||
# Alpha Streamline 2 Work Log
|
||||
|
||||
## Phase 6: Rendering Revolution
|
||||
|
||||
### Task: RenderTexture Base Infrastructure (#6 - Part 1)
|
||||
|
||||
**Status**: Completed
|
||||
**Date**: 2025-07-06
|
||||
|
||||
**Goal**: Implement opt-in RenderTexture support in UIDrawable base class and enable clipping for UIFrame
|
||||
|
||||
**Implementation**:
|
||||
1. Added RenderTexture infrastructure to UIDrawable:
|
||||
- `std::unique_ptr<sf::RenderTexture> render_texture`
|
||||
- `sf::Sprite render_sprite`
|
||||
- `bool use_render_texture` and `bool render_dirty` flags
|
||||
- `enableRenderTexture()` and `markDirty()` methods
|
||||
2. Implemented clip_children property for UIFrame:
|
||||
- Python property getter/setter
|
||||
- Automatic RenderTexture creation when enabled
|
||||
- Proper handling of nested render contexts
|
||||
3. Updated UIFrame::render() to support clipping:
|
||||
- Renders frame and children to RenderTexture when clipping enabled
|
||||
- Handles coordinate transformations correctly
|
||||
- Optimizes by only re-rendering when dirty
|
||||
4. Added dirty flag propagation:
|
||||
- All property setters call markDirty()
|
||||
- Size changes recreate RenderTexture
|
||||
- Animation system integration
|
||||
|
||||
**Technical Details**:
|
||||
- RenderTexture created lazily on first use
|
||||
- Size matches frame dimensions, recreated on resize
|
||||
- Children rendered at local coordinates (0,0) in texture
|
||||
- Final texture drawn at frame's world position
|
||||
- Transparent background preserves alpha blending
|
||||
|
||||
**Test Results**:
|
||||
- Basic clipping works correctly - children are clipped to parent bounds
|
||||
- Nested clipping (frames within frames) works properly
|
||||
- Dynamic resizing recreates RenderTexture as needed
|
||||
- No performance regression for non-clipped frames
|
||||
- Memory usage reasonable (textures only created when needed)
|
||||
|
||||
**Result**: Foundation laid for advanced rendering features. UIFrame can now clip children to bounds, enabling professional UI layouts. Architecture supports future effects like blur, glow, and shaders.
|
||||
|
||||
---
|
||||
|
||||
### Task: Grid Background Colors (#50)
|
||||
|
||||
**Status**: Completed
|
||||
**Date**: 2025-07-06
|
||||
|
||||
**Goal**: Add customizable background color to UIGrid
|
||||
|
||||
**Implementation**:
|
||||
1. Added `sf::Color background_color` member to UIGrid class
|
||||
2. Implemented Python property getter/setter for background_color
|
||||
3. Updated UIGrid::render() to clear RenderTexture with background color
|
||||
4. Added animation support for individual color components:
|
||||
- background_color.r, background_color.g, background_color.b, background_color.a
|
||||
5. Default background color set to dark gray (8, 8, 8, 255)
|
||||
|
||||
**Test Results**:
|
||||
- Background color properly renders behind grid content
|
||||
- Python property access works correctly
|
||||
- Color animation would work with Animation system
|
||||
- No performance impact
|
||||
|
||||
**Result**: Quick win completed. Grids now have customizable background colors, improving visual flexibility for game developers.
|
||||
|
||||
---
|
||||
|
||||
## Phase 5: Window/Scene Architecture
|
||||
|
||||
### Task: Window Object Singleton (#34)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue