-
Notifications
You must be signed in to change notification settings - Fork 0
feat(api): add surface and texture APIs for v0.2.0 #2
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
- Add convert() method for pixel format conversion - Add duplicate() method for surface duplication - Add scale() method with linear scaling - Add flip() method for horizontal/vertical flipping - Implement surface_lock_guard for safe pixel access - Complete all surface transformation functionality
- Add texture_access enum for static/streaming/target access - Add scale_mode enum for nearest/linear scaling - Add texture_flip enum with bitmask support - Map directly to SDL3 constants for type safety - Enable texture flip combinations with bitmask operators
- Add texture class with comprehensive interface design - Add texture_lock_guard for safe pixel access - Add texture_args struct for construction parameters - Include texture creation, state management, and pixel access - Support factory methods for BMP/PNG loading and surface conversion - Update laya.hpp to include texture headers - Complete texture interface with 200+ lines of declarations
- Add texture.cpp with complete implementation - Implement texture constructors and factory methods - Add texture_lock_guard for pixel access safety - Add texture update and locking operations - Add query methods for size, format, and access - Update CMakeLists.txt to include texture.cpp - Use SDL3 properties API for texture queries
- Add set_alpha_mod() and get_alpha_mod() for alpha modulation - Add set_color_mod() and get_color_mod() for color modulation - Add set_blend_mode() and get_blend_mode() for blend mode control - Add set_scale_mode() and get_scale_mode() for scaling control - Complete texture state management functionality - All texture state operations properly handle SDL3 errors
- Add texture forward declaration to renderer.hpp - Add comprehensive texture render() method overloads - Implement basic texture rendering (position and rectangle) - Implement texture region rendering with src/dst rects - Implement texture rotation with angle and center point - Implement texture flipping with horizontal/vertical options - Add full-control rendering with rotation, center, and flip - Use SDL3 RenderTexture and RenderTextureRotated functions - Complete renderer-texture integration for v0.2.0
- Add scripts/run-pre-commit.sh following STYLE.md conventions - Provides convenient wrapper for uv run --project tools --group dev pre-commit run - Includes colored output, help documentation, and argument passthrough - Update scripts/README.md with documentation for new script
…ions - Unify flip_mode/texture_flip enums to single flip_mode in renderer_types.hpp - Add missing texture::update(const surface&) implementation - Remove duplicate texture_flip enum and unnecessary bitmask support - Update all flip enum references across codebase for consistency - Fix documentation examples to use correct API signatures - Add comprehensive surface unit tests with doctest framework Addresses all blocking issues identified in branch review: - API naming consistency (flip enums unified) - Complete implementations (no missing symbols) - Accurate documentation (examples compile correctly) - Basic test coverage (15 surface test cases added) Branch is now merge-ready with proper RAII, error handling, and SDL3 integration.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
💡 Codex Review
Here are some automated review suggestions for this pull request.
ℹ️ About Codex in GitHub
Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you
- Open a pull request for review
- Mark a draft as ready
- Comment "@codex review".
If Codex has suggestions, it will comment; otherwise it will react with 👍.
Codex can also answer questions or update the PR. Try commenting "@codex address that feedback".
- add missing include headers for stdexcept, string, and iterator - correct SDL_GetRGBA call to use proper SDL3 signature with palette parameter
Summary
This PR adds complete surface and texture APIs to laya, providing type-safe C++20 wrappers for SDL3's 2D graphics pipeline. This represents a major feature addition (~960 lines of new code) that enables CPU-side pixel manipulation and GPU texture management.
Features Added
🎨 Surface API
SDL_Surfacewith move-only semantics🖼️ Texture API
SDL_Texturewith move-only semantics🎯 Renderer Extensions
flip_modeenum for consistencyTechnical Details
laya::error::from_sdl()std::exchangepatternBreaking Changes
None - This is a purely additive change. All existing APIs remain unchanged.
Testing
Documentation
docs/features/surfaces.mdwith usage examplesdocs/features/textures.mdwith renderer integration examplesCode Quality Fixes
This PR also includes critical fixes identified during branch review:
flip_mode/texture_flipenumstexture::update(const surface&)methodMigration Guide
For new users:
Note: This PR prepares the groundwork for v0.2.0 release. Version bump and tagging will be done on
mainafter merge.