Skip to content

Commit

Permalink
Improve readme
Browse files Browse the repository at this point in the history
  • Loading branch information
SerafimArts committed Aug 9, 2023
1 parent f2b4790 commit 6a06417
Showing 1 changed file with 12 additions and 19 deletions.
31 changes: 12 additions & 19 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,10 @@ This is a SDL bindings for PHP

## Requirements

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

## Installation
Expand All @@ -28,17 +28,10 @@ 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

- SDL (2.0.12) binaries are already bundled
Additional dependencies:
- Debian-based Linux: `sudo apt install libsdl2-2.0-0 -y`
- MacOS: `brew install sdl2`
- Window: Can be [downloaded from here](https://github.com/libsdl-org/SDL/releases)

## Extensions

Expand All @@ -54,7 +47,7 @@ The library API completely supports and repeats the analogue in the C language.
#### Notes

- API not yet fully documented and may not work in places.
- Low level system functions (such as `SDL_malloc` or `SDL_memcpy`) have been removed.
- Low level and inline functions (such as `SDL_malloc` or `SDL_memcpy`) have been removed.

## Example

Expand All @@ -67,10 +60,10 @@ $sdl = new SDL();

$sdl->SDL_Init(SDL::SDL_INIT_VIDEO);

$window = $sdl->SDL_CreateWindow(
$window = $sdl->SDL_CreateWindow(
'An SDL2 window',
SDL::SDL_WINDOWPOS_UNDEFINED,
SDL::SDL_WINDOWPOS_UNDEFINED,
SDL::SDL_WINDOWPOS_UNDEFINED,
640,
480,
SDL::SDL_WINDOW_OPENGL
Expand All @@ -80,11 +73,11 @@ if ($window === null) {
throw new \Exception(sprintf('Could not create window: %s', $sdl->SDL_GetError()));
}

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

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

0 comments on commit 6a06417

Please sign in to comment.