All Projects → SerafimArts → ffi-sdl

SerafimArts / ffi-sdl

Licence: MIT license
PHP FFI SDL bindings

Programming Languages

PHP
23972 projects - #3 most used programming language

Projects that are alternatives of or similar to ffi-sdl

Chocolate Doom
Chocolate Doom is a Doom source port that is minimalist and historically accurate.
Stars: ✭ 1,052 (+4473.91%)
Mutual labels:  sdl, sdl2
Xray 16
Improved version of the X-Ray Engine, the game engine used in the world-famous S.T.A.L.K.E.R. game series by GSC Game World. Join OpenXRay! ;)
Stars: ✭ 1,806 (+7752.17%)
Mutual labels:  sdl, sdl2
Sdl kitchensink
A Simple SDL2 / FFmpeg library for audio/video playback written in C99
Stars: ✭ 53 (+130.43%)
Mutual labels:  sdl, sdl2
Doomretro
The classic, refined DOOM source port. For Windows PC.
Stars: ✭ 349 (+1417.39%)
Mutual labels:  sdl, sdl2
Haskanoid
A breakout game in Haskell using SDL and FRP, with Wiimote and Kinect support.
Stars: ✭ 242 (+952.17%)
Mutual labels:  sdl, sdl2
Libsdl2pp
C++11 bindings/wrapper for SDL2
Stars: ✭ 385 (+1573.91%)
Mutual labels:  sdl, sdl2
Koreader Base
Base framework offering a Lua scriptable environment for creating document readers
Stars: ✭ 81 (+252.17%)
Mutual labels:  sdl, ffi
EnttPong
Built for EnTT, at the request of the developer as a demo.
Stars: ✭ 51 (+121.74%)
Mutual labels:  sdl, sdl2
Gwork
Skinnable GUI with useful widget collection. Fork of GWEN.
Stars: ✭ 179 (+678.26%)
Mutual labels:  sdl, sdl2
Div Games Studio
Complete cross platform games development package, originally for DOS but now available on modern platforms.
Stars: ✭ 168 (+630.43%)
Mutual labels:  sdl, sdl2
Anese
Another NES Emulator - written for fun & learning - first implementation of wideNES
Stars: ✭ 323 (+1304.35%)
Mutual labels:  sdl, sdl2
gnuboy
latest version of original laguna source, with a handful fixes for modern compilers and systems
Stars: ✭ 70 (+204.35%)
Mutual labels:  sdl, sdl2
Pygame
pygame (the library) is a Free and Open Source python programming language library for making multimedia applications like games built on top of the excellent SDL library. C, Python, Native, OpenGL.
Stars: ✭ 4,164 (+18004.35%)
Mutual labels:  sdl, sdl2
Fortran Sdl2
Fortran 2008 interface bindings to SDL 2.0
Stars: ✭ 18 (-21.74%)
Mutual labels:  sdl, sdl2
Vado
A demo web browser engine written in Haskell
Stars: ✭ 265 (+1052.17%)
Mutual labels:  sdl, sdl2
Supertux
SuperTux source code
Stars: ✭ 1,120 (+4769.57%)
Mutual labels:  sdl, sdl2
zero-graphics
Application framework based on OpenGL ES 2.0. Runs on desktop machines, Android phones and the web
Stars: ✭ 72 (+213.04%)
Mutual labels:  sdl, sdl2
SDL.zig
A shallow wrapper around SDL that provides object API and error handling
Stars: ✭ 102 (+343.48%)
Mutual labels:  sdl, sdl2
Ffmpeg Video Player
An FFmpeg and SDL Tutorial.
Stars: ✭ 149 (+547.83%)
Mutual labels:  sdl, sdl2
nox-decomp
Unofficial Nox (2000) port to Linux using decompiled code from https://playnox.xyz
Stars: ✭ 21 (-8.7%)
Mutual labels:  sdl, sdl2

FFI SDL Bindings

This is a SDL bindings for PHP

Requirements

  • PHP ^8.1
  • ext-ffi
  • Windows, Linux or MacOS
    • Android, iOS, BSD or something else are not supported yet
  • SDL >= 2.0

Installation

Library is available as composer repository and can be installed using the following command in a root of your project.

$ composer require serafim/ffi-sdl

Linux

  • sudo apt install libsdl2-2.0-0 -y

MacOS

  • brew install sdl2

Windows

  • composer require --dev phing/phing
  • vendor/bin/phing serafim/ffi-sdl:download -f vendor/serafim/ffi-sdl/build.xml

Extensions

Documentation

The library API completely supports and repeats the analogue in the C language.

Usage

use Serafim\SDL\SDL2;
use Serafim\SDL\Init;
use Serafim\SDL\Event;
use Serafim\SDL\Kernel\Event\Type;

$sdl = new SDL2(init: Init::VIDEO);

$window = $sdl->SDL_CreateWindow( 
    'An SDL2 window',
    SDL2::SDL_WINDOWPOS_UNDEFINED,
    SDL2::SDL_WINDOWPOS_UNDEFINED, 
    640,
    480,
    SDL2::SDL_WINDOW_OPENGL
);

if ($window === null) {
    throw new \Exception(sprintf('Could not create window: %s', $sdl->SDL_GetError()));
}

$event = $sdl->new(Event::class);
$running = true;

while ($running) {
    $sdl->SDL_PollEvent(SDL2::addr($event));
    if ($event->type === Type::SDL_QUIT) {
        $running = false;
    }
}

$sdl->SDL_DestroyWindow($window);

Remarks

This API not included and is only available through direct FFI calls:

  • From SDL_assert.h: Not required, as assertion is built into PHP.
    • SDL_ReportAssertion
    • SDL_SetAssertionHandler
    • SDL_GetDefaultAssertionHandler
    • SDL_GetAssertionHandler
    • SDL_GetAssertionReport
    • SDL_ResetAssertionReport
  • From SDL_atomic.h: Working with pointers is available only when working at a low level.
    • SDL_AtomicCASPtr
    • SDL_AtomicSetPtr
    • SDL_AtomicGetPtr
Note that the project description data, including the texts, logos, images, and/or trademarks, for each open source project belongs to its rightful owner. If you wish to add or remove any projects, please contact us at [email protected].