Giter VIP home page Giter VIP logo

raylib-php's Introduction

raylib-php

PHP 8.x bindings for RayLib, a simple and easy-to-use library to learn video g

This is currently a work-in-progress and bindings are not complete and are likely to change.

  • raylib.h - See Not yet implemented
  • raymath.h - TODO Extra mathy stuff
  • raygui.h - TODO API for drawing GUI
  • physac.h - TODO More complex collision detection, more than built-in collision detection

Other PHP RayLib Bindings

  • PHP Raylib FFI - Uses PHP's built-in FFI (Foreign Function Interface) to connect directly to the shared RayLib.dll/.so file. This will be slower than a native binding.

Isn't PHP A Terrible Choice For Games?

Here are some common misconceptions:

  • PHP has no multi-threading. There are native PHP extensions to enable this, pThreads and now a easier way to tackle this issue Parallel - https://github.com/krakjoe/parallel
  • PHP is too slow. Since PHP 7 a lot of things have gotten faster, so it can outperform Python and NodeJS in some area. PHP 8 now include JIT and provides even more performance.
  • Object Oriented Programming in PHP is horrible. Since PHP 5.4+ you get a lot of feature parity and since PHP 7 you now get type checking.
  • Garbage Collection IS ... GARBAGE - Until PHP 7.3 this was true. Running PHP in a tight loop for hours/days on end would hit a point where PHP could spend more time doing GC than anything else. This has been greatly improved.
  • PHP Has No Code Reload - Well not built-in. But, any language with eval can have code reloading. With that said I have code reloading using SoftMocks, but there is also a native PHP extension Runkit7. Code Reload

Example

Texture Image Loading

<?php

use raylib\Color;
use raylib\Draw;
use raylib\Text;
use raylib\Timming;
use raylib\Window;

// Initialization
//--------------------------------------------------------------------------------------
$screenWidth  = 800;
$screenHeight = 450;
$lightGray    = new Color(245, 245, 245, 255);
$gray         = new Color(200, 200, 200, 255);

InitWindow($screenWidth, $screenHeight, "raylib [core] example - basic window");

SetTargetFPS(60);                   // Set our game to run at 60 frames-per-second
//--------------------------------------------------------------------------------------

// Main game loop
while (!WindowShouldClose())        // Detect window close button or ESC key
{
    // Update
    //----------------------------------------------------------------------------------
    // TODO: Update your variables here
    //----------------------------------------------------------------------------------

    // Draw
    //----------------------------------------------------------------------------------

    BeginDrawing();

    ClearBackground($lightGray);

    DrawText("Congrats! You created your first window!", 190, 200, 20, $gray);

    EndDrawing();
    //----------------------------------------------------------------------------------
}

// De-Initialization
//--------------------------------------------------------------------------------------
CloseWindow();        // Close window and OpenGL context
//--------------------------------------------------------------------------------------

Autocomplete

Classes and method calls are available via a stub repository. Its contains all the classes and methods so you get information on everything and anything implemented.

IDE Autocomplete

Install via composer:

composer require joseph-montanez/raylib-php-stub

More information on the stubs can be found here at the repository RayLib-PHP-Stubs

License

raylib-php is licensed under an unmodified zlib/libpng license, which is an OSI-certified, BSD-like license that allows static linking with closed source software. Check LICENSE for further details.

Copyright (c) 2017 Joseph Montanez (@joseph-montanez)

Binary Releases

Windows PHP Extension DLL

API Differences

Raylib-PHP closely follows the RayLib's C-API with a few exceptions due to clashing function names:

  • ImageCopy is renamed to rlImageCopy due to collision with GDI
  • ImageCrop is renamed to rlImageCrop due to collision with GDI
  • Raylib static colors i.e RAYWHITE are renamed to raylib\Color::RAYWHITE()

API Limitation

The PHP RayLib implementation has two glaring limitations.

  • Not all object properties are read and write, for example /raylib/Image::width is a read-only property but /raylib/Vector2::x is a read/write property. When you want to alter a property that is read-only there should be method calls such as /raylib/Image::resize() that will adjust the properties for you.
  • All RayLib object assignment i.e $player->position = $position will not copy the variable but instead link the property. So if you want to copy the data instead, you need to use PHP's clone feature clone i.e $player->position = clone $position.

How To Build PHP Extension

Windows is by far the hardest platform to support and build for. Please use the binaries for Windows instead unless you want to commit fixes to this repo.

Linux

Ubuntu 19.10+

sudo apt-get install -y libx11-dev xorg-dev

Build

phpize
./configure
make

Mac OS

brew install [email protected]

Unfortunately, macOS Brew via brew install [email protected] installs the non thread safe (nts) version which if you want to use parallels the multi-threaded extension for php, you will need to compile and install PHP manually.

git clone https://github.com/php/php-src.git
git checkout php-8.2.8
./buildconf --force
./configure --enable-zts --with-iconv=$(brew --prefix libiconv) --enable-opcache
make
sudo make install

Build

phpize
./configure
make

Windows

Windows requires compiling with PHP sources (Currently Visual Studio 2019 needed), you will still get a .dll in the end.

You will need to also compile RayLib as well. At the time writing I am using Visual Studio 2019 compiler, since PHP 8 requires this. Once compiled paste the following files:

(Please note your Raylib and PHP paths may be different)

Static Libs

