1. Go to this page and download the library: Download serafim/ffi-sdl library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
serafim / ffi-sdl example snippets
// Load library from pathname (it may be relative or part of system-dependent path)
$sdl = new Serafim\SDL\SDL(library: __DIR__ . '/path/to/library.so');
// Try to automatically resolve library's pathname
$sdl = new Serafim\SDL\SDL(library: null);
// Use Linux as compile-aware platform
$sdl = new Serafim\SDL\SDL(platform: Serafim\SDL\Platform::LINUX);
// Detect platform automatically
$sdl = new Serafim\SDL\SDL(platform: null);
// Use v2.28.2 from string
$sdl = new Serafim\SDL\SDL(version: '2.28.2');
// Use v2.24.1 from predefined versions constant
$sdl = new Serafim\SDL\SDL(version: \Serafim\SDL\Version::V2_24_1);
// Use latest supported version
$sdl = new Serafim\SDL\SDL(version: \Serafim\SDL\Version::LATEST);
$sdl = new Serafim\SDL\SDL(cache: new Psr16Cache(...));
$pre = new \FFI\Preprocessor\Preprocessor();
$pre->setLogger(new ExampleLogger());
$pre->define('__ANDROID__', '1');
$sdl = new Serafim\SDL\SDL(pre: $pre);
$jni = $sdl->SDL_AndroidGetJNIEnv();
use Serafim\SDL\SDL;
use Serafim\SDL\Event\Type;
$sdl = new SDL();
$sdl->SDL_Init(SDL::SDL_INIT_VIDEO);
$window = $sdl->SDL_CreateWindow(
'An SDL2 window',
SDL::SDL_WINDOWPOS_UNDEFINED,
SDL::SDL_WINDOWPOS_UNDEFINED,
640,
480,
SDL::SDL_WINDOW_OPENGL
);
if ($window === null) {
throw new \Exception(sprintf('Could not create window: %s', $sdl->SDL_GetError()));
}
$event = $sdl->new('SDL_Event');
$running = true;
while ($running) {
$sdl->SDL_PollEvent(FFI::addr($event));
if ($event->type === Type::SDL_QUIT) {
$running = false;
}
}
$sdl->SDL_DestroyWindow($window);
$sdl->SDL_Quit();
Loading please wait ...
Before you can download the PHP files, the dependencies should be resolved. This can take some minutes. Please be patient.