cglm-php-ffi
recp/cglm binding for PHP using FFI
Tested with PHP-cli 8.0.x under Linux.
- the cglm C API is encapsulated into a PHP class
GLMwhich only containsconstandstaticmembers ; - it autoinit uppon
include_once("./include/GLM.php");; - depeding on your OS, it will try to load
libcglm.soorlibcglm.dllfrom./lib/(default), or from the directory defined inFFI_LIB_DIR; - a
__callStatic()method is used to call C functions using FFI. Example :GLM::vec3_normalize( $vec );; - if required, it is possible to override a C function by adding a
public static functionwith the same name into the class. This can be used to simply the C API and the usage of FFI with some functions that requires pointers. - helpers can be added to the
GLM::API.
/!\ Performance :
Using the __staticCall encapsulation method makes life easier, but it represents a great loss of performance.
If high perf are required, I recommand using GLM::$ffi->glmc_xxxxx() direct calls.
TODO :
- add some helpers that would make the API easier to use in PHP ...