C:\src\raylib-4.5.0\projects\VS2022\build\raylib\bin\x64\raylib.lib -> C:\php-sdk\phpdev\vc16\x64\deps\lib\raylib.lib

GLFW Includes

C:\src\raylib-4.5.0\src\external\glfw\include\GLFW\glfw3.h -> C:\php-sdk\phpmaster\vc16\x64\deps\include\GLFW\glfw3.h
C:\src\raylib-4.5.0\src\external\glfw\include\GLFW\glfw3native.h -> C:\php-sdk\phpmaster\vc16\x64\deps\include\GLFW\glfw3native.h

RayLib Includes

C:\src\raylib-4.5.0\cmake-build-debug\src\raudio.h -> C:\php-sdk\phpmaster\vc15\x64\deps\include\raudio.h
C:\src\raylib-4.5.0\cmake-build-debug\src\raylib.h -> C:\php-sdk\phpmaster\vc15\x64\deps\include\raylib.h
C:\src\raylib-4.5.0\cmake-build-debug\src\raymath.h -> C:\php-sdk\phpmaster\vc15\x64\deps\include\raymath.h
C:\src\raylib-4.5.0\cmake-build-debug\src\rlgl.h -> C:\php-sdk\phpmaster\vc15\x64\deps\include\rlgl.h

Once you have PHP & Raylib setup you can then compile the extension

%comspec% /k "C:\Program Files (x86)\Microsoft Visual Studio\2019\BuildTools\VC\Auxiliary\Build\vcvars64.bat"
cd C:/php-sdk
phpsdk-vs16-x64.bat
cd phpdev\vs16\x64\raylib-php
..\php-8.2.8-devel-vs16-x64-ts\phpize.bat
configure
nmake

How To Run raylib PHP Extension

MacOS & Linux

php -dextension=modules/raylib.so examples/textures/textures_image_loading.php

Windows

php-win.exe -dextension=x64/Release_TS/php_raylib.dll examples/textures/textures_image_loading.php

Not Yet Implemented

These are methods that may be able to work later on with more development. For example callbacks are generally not supported yet, but can be later.

  • GetRenderWidth
  • GetRenderHeight
  • TraceLog
  • SetTraceLogCallback
  • SetSaveFileDataCallback
  • SetLoadFileTextCallback
  • SetSaveFileTextCallback
  • SetLoadFileDataCallback
  • SaveFileData
  • MemFree
  • SetWindowOpacity
  • GetPixelColor
  • SetPixelColor
  • GenImageFontAtlas
  • UpdateMeshBuffer
  • SetShaderValue
  • SetShaderValueV
  • UpdateTexture
  • UpdateTextureRec
  • UpdateSound
  • UpdateAudioStream
  • SetAudioStreamCallback
  • AttachAudioStreamProcessor
  • DetachAudioStreamProcessor
  • AttachAudioMixedProcessor
  • DetachAudioMixedProcessor

Benchmarks

Using the Bunnymark textures 100,000 max, 144 frames per second. Any language / extension that hits 85 FPS is the limit of the GPU of the test machine. All run with "Apple" for kind (M1/M2) native architect.

M1 Mac Mini - 16GB RAM - macOS Ventura 13.4.1

  • Compiled - Must be compiled to a binary to run the application
  • Dynamic - Can be interpreted for immediately running the application
Language Typed Extension FPS Memory CPU GPU
C (CMake Release) compiled Native 85 FPS 47 MB 64% 90%
Zig 0.11.0 (ReleaseFast) (Arena) compiled raylib.zig 85 FPS 54 MB 60% 90%
Rust (Release) compiled bitten2up/raylib-rs 85 FPS 48 MB 67% 90%
Go 2.20 (Release) compiled gen2brain/raylib-go 85 FPS 55 MB 73% 90%
C# 11 .Net 7 compiled raylib-cs 85 FPS 68 MB 75% 90%
Nim 2.0 (Release) compiled planetis-m/naylib 75 FPS 49 MB 70% 90%
Haxe 4.3.1 (no-debug, HXCPP_ARM64)* compiled raylib-haxe 47 FPS 128 MB 87% 66%
NodeJS 20 dynamic node-raylib 44 FPS 134 MB 100% 80%
PHP 8.2 (Jit) dynamic raylib-php 41 FPS 257 MB 100% 60%
PHP 8.2 dynamic raylib-php 27 FPS 242 MB 100% 57%
Ruby 3.2.2 dynamic vaiorabbit/raylib-bindings 11 FPS 144 MB 100% 50%
Python 3.11** dynamic raylib-python-cffi 10 FPS 100 MB 100% 35%
Lua (LuaJIT 2.1.0-beta3) (-O2)*** dynamic TSnake41/raylib-lua 5 FPS 113 MB 100% 31%
  1. *Raylib-Haxe does not compile out of the box and fixes are needed to run.

  2. **Python - raylib-python-cffi Uses FFI which is slower than a ctypes integration

  3. ***TSnake41/raylib-lua Does not currently compile on Arm64 (M1/M2) out of the box, and JIT isn't working as expected on this platform as it should be faster.

Honorable mentions:

  • PyGame 2.5.1: PyGame is completely software rendered and thus extremely slow, I wasn't even getting 1 FPS. You'll need to hand roll your own OpenGL rendering solution or leverage an additional library to get hardware acceleration. I tried sprite groups and no improvements.
  • DragonRuby Game Toolkit 5.5: DragonRuby is as slow as raylib-python-cffi coming in at 10 FPS. This is because DragonRuby does not have batch rendering so if there are 100,000 sprites, that's 100,000 draw calls. It also forces you to render at 1280x720 at 60 FPS, it's not possible to change this. There are render targets, but this doesn't reduce offscreen rendering.

raylib-php's People

Contributors

jm-comentum avatar joseph-montanez avatar nawarian avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

raylib-php's Issues

Binary ext error

Version: PHP 7.4
Os: Windows 10

It says ext-parallel.dll not found, but i did everything right like this same at ext-raylib.dll

Audio

Hey I cant seem to figure out how to make sound work, could I have some help please?

Issue compiling against PHP 7.4 on MacOS

When compiling against the PHP 7.4 version on Mac OS the process fails during make due to the following errors:

/Users/dpock/GitProjects/raylib-php/raylib-camera3d.c:526:9: error: implicit declaration of function 'Z_PARAM_OBJ_OF_CLASS_OR_NULL' is invalid in
      C99 [-Werror,-Wimplicit-function-declaration]
        Z_PARAM_OBJ_OF_CLASS_OR_NULL(position, php_raylib_vector3_ce)
        ^
/Users/dpock/GitProjects/raylib-php/raylib-camera3d.c:526:70: error: expected ';' after expression
        Z_PARAM_OBJ_OF_CLASS_OR_NULL(position, php_raylib_vector3_ce)

/Users/dpock/GitProjects/raylib-php/raylib-camera3d.c:717:9: error: implicit declaration of function 'Z_PARAM_OBJ_OF_CLASS' is invalid in C99
      [-Werror,-Wimplicit-function-declaration]
        Z_PARAM_OBJ_OF_CLASS(mousePosition, php_raylib_vector2_ce)

/Users/dpock/GitProjects/raylib-php/raylib-camera3d.c:784:9: error: implicit declaration of function 'Z_PARAM_OBJ_OF_CLASS' is invalid in C99
      [-Werror,-Wimplicit-function-declaration]
        Z_PARAM_OBJ_OF_CLASS(position, php_raylib_vector3_ce)
        ^
/Users/dpock/GitProjects/raylib-php/raylib-camera3d.c:785:9: error: expression is not assignable
        Z_PARAM_LONG(width)

However when using PHP 8.0 this extension makes properly and can be subsequently installed and activated.

I found some incompatibility..

Hi, I'm trying your framework with php and linux mint.
I am sad to say raylib release a new version, the 3.5, and there's a couple of incompatibilities with your framework. I was able to quick fix but I think some funcions would be redefinied or deleted because the changelog of november is about 150 lines of added / deleted functionalities.
Finally I was able, after a quick fix on code, to compile the .so library and start build a game, but still, some functions are not working perfectly.
Good work btw!

Greetings from Italy.

configure: error: pkg-config not found

I'm trying to buld raylib-php on Raspberry Pi 4.
I get the following error after running ./configure

checking for raylib support... yes, shared
checking whether to enable raylib support... yes, shared
checking for pkg-config... /usr/bin/pkg-config
checking for libraylib... configure: error: pkg-config not found

Please advise.

Supported PHP Versions

I came to report an issue while compiling the extension using php 7.3.16.

  1. The ZEND_THIS constant
    Seems like the constant ZEND_THIS is not available there. Before this value used to be fetched with getThis() in this repo. With php 7.4 it works. Replacing ZEND_THIS with getThis() solves the issue on php 7.3.

  2. The zend_std_write_property() call
    Another thing quite common in this repo is the following line:

value = zend_std_write_property(object, member, value, cache_slot);

This happens, for example, here:

value = zend_std_write_property(object, member, value, cache_slot);

This seems to be problematic on php 7.3.16 as zend_std_write_property() returns void and value is a zval, passed for writing as the third parameter. Removing the assignment seems to solve the issue.

Note: I'm running MacOS Catalina. But this seems to be independent from build environment.


What is the minimum version supported?

I'd be happy to send out some pull requests if php 7.3 is supposed to be supported. I'm not a C expert but I think I can help a bit there.

Cheers!

Error when executing make command in Ubuntu 20.04

Hello,

I really liked the project with PHP support, could you help me please?

I am trying to run the make command in raylib-php, but the following errors are occurring that make it impossible to execute the project successfully, how can I revolve them?

PS: I'm running PHP 8.0.2

/var/www/html/raylib-php/raylib-texture.c:5394:66: error: ‘FILTER_TRILINEAR’ undeclared (first use in this function); did you mean ‘FILTER_BILINEAR’?
  594 | REGISTER_RAYLIB_TEXTURE_CLASS_CONST_LONG ("FILTER_TRILINEAR", FILTER_TRILINEAR);

/var/www/html/raylib-php/raylib-texture.c:318:107: note: in definition of macro ‘REGISTER_RAYLIB_TEXTURE_CLASS_CONST_LONG’
  318 | zend_declare_class_constant_long (php_raylib_texture_ce, const_name, sizeof (const_name) -1, (zend_long) value);

/var/www/html/raylib-php/raylib-texture.c 16:94:66: note: each undeclared identifier is reported only once for each function it appears in
  594 | REGISTER_RAYLIB_TEXTURE_CLASS_CONST_LONG ("FILTER_TRILINEAR", FILTER_TRILINEAR);

/var/www/html/raylib-php/raylib-texture.c:318:107: note: in definition of macro ‘REGISTER_RAYLIB_TEXTURE_CLASS_CONST_LONG’
  318 | zend_declare_class_constant_long (php_raylib_texture_ce, const_name, sizeof (const_name) -1, (zend_long) 

/var/www/html/raylib-php/raylib-texture.c:5395:71: error: ‘FILTER_ANISOTROPIC_4X’ undeclared (first use in this function); did you mean ‘TEXTURE_FILTER_ANISOTROPIC_4X’?
  595 | REGISTER_RAYLIB_TEXTURE_CLASS_CONST_LONG ("FILTER_ANISOTROPIC_4X", FILTER_ANISOTROPIC_4X);
                                              
/var/www/html/raylib-php/raylib-texture.c:318:107: note: in definition of macro ‘REGISTER_RAYLIB_TEXTURE_CLASS_CONST_LONG’
  318 | zend_declare_class_constant_long (php_raylib_texture_ce, const_name, sizeof (const_name) -1, (zend_long) 

/var/www/html/raylib-php/raylib-texture.c/1696:71: error: ‘FILTER_ANISOTROPIC_8X’ undeclared (first use in this function); did you mean ‘TEXTURE_FILTER_ANISOTROPIC_8X’?
  596 | REGISTER_RAYLIB_TEXTURE_CLASS_CONST_LONG ("FILTER_ANISOTROPIC_8X", FILTER_ANISOTROPIC_8X);

/var/www/html/raylib-php/raylib-texture.c:318:107: note: in definition of macro ‘REGISTER_RAYLIB_TEXTURE_CLASS_CONST_LONG’
  318 | zend_declare_class_constant_long (php_raylib_texture_ce, const_name, sizeof (const_name) -1, (zend_long) 

/var/www/html/raylib-php/raylib-texture.c:5397:72: error: ‘FILTER_ANISOTROPIC_16X’ undeclared (first use in this function); did you mean ‘TEXTURE_FILTER_ANISOTROPIC_16X’?
  597 | REGISTER_RAYLIB_TEXTURE_CLASS_CONST_LONG ("FILTER_ANISOTROPIC_16X", 

/var/www/html/raylib-php/raylib-texture.c:318:107: note: in definition of macro ‘REGISTER_RAYLIB_TEXTURE_CLASS_CONST_LONG’
  318 | zend_declare_class_constant_long (php_raylib_texture_ce, const_name, sizeof (const_name) -1, (zend_long) 

/var/www/html/raylib-php/raylib-texture.c:600:61: error: ‘WRAP_REPEAT’ undeclared (first use in this function)
  600 | REGISTER_RAYLIB_TEXTURE_CLASS_CONST_LONG ("WRAP_REPEAT", WRAP_REPEAT);

/var/www/html/raylib-php/raylib-texture.c:318:107: note: in definition of macro ‘REGISTER_RAYLIB_TEXTURE_CLASS_CONST_LONG’
  318 | zend_declare_class_constant_long (php_raylib_texture_ce, const_name, sizeof (const_name) -1, (zend_long) 

/var/www/html/raylib-php/raylib-texture.c:601:60: error: ‘WRAP_CLAMP’ undeclared (first use in this function)
  601 | REGISTER_RAYLIB_TEXTURE_CLASS_CONST_LONG ("WRAP_CLAMP", 

/var/www/html/raylib-php/raylib-texture.c:318:107: note: in definition of macro ‘REGISTER_RAYLIB_TEXTURE_CLASS_CONST_LONG’
  318 

zend_declare_class_constant_long (php_raylib_texture_ce, const_name, sizeof (const_name) -1, (zend_long) value); 

Composer

Can haz composer require Raylib???

PHP 8 Support

This will force PHP 5.6 to no longer be possible, but also provide a large code clean up.

  • Argument Info - Now required or else warning hell happens, all functions must be revamped to include this. This is a large change.
  • Remove thread safety macros
  • Add semi colons to returns
  • Revamp properties - property read and write cause segment faults

Raylib 4 & PHP8

Hello, is there a way to help out to revive the project?

I get various errors on REGISTER_NS_LONG_CONSTANT while compiling, i thought adding some new constants should be something i can manage in C but then i have no idea what to choose and what is the intended way of this project.

Just for info my build log

/bin/sh /home/xuedi/Projects/libs/raylib-php/libtool --mode=compile cc -I. -I/home/xuedi/Projects/libs/raylib-php -I/home/xuedi/Projects/libs/raylib-php/include -I/home/xuedi/Projects/libs/raylib-php/main -I/home/xuedi/Projects/libs/raylib-php -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib  -DHAVE_CONFIG_H  -g -O2    -c /home/xuedi/Projects/libs/raylib-php/raylib.c -o raylib.lo 
 cc -I. -I/home/xuedi/Projects/libs/raylib-php -I/home/xuedi/Projects/libs/raylib-php/include -I/home/xuedi/Projects/libs/raylib-php/main -I/home/xuedi/Projects/libs/raylib-php -I/usr/include/php -I/usr/include/php/main -I/usr/include/php/TSRM -I/usr/include/php/Zend -I/usr/include/php/ext -I/usr/include/php/ext/date/lib -DHAVE_CONFIG_H -g -O2 -c /home/xuedi/Projects/libs/raylib-php/raylib.c  -fPIC -DPIC -o .libs/raylib.o
In file included from /home/xuedi/Projects/libs/raylib-php/raylib.c:52:
/home/xuedi/Projects/libs/raylib-php/raylib-charinfo.h:12:5: error: unknown type name ‘CharInfo’
   12 |     CharInfo charinfo;
      |     ^~~~~~~~
In file included from /usr/include/php/main/php.h:439,
                 from /home/xuedi/Projects/libs/raylib-php/php_raylib.h:30,
                 from /home/xuedi/Projects/libs/raylib-php/raylib.c:25:
/home/xuedi/Projects/libs/raylib-php/raylib.c: In function ‘zm_startup_raylib’:
/home/xuedi/Projects/libs/raylib-php/raylib.c:236:80: error: ‘UNCOMPRESSED_GRAYSCALE’ undeclared (first use in this function); did you mean ‘PIXELFORMAT_UNCOMPRESSED_GRAYSCALE’?
  236 |     REGISTER_NS_LONG_CONSTANT("raylib\\PixelFormat", "UNCOMPRESSED_GRAYSCALE", UNCOMPRESSED_GRAYSCALE, CONST_CS | CONST_PERSISTENT);
      |                                                                                ^~~~~~~~~~~~~~~~~~~~~~
/usr/include/php/Zend/zend_constants.h:57:146: note: in definition of macro ‘REGISTER_NS_LONG_CONSTANT’
   57 | #define REGISTER_NS_LONG_CONSTANT(ns, name, lval, flags)  zend_register_long_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (lval), (flags), module_number)
      |                                                                                                                                                  ^~~~
/home/xuedi/Projects/libs/raylib-php/raylib.c:236:80: note: each undeclared identifier is reported only once for each function it appears in
  236 |     REGISTER_NS_LONG_CONSTANT("raylib\\PixelFormat", "UNCOMPRESSED_GRAYSCALE", UNCOMPRESSED_GRAYSCALE, CONST_CS | CONST_PERSISTENT);
      |                                                                                ^~~~~~~~~~~~~~~~~~~~~~
/usr/include/php/Zend/zend_constants.h:57:146: note: in definition of macro ‘REGISTER_NS_LONG_CONSTANT’
   57 | #define REGISTER_NS_LONG_CONSTANT(ns, name, lval, flags)  zend_register_long_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (lval), (flags), module_number)
      |                                                                                                                                                  ^~~~
/home/xuedi/Projects/libs/raylib-php/raylib.c:237:81: error: ‘UNCOMPRESSED_GRAY_ALPHA’ undeclared (first use in this function); did you mean ‘PIXELFORMAT_UNCOMPRESSED_GRAY_ALPHA’?
  237 |     REGISTER_NS_LONG_CONSTANT("raylib\\PixelFormat", "UNCOMPRESSED_GRAY_ALPHA", UNCOMPRESSED_GRAY_ALPHA, CONST_CS | CONST_PERSISTENT);
      |                                                                                 ^~~~~~~~~~~~~~~~~~~~~~~
/usr/include/php/Zend/zend_constants.h:57:146: note: in definition of macro ‘REGISTER_NS_LONG_CONSTANT’
   57 | #define REGISTER_NS_LONG_CONSTANT(ns, name, lval, flags)  zend_register_long_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (lval), (flags), module_number)
      |                                                                                                                                                  ^~~~
/home/xuedi/Projects/libs/raylib-php/raylib.c:238:77: error: ‘UNCOMPRESSED_R5G6B5’ undeclared (first use in this function)
  238 |     REGISTER_NS_LONG_CONSTANT("raylib\\PixelFormat", "UNCOMPRESSED_R5G6B5", UNCOMPRESSED_R5G6B5, CONST_CS | CONST_PERSISTENT);
      |                                                                             ^~~~~~~~~~~~~~~~~~~
/usr/include/php/Zend/zend_constants.h:57:146: note: in definition of macro ‘REGISTER_NS_LONG_CONSTANT’
   57 | #define REGISTER_NS_LONG_CONSTANT(ns, name, lval, flags)  zend_register_long_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (lval), (flags), module_number)
      |                                                                                                                                                  ^~~~
/home/xuedi/Projects/libs/raylib-php/raylib.c:239:77: error: ‘UNCOMPRESSED_R8G8B8’ undeclared (first use in this function)
  239 |     REGISTER_NS_LONG_CONSTANT("raylib\\PixelFormat", "UNCOMPRESSED_R8G8B8", UNCOMPRESSED_R8G8B8, CONST_CS | CONST_PERSISTENT);
      |                                                                             ^~~~~~~~~~~~~~~~~~~
/usr/include/php/Zend/zend_constants.h:57:146: note: in definition of macro ‘REGISTER_NS_LONG_CONSTANT’
   57 | #define REGISTER_NS_LONG_CONSTANT(ns, name, lval, flags)  zend_register_long_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (lval), (flags), module_number)
      |                                                                                                                                                  ^~~~
/home/xuedi/Projects/libs/raylib-php/raylib.c:240:79: error: ‘UNCOMPRESSED_R5G5B5A1’ undeclared (first use in this function)
  240 |     REGISTER_NS_LONG_CONSTANT("raylib\\PixelFormat", "UNCOMPRESSED_R5G5B5A1", UNCOMPRESSED_R5G5B5A1, CONST_CS | CONST_PERSISTENT);
      |                                                                               ^~~~~~~~~~~~~~~~~~~~~
/usr/include/php/Zend/zend_constants.h:57:146: note: in definition of macro ‘REGISTER_NS_LONG_CONSTANT’
   57 | #define REGISTER_NS_LONG_CONSTANT(ns, name, lval, flags)  zend_register_long_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (lval), (flags), module_number)
      |                                                                                                                                                  ^~~~
/home/xuedi/Projects/libs/raylib-php/raylib.c:241:79: error: ‘UNCOMPRESSED_R4G4B4A4’ undeclared (first use in this function)
  241 |     REGISTER_NS_LONG_CONSTANT("raylib\\PixelFormat", "UNCOMPRESSED_R4G4B4A4", UNCOMPRESSED_R4G4B4A4, CONST_CS | CONST_PERSISTENT);
      |                                                                               ^~~~~~~~~~~~~~~~~~~~~
/usr/include/php/Zend/zend_constants.h:57:146: note: in definition of macro ‘REGISTER_NS_LONG_CONSTANT’
   57 | #define REGISTER_NS_LONG_CONSTANT(ns, name, lval, flags)  zend_register_long_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (lval), (flags), module_number)
      |                                                                                                                                                  ^~~~
/home/xuedi/Projects/libs/raylib-php/raylib.c:242:79: error: ‘UNCOMPRESSED_R8G8B8A8’ undeclared (first use in this function)
  242 |     REGISTER_NS_LONG_CONSTANT("raylib\\PixelFormat", "UNCOMPRESSED_R8G8B8A8", UNCOMPRESSED_R8G8B8A8, CONST_CS | CONST_PERSISTENT);
      |                                                                               ^~~~~~~~~~~~~~~~~~~~~
/usr/include/php/Zend/zend_constants.h:57:146: note: in definition of macro ‘REGISTER_NS_LONG_CONSTANT’
   57 | #define REGISTER_NS_LONG_CONSTANT(ns, name, lval, flags)  zend_register_long_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (lval), (flags), module_number)
      |                                                                                                                                                  ^~~~
/home/xuedi/Projects/libs/raylib-php/raylib.c:243:74: error: ‘UNCOMPRESSED_R32’ undeclared (first use in this function)
  243 |     REGISTER_NS_LONG_CONSTANT("raylib\\PixelFormat", "UNCOMPRESSED_R32", UNCOMPRESSED_R32, CONST_CS | CONST_PERSISTENT);
      |                                                                          ^~~~~~~~~~~~~~~~
/usr/include/php/Zend/zend_constants.h:57:146: note: in definition of macro ‘REGISTER_NS_LONG_CONSTANT’
   57 | #define REGISTER_NS_LONG_CONSTANT(ns, name, lval, flags)  zend_register_long_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (lval), (flags), module_number)
      |                                                                                                                                                  ^~~~
/home/xuedi/Projects/libs/raylib-php/raylib.c:244:80: error: ‘UNCOMPRESSED_R32G32B32’ undeclared (first use in this function); did you mean ‘PIXELFORMAT_UNCOMPRESSED_R32G32B32’?
  244 |     REGISTER_NS_LONG_CONSTANT("raylib\\PixelFormat", "UNCOMPRESSED_R32G32B32", UNCOMPRESSED_R32G32B32, CONST_CS | CONST_PERSISTENT);
      |                                                                                ^~~~~~~~~~~~~~~~~~~~~~
/usr/include/php/Zend/zend_constants.h:57:146: note: in definition of macro ‘REGISTER_NS_LONG_CONSTANT’
   57 | #define REGISTER_NS_LONG_CONSTANT(ns, name, lval, flags)  zend_register_long_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (lval), (flags), module_number)
      |                                                                                                                                                  ^~~~
/home/xuedi/Projects/libs/raylib-php/raylib.c:245:83: error: ‘UNCOMPRESSED_R32G32B32A32’ undeclared (first use in this function); did you mean ‘PIXELFORMAT_UNCOMPRESSED_R32G32B32A32’?
  245 |     REGISTER_NS_LONG_CONSTANT("raylib\\PixelFormat", "UNCOMPRESSED_R32G32B32A32", UNCOMPRESSED_R32G32B32A32, CONST_CS | CONST_PERSISTENT);
      |                                                                                   ^~~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/php/Zend/zend_constants.h:57:146: note: in definition of macro ‘REGISTER_NS_LONG_CONSTANT’
   57 | #define REGISTER_NS_LONG_CONSTANT(ns, name, lval, flags)  zend_register_long_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (lval), (flags), module_number)
      |                                                                                                                                                  ^~~~
/home/xuedi/Projects/libs/raylib-php/raylib.c:246:77: error: ‘COMPRESSED_DXT1_RGB’ undeclared (first use in this function)
  246 |     REGISTER_NS_LONG_CONSTANT("raylib\\PixelFormat", "COMPRESSED_DXT1_RGB", COMPRESSED_DXT1_RGB, CONST_CS | CONST_PERSISTENT);
      |                                                                             ^~~~~~~~~~~~~~~~~~~
/usr/include/php/Zend/zend_constants.h:57:146: note: in definition of macro ‘REGISTER_NS_LONG_CONSTANT’
   57 | #define REGISTER_NS_LONG_CONSTANT(ns, name, lval, flags)  zend_register_long_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (lval), (flags), module_number)
      |                                                                                                                                                  ^~~~
/home/xuedi/Projects/libs/raylib-php/raylib.c:247:78: error: ‘COMPRESSED_DXT1_RGBA’ undeclared (first use in this function)
  247 |     REGISTER_NS_LONG_CONSTANT("raylib\\PixelFormat", "COMPRESSED_DXT1_RGBA", COMPRESSED_DXT1_RGBA, CONST_CS | CONST_PERSISTENT);
      |                                                                              ^~~~~~~~~~~~~~~~~~~~
/usr/include/php/Zend/zend_constants.h:57:146: note: in definition of macro ‘REGISTER_NS_LONG_CONSTANT’
   57 | #define REGISTER_NS_LONG_CONSTANT(ns, name, lval, flags)  zend_register_long_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (lval), (flags), module_number)
      |                                                                                                                                                  ^~~~
/home/xuedi/Projects/libs/raylib-php/raylib.c:248:78: error: ‘COMPRESSED_DXT3_RGBA’ undeclared (first use in this function)
  248 |     REGISTER_NS_LONG_CONSTANT("raylib\\PixelFormat", "COMPRESSED_DXT3_RGBA", COMPRESSED_DXT3_RGBA, CONST_CS | CONST_PERSISTENT);
      |                                                                              ^~~~~~~~~~~~~~~~~~~~
/usr/include/php/Zend/zend_constants.h:57:146: note: in definition of macro ‘REGISTER_NS_LONG_CONSTANT’
   57 | #define REGISTER_NS_LONG_CONSTANT(ns, name, lval, flags)  zend_register_long_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (lval), (flags), module_number)
      |                                                                                                                                                  ^~~~
/home/xuedi/Projects/libs/raylib-php/raylib.c:249:78: error: ‘COMPRESSED_DXT5_RGBA’ undeclared (first use in this function)
  249 |     REGISTER_NS_LONG_CONSTANT("raylib\\PixelFormat", "COMPRESSED_DXT5_RGBA", COMPRESSED_DXT5_RGBA, CONST_CS | CONST_PERSISTENT);
      |                                                                              ^~~~~~~~~~~~~~~~~~~~
/usr/include/php/Zend/zend_constants.h:57:146: note: in definition of macro ‘REGISTER_NS_LONG_CONSTANT’
   57 | #define REGISTER_NS_LONG_CONSTANT(ns, name, lval, flags)  zend_register_long_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (lval), (flags), module_number)
      |                                                                                                                                                  ^~~~
/home/xuedi/Projects/libs/raylib-php/raylib.c:250:77: error: ‘COMPRESSED_ETC1_RGB’ undeclared (first use in this function)
  250 |     REGISTER_NS_LONG_CONSTANT("raylib\\PixelFormat", "COMPRESSED_ETC1_RGB", COMPRESSED_ETC1_RGB, CONST_CS | CONST_PERSISTENT);
      |                                                                             ^~~~~~~~~~~~~~~~~~~
/usr/include/php/Zend/zend_constants.h:57:146: note: in definition of macro ‘REGISTER_NS_LONG_CONSTANT’
   57 | #define REGISTER_NS_LONG_CONSTANT(ns, name, lval, flags)  zend_register_long_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (lval), (flags), module_number)
      |                                                                                                                                                  ^~~~
/home/xuedi/Projects/libs/raylib-php/raylib.c:251:77: error: ‘COMPRESSED_ETC2_RGB’ undeclared (first use in this function)
  251 |     REGISTER_NS_LONG_CONSTANT("raylib\\PixelFormat", "COMPRESSED_ETC2_RGB", COMPRESSED_ETC2_RGB, CONST_CS | CONST_PERSISTENT);
      |                                                                             ^~~~~~~~~~~~~~~~~~~
/usr/include/php/Zend/zend_constants.h:57:146: note: in definition of macro ‘REGISTER_NS_LONG_CONSTANT’
   57 | #define REGISTER_NS_LONG_CONSTANT(ns, name, lval, flags)  zend_register_long_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (lval), (flags), module_number)
      |                                                                                                                                                  ^~~~
/home/xuedi/Projects/libs/raylib-php/raylib.c:252:82: error: ‘COMPRESSED_ETC2_EAC_RGBA’ undeclared (first use in this function); did you mean ‘PIXELFORMAT_COMPRESSED_ETC2_EAC_RGBA’?
  252 |     REGISTER_NS_LONG_CONSTANT("raylib\\PixelFormat", "COMPRESSED_ETC2_EAC_RGBA", COMPRESSED_ETC2_EAC_RGBA, CONST_CS | CONST_PERSISTENT);
      |                                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/php/Zend/zend_constants.h:57:146: note: in definition of macro ‘REGISTER_NS_LONG_CONSTANT’
   57 | #define REGISTER_NS_LONG_CONSTANT(ns, name, lval, flags)  zend_register_long_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (lval), (flags), module_number)
      |                                                                                                                                                  ^~~~
/home/xuedi/Projects/libs/raylib-php/raylib.c:253:77: error: ‘COMPRESSED_PVRT_RGB’ undeclared (first use in this function)
  253 |     REGISTER_NS_LONG_CONSTANT("raylib\\PixelFormat", "COMPRESSED_PVRT_RGB", COMPRESSED_PVRT_RGB, CONST_CS | CONST_PERSISTENT);
      |                                                                             ^~~~~~~~~~~~~~~~~~~
/usr/include/php/Zend/zend_constants.h:57:146: note: in definition of macro ‘REGISTER_NS_LONG_CONSTANT’
   57 | #define REGISTER_NS_LONG_CONSTANT(ns, name, lval, flags)  zend_register_long_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (lval), (flags), module_number)
      |                                                                                                                                                  ^~~~
/home/xuedi/Projects/libs/raylib-php/raylib.c:254:78: error: ‘COMPRESSED_PVRT_RGBA’ undeclared (first use in this function)
  254 |     REGISTER_NS_LONG_CONSTANT("raylib\\PixelFormat", "COMPRESSED_PVRT_RGBA", COMPRESSED_PVRT_RGBA, CONST_CS | CONST_PERSISTENT);
      |                                                                              ^~~~~~~~~~~~~~~~~~~~
/usr/include/php/Zend/zend_constants.h:57:146: note: in definition of macro ‘REGISTER_NS_LONG_CONSTANT’
   57 | #define REGISTER_NS_LONG_CONSTANT(ns, name, lval, flags)  zend_register_long_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (lval), (flags), module_number)
      |                                                                                                                                                  ^~~~
/home/xuedi/Projects/libs/raylib-php/raylib.c:255:82: error: ‘COMPRESSED_ASTC_4x4_RGBA’ undeclared (first use in this function); did you mean ‘PIXELFORMAT_COMPRESSED_ASTC_4x4_RGBA’?
  255 |     REGISTER_NS_LONG_CONSTANT("raylib\\PixelFormat", "COMPRESSED_ASTC_4x4_RGBA", COMPRESSED_ASTC_4x4_RGBA, CONST_CS | CONST_PERSISTENT);
      |                                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/php/Zend/zend_constants.h:57:146: note: in definition of macro ‘REGISTER_NS_LONG_CONSTANT’
   57 | #define REGISTER_NS_LONG_CONSTANT(ns, name, lval, flags)  zend_register_long_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (lval), (flags), module_number)
      |                                                                                                                                                  ^~~~
/home/xuedi/Projects/libs/raylib-php/raylib.c:256:82: error: ‘COMPRESSED_ASTC_8x8_RGBA’ undeclared (first use in this function); did you mean ‘PIXELFORMAT_COMPRESSED_ASTC_8x8_RGBA’?
  256 |     REGISTER_NS_LONG_CONSTANT("raylib\\PixelFormat", "COMPRESSED_ASTC_8x8_RGBA", COMPRESSED_ASTC_8x8_RGBA, CONST_CS | CONST_PERSISTENT);
      |                                                                                  ^~~~~~~~~~~~~~~~~~~~~~~~
/usr/include/php/Zend/zend_constants.h:57:146: note: in definition of macro ‘REGISTER_NS_LONG_CONSTANT’
   57 | #define REGISTER_NS_LONG_CONSTANT(ns, name, lval, flags)  zend_register_long_constant(ZEND_NS_NAME(ns, name), sizeof(ZEND_NS_NAME(ns, name))-1, (lval), (flags), module_number)
      |                                                                                                                                                  ^~~~
make: *** [Makefile:209: raylib.lo] Error 1

Move to Type Checked Parameters

Right now most parameters that take in an object are not type checked, only the stub has the type defined.

For example:

Z_PARAM_ZVAL(image)

Is used to pull in an \raylib\Image object. However you could pass in any object and crash your program. Instead I can move to type checking i.e:

Z_PARAM_OBJ_OF_CLASS(image, php_raylib_image_ce)

This will correctly those an error in PHP that the object is not correct.

Camera 2D target doesn't work

When trying to create a 2d camera following an entity, the camera doesn't follow.
the exemple on the repo doesn't work either

Raylib Constant Aliases Missing

Raylib has a handful of aliases missing for backwards compatibility. These are in the define section of the json file.

    {
      "name": "MOUSE_LEFT_BUTTON",
      "type": "UNKNOWN",
      "value": "MOUSE_BUTTON_LEFT",
      "description": ""
    },
    {
      "name": "MOUSE_RIGHT_BUTTON",
      "type": "UNKNOWN",
      "value": "MOUSE_BUTTON_RIGHT",
      "description": ""
    },
    {
      "name": "MOUSE_MIDDLE_BUTTON",
      "type": "UNKNOWN",
      "value": "MOUSE_BUTTON_MIDDLE",
      "description": ""
    },
    {
      "name": "MATERIAL_MAP_DIFFUSE",
      "type": "UNKNOWN",
      "value": "MATERIAL_MAP_ALBEDO",
      "description": ""
    },
    {
      "name": "MATERIAL_MAP_SPECULAR",
      "type": "UNKNOWN",
      "value": "MATERIAL_MAP_METALNESS",
      "description": ""
    },
    {
      "name": "SHADER_LOC_MAP_DIFFUSE",
      "type": "UNKNOWN",
      "value": "SHADER_LOC_MAP_ALBEDO",
      "description": ""
    },
    {
      "name": "SHADER_LOC_MAP_SPECULAR",
      "type": "UNKNOWN",
      "value": "SHADER_LOC_MAP_METALNESS",
      "description": ""
    }

So MATERIAL_MAP_DIFFUSE would map to raylib\MaterialMapIndex\MATERIAL_MAP_ALBEDO.

RayLib 3.5 Support

Initial work is done to change the implementation as needed to work off RayLib 3.5, but a full audit of the changelog is still in process.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.