raylib-php icon indicating copy to clipboard operation
raylib-php copied to clipboard

Raylib 4 & PHP8

Open xuedi opened this issue 4 years ago • 4 comments

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

xuedi avatar Dec 24 '21 10:12 xuedi

I've just had a go at this.. wasn't expect much but I got way further than expected.. Most of the constants in question have been prepened with TEXTURE_ and some other changes. I'm too deep to continue now.

Before this I just tried cloning this project, and cloning an older release and runnign docker-composer up.. but that produced errros.. so I've been playing about.

Camera3D's type parameter has been renamed to projection.

https://gamefromscratch.com/raylib-4-released/ many of the CONSTANTS where easily found to have TEXTURE_ prepended to them.

struct CharInfo was renamed to struct GlyphInfo ...

I have edited files I got directly from the zip, so don't have a diff readily at hand.

for now I"m just using php-ffi because.. I can.

thursdaybw avatar Feb 20 '22 03:02 thursdaybw

I have the impression there's no better way to proceed with this project if not by code generation. Raylib is constantly breaking its API on each minor version and this is just not sustainable for any FFI/Ext project.

I recommend fetching raylib's metadata (found here) to auto-generate bindings or at least scaffold the repo.

nawarian avatar Feb 20 '22 08:02 nawarian

I'll have fixes up within the next few days. This will be the last release with the current raylib-php API and I'll need to defer to wrapping RayLib functions more managable. What @nawarian provide is awesome and I can automate as much as I can here. Instead I can provide an external regular PHP library to wrap up the API as it is now so it has a way forward.

joseph-montanez avatar Feb 21 '22 05:02 joseph-montanez

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.

2968648

I've added initial support for Raylib 4.0. The font code needs more looking on my end as it wasn't completed and pending tweaks to Texture2D. I've kept the pre 4.0 names in place so existing code should work.

joseph-montanez avatar Feb 21 '22 09:02 joseph-montanez