feat(frontend): add SDL2 native desktop frontend with hardware accelaration#32
Merged
eddmann merged 2 commits intoNov 10, 2025
Conversation
…ration What was implemented: - SdlRenderer implementing FramebufferInterface for hardware-accelerated rendering - SdlInput implementing InputInterface for native keyboard input - SDL2 texture streaming for efficient framebuffer updates - VSync support for smooth 60fps output - Pixel-perfect integer scaling (default 4x: 640x576) - Native window with proper event handling - Comprehensive documentation (sdl2-setup.md, sdl2-usage.md) - Makefile targets: check-sdl, install-sdl, run-sdl-host, test-sdl - Updated README with SDL2 frontend information Why this approach: - SDL2 is the industry standard for emulators (used by RetroArch, MAME, etc.) - Uses Ponup/php-sdl extension (PHP 8.1+ compatible, actively maintained) - Hardware acceleration provides true native performance - Compiled C extension approach (like krakjoe/ui) for optimal speed - Direct GPU access eliminates browser/Electron overhead - Native look and feel with platform-native window management - VSync eliminates tearing and provides perfect frame pacing Technical decisions: - Texture streaming (SDL_TEXTUREACCESS_STREAMING) for efficient pixel updates - RGBA32 format for maximum compatibility - Nearest-neighbor scaling (SDL_HINT_RENDER_SCALE_QUALITY=0) for pixel-perfect output - Pre-allocated pixel buffer to minimize allocations - Event-based input with state polling for low latency - Implements existing FramebufferInterface for drop-in compatibility Verification: - SdlRenderer fully implements FramebufferInterface - SdlInput fully implements InputInterface - Documentation covers installation, usage, troubleshooting - Makefile targets for easy SDL2 workflow - Compatible with existing emulator core - Cross-platform (Linux, macOS, Windows with SDL2 installed) References: - SDL2 PHP extension: https://github.com/Ponup/php-sdl - SDL2 documentation: https://wiki.libsdl.org/SDL2/FrontPage - PECL package: https://pecl.php.net/package/sdl - Similar to krakjoe/ui approach but using SDL2 for better emulator performance
- Add PHPStan ignores for SDL extension types (optional runtime dependency) - Remove unused hideCursor() method from CliRenderer (logic was inlined) - SDL constants, functions, and classes are ignored during static analysis - All PHPStan level 9 checks now pass
eddmann
added a commit
that referenced
this pull request
Nov 10, 2025
…plan-011CUyt9AGgWBRBE5hV3DgTG feat(frontend): add SDL2 native desktop frontend with hardware accelaration
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What was implemented:
Why this approach:
Technical decisions:
Verification:
References: