feat(viewport): complete viewport-based rendering system (#8)
Implements a comprehensive viewport system that allows fixed game resolution with flexible window scaling, addressing the primary wishes for issues #34, #49, and #8. Key Features: - Fixed game resolution independent of window size (window.game_resolution property) - Three scaling modes accessible via window.scaling_mode: - "center": 1:1 pixels, viewport centered in window - "stretch": viewport fills window, ignores aspect ratio - "fit": maintains aspect ratio with black bars - Automatic window-to-game coordinate transformation for mouse input - Full Python API integration with PyWindow properties Technical Implementation: - GameEngine::ViewportMode enum with Center, Stretch, Fit modes - SFML View system for efficient GPU-based viewport scaling - updateViewport() recalculates on window resize or mode change - windowToGameCoords() transforms mouse coordinates correctly - PyScene mouse input automatically uses transformed coordinates Tests: - test_viewport_simple.py: Basic API functionality - test_viewport_visual.py: Visual verification with screenshots - test_viewport_scaling.py: Interactive mode switching and resizing This completes the viewport-based rendering task and provides the foundation for resolution-independent game development as requested for Crypt of Sokoban. 🤖 Generated with [Claude Code](https://claude.ai/code) Co-Authored-By: Claude <noreply@anthropic.com>
This commit is contained in:
parent
93256b96c6
commit
5a49cb7b6d
9 changed files with 626 additions and 12 deletions
15
ROADMAP.md
15
ROADMAP.md
|
|
@ -65,6 +65,7 @@
|
|||
- Grid background colors (#50) ✅
|
||||
- RenderTexture base infrastructure ✅
|
||||
- UIFrame clipping support ✅
|
||||
- Viewport-based rendering (#8) ✅
|
||||
|
||||
### Active Development:
|
||||
- **Branch**: alpha_streamline_2
|
||||
|
|
@ -244,10 +245,13 @@ Rendering Layer:
|
|||
⏳ Extend to other UI classes
|
||||
⏳ Effects (blur, glow, etc.)
|
||||
|
||||
3. #8 - Viewport-based rendering [NEXT PRIORITY]
|
||||
- RenderTexture matches viewport
|
||||
- Proper scaling/letterboxing
|
||||
- Coordinate system transformations
|
||||
3. ✅ #8 - Viewport-based rendering [COMPLETED]
|
||||
- Fixed game resolution (window.game_resolution)
|
||||
- Three scaling modes: "center", "stretch", "fit"
|
||||
- Window to game coordinate transformation
|
||||
- Mouse input properly scaled with windowToGameCoords()
|
||||
- Python API fully integrated
|
||||
- Tests: test_viewport_simple.py, test_viewport_visual.py, test_viewport_scaling.py
|
||||
|
||||
4. #106 - Shader support [STRETCH GOAL]
|
||||
sprite.shader = mcrfpy.Shader.load("glow.frag")
|
||||
|
|
@ -267,7 +271,8 @@ Rendering Layer:
|
|||
- Dirty flag system crucial for performance - only re-render when properties change
|
||||
- Nested clipping works correctly with proper coordinate transformations
|
||||
- Scene transitions already use RenderTextures - good integration test
|
||||
- Next: Viewport rendering (#8) will build on RenderTexture foundation
|
||||
- Viewport rendering (#8) ✅ complete with three scaling modes and coordinate transformation
|
||||
- Next: Extend RenderTexture support to remaining UI classes (Caption, Sprite, Grid)
|
||||
- Shader/Particle systems might be deferred to Phase 7 or Gamma
|
||||
|
||||
*Rationale*: This unlocks professional visual effects but is complex.
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue