hanhan1978 / ffi-sdl3
PHP FFI bindings for SDL3 and SDL3_ttf
v0.1.1
2026-04-16 01:22 UTC
Requires
- php: >=8.4
- ext-ffi: *
README
Small PHP FFI bindings for SDL3 and SDL3_ttf.
This package was split out from the overlay demo so it can be reused as an independent Composer library.
Requirements
- PHP 8.4 or later
ext-ffi- SDL3
- SDL3_ttf
- Apache-2.0 license
Installation
composer require hanhan1978/ffi-sdl3:^0.1
Local development
If you are developing against a local checkout, add a path repository to the
parent project's composer.json and run composer install.
{
"repositories": [
{
"type": "path",
"url": "../ffi-sdl3"
}
]
}
Usage
use SDL3\BlendMode; use SDL3\Color; use SDL3\SDL; use SDL3\TTF\Font; use SDL3\TTF\TTF; use SDL3\Window; use SDL3\WindowFlag; $sdl = SDL::init(); $ttf = TTF::init($sdl); $font = new Font($ttf, '/System/Library/Fonts/Helvetica.ttc', 32.0); $window = new Window($sdl, 'Overlay', 640, 80, [ WindowFlag::Borderless, WindowFlag::AlwaysOnTop, WindowFlag::Transparent, ]); $renderer = $window->createRenderer(); $renderer->setDrawBlendMode(BlendMode::Blend); $surface = $font->renderTextBlended('Hello', new Color(255, 230, 80)); $texture = $renderer->createTextureFromSurface($surface); $surface->destroy();
Library lookup
LibraryFinder searches for SDL3 and SDL3_ttf in this order:
SDL3_LIBRARY_PATHSDL3_TTF_LIBRARY_PATHpkg-config- Common Homebrew paths
Public API
SDL3\SDLSDL3\WindowSDL3\RendererSDL3\TextureSDL3\SurfaceSDL3\RectSDL3\ColorSDL3\WindowFlagSDL3\BlendModeSDL3\Event\*SDL3\TTF\TTFSDL3\TTF\Font
License
Apache-2.0