├── EXPERIMENTAL ├── CREDITS ├── bundle └── runtime │ ├── example.php │ ├── Cargo.toml │ ├── src │ ├── main.rs │ └── php.rs │ └── build.rs ├── lib ├── glfw3.lib └── raylib_static.lib ├── img ├── hot-reload.gif ├── autocomplete.png ├── core-basic-window.png └── textures-image-loading.png ├── generate ├── composer.phar ├── examples │ ├── core │ │ ├── test.php │ │ └── core_3d_camera.php │ ├── audio │ │ ├── resources │ │ │ ├── coin.wav │ │ │ ├── sound.wav │ │ │ ├── weird.wav │ │ │ ├── country.mp3 │ │ │ ├── mini1111.xm │ │ │ ├── spring.wav │ │ │ ├── target.flac │ │ │ ├── target.ogg │ │ │ └── LICENSE.md │ │ └── audio_sound_loading.php │ ├── models │ │ ├── models_loading.png │ │ ├── models_skybox.png │ │ ├── models_animation.png │ │ ├── models_billboard.png │ │ ├── models_cubicmap.png │ │ ├── models_heightmap.png │ │ ├── resources │ │ │ ├── skybox.png │ │ │ ├── billboard.png │ │ │ ├── cubicmap.png │ │ │ ├── heightmap.png │ │ │ ├── cubicmap_atlas.png │ │ │ ├── models │ │ │ │ ├── iqm │ │ │ │ │ ├── guy.iqm │ │ │ │ │ ├── guy.blend │ │ │ │ │ ├── guyanim.iqm │ │ │ │ │ ├── guytex.png │ │ │ │ │ └── vertex_colored_object.iqm │ │ │ │ ├── gltf │ │ │ │ │ ├── girl.glb │ │ │ │ │ ├── BoxAnimated.glb │ │ │ │ │ ├── raylib_32x32.glb │ │ │ │ │ ├── rigged_figure.glb │ │ │ │ │ ├── AnimatedMorphCube.glb │ │ │ │ │ ├── vertex_colored_object.glb │ │ │ │ │ ├── LICENSE │ │ │ │ │ └── AnimatedTriangle.gltf │ │ │ │ ├── vox │ │ │ │ │ ├── monu9.vox │ │ │ │ │ ├── chr_knight.vox │ │ │ │ │ ├── chr_sword.vox │ │ │ │ │ └── LICENSE │ │ │ │ └── obj │ │ │ │ │ ├── cube_diffuse.png │ │ │ │ │ ├── house_diffuse.png │ │ │ │ │ ├── plane_diffuse.png │ │ │ │ │ ├── well_diffuse.png │ │ │ │ │ ├── bridge_diffuse.png │ │ │ │ │ ├── castle_diffuse.png │ │ │ │ │ ├── market_diffuse.png │ │ │ │ │ ├── turret_diffuse.png │ │ │ │ │ └── cube.obj │ │ │ ├── dresden_square_1k.hdr │ │ │ ├── dresden_square_2k.hdr │ │ │ ├── shaders │ │ │ │ ├── glsl330 │ │ │ │ │ ├── cubemap.vs │ │ │ │ │ ├── skybox.vs │ │ │ │ │ ├── cubemap.fs │ │ │ │ │ └── skybox.fs │ │ │ │ └── glsl100 │ │ │ │ │ ├── cubemap.vs │ │ │ │ │ ├── skybox.vs │ │ │ │ │ ├── cubemap.fs │ │ │ │ │ └── skybox.fs │ │ │ └── LICENSE.md │ │ ├── models_loading_gltf.png │ │ ├── models_loading_vox.png │ │ ├── models_mesh_picking.png │ │ ├── models_waving_cubes.png │ │ ├── models_box_collisions.png │ │ ├── models_yaw_pitch_roll.png │ │ ├── models_first_person_maze.png │ │ ├── models_geometric_shapes.png │ │ ├── models_mesh_generation.png │ │ ├── models_rlgl_solar_system.png │ │ ├── models_orthographic_projection.png │ │ ├── models_billboard.php │ │ ├── models_billboard.c │ │ ├── models_geometric_shapes.c │ │ └── models_heightmap.c │ └── textures │ │ ├── resources │ │ ├── boom.wav │ │ ├── cat.png │ │ ├── KAISG.ttf │ │ ├── button.png │ │ ├── parrots.png │ │ ├── scarfy.png │ │ ├── buttonfx.wav │ │ ├── explosion.png │ │ ├── fudesumi.png │ │ ├── fudesumi.raw │ │ ├── patterns.png │ │ ├── raylib_logo.png │ │ ├── spark_flame.png │ │ ├── wabbit_alpha.png │ │ ├── ninepatch_button.png │ │ ├── custom_jupiter_crash.png │ │ ├── cyberpunk_street_background.png │ │ ├── cyberpunk_street_foreground.png │ │ ├── cyberpunk_street_midground.png │ │ └── LICENSE.md │ │ └── textures_background_scrolling.php ├── main.php ├── manual │ ├── color.c │ └── LoadModelAnimations.c ├── src │ ├── EnumValue.php │ ├── Generate │ │ ├── ObjectFreePropertyHandler.php │ │ ├── ObjectMethods.php │ │ ├── ObjectNew.php │ │ ├── ObjectGetGarbageCollector.php │ │ ├── ObjectClone.php │ │ ├── ObjectFreeStorage.php │ │ ├── ObjectPropertyReader.php │ │ ├── ObjectGetPropertyPointerPointer.php │ │ ├── ObjectPropertyWriter.php │ │ ├── ObjectGetProperties.php │ │ ├── ObjectRL.php │ │ ├── ObjectStruct.php │ │ ├── ObjectHasProperty.php │ │ ├── Zend │ │ │ └── ZParam.php │ │ └── ObjectStartup.php │ ├── Enum.php │ ├── Func.php │ ├── Param.php │ └── Field.php ├── composer.lock ├── test.php ├── composer.json └── templates │ └── struct-array.c ├── run.sh ├── RELEASES ├── clean.sh ├── .gitattributes ├── tests ├── vector3.php └── 001.phpt ├── raylib-utils.h ├── composer.json ├── php-docker-versions ├── php-8.0 │ └── Dockerfile ├── php-8.2 │ └── Dockerfile ├── php-8.1 │ └── Dockerfile └── php-8.3 │ └── Dockerfile ├── LICENSE.md ├── docker-compose.yml ├── installer.nsi ├── .gitignore ├── CMakeLists.txt ├── color.h ├── ray.h ├── matrix.h ├── wave.h ├── texture.h ├── vector2.h ├── vector3.h ├── vector4.h ├── image.h ├── sound.h ├── shader.h ├── rectangle.h ├── music.h ├── boneinfo.h ├── camera2d.h ├── camera3d.h ├── glyphinfo.h ├── filepathlist.h ├── npatchinfo.h ├── font.h ├── boundingbox.h ├── transform.h ├── raycollision.h ├── material.h ├── materialmap.h ├── rendertexture.h ├── vrdeviceinfo.h ├── audiostream.h ├── modelanimation.h ├── config.w32 ├── model.h ├── include └── hashmap.h ├── mesh.h ├── config.m4 └── vrstereoconfig.h /EXPERIMENTAL: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /CREDITS: -------------------------------------------------------------------------------- 1 | raylib 2 | -------------------------------------------------------------------------------- /bundle/runtime/example.php: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /lib/glfw3.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joseph-montanez/raylib-php/HEAD/lib/glfw3.lib -------------------------------------------------------------------------------- /img/hot-reload.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joseph-montanez/raylib-php/HEAD/img/hot-reload.gif -------------------------------------------------------------------------------- /img/autocomplete.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joseph-montanez/raylib-php/HEAD/img/autocomplete.png -------------------------------------------------------------------------------- /generate/composer.phar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joseph-montanez/raylib-php/HEAD/generate/composer.phar -------------------------------------------------------------------------------- /lib/raylib_static.lib: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joseph-montanez/raylib-php/HEAD/lib/raylib_static.lib -------------------------------------------------------------------------------- /img/core-basic-window.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joseph-montanez/raylib-php/HEAD/img/core-basic-window.png -------------------------------------------------------------------------------- /run.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | php generate/main.php 3 | #bash clean.sh 4 | docker compose up php_raylib_php81 -------------------------------------------------------------------------------- /img/textures-image-loading.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/joseph-montanez/raylib-php/HEAD/img/textures-image-loading.png -------------------------------------------------------------------------------- /RELEASES: -------------------------------------------------------------------------------- 1 | Version: 2.0.0 2 | Date: 2020-04-04 3 | Stability: alpha 4 | 5 | notes: 6 | 7 | 8 | 9 | 10 | 11 | -------------------------------------------------------------------------------- /generate/examples/core/test.php: -------------------------------------------------------------------------------- 1 | load(__DIR__ . '/raylib_api.json'); 8 | 9 | $parser->generateStructs(); -------------------------------------------------------------------------------- /bundle/runtime/Cargo.toml: -------------------------------------------------------------------------------- 1 | [package] 2 | name = "runtime" 3 | version = "0.1.0" 4 | edition = "2021" 5 | 6 | # See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html 7 | 8 | [dependencies] 9 | libc = "0.2" 10 | 11 | [build-dependencies] 12 | bindgen = "0.66.1" 13 | -------------------------------------------------------------------------------- /generate/manual/color.c: -------------------------------------------------------------------------------- 1 | ZEND_BEGIN_ARG_INFO_EX(arginfo_color_[colorName], 0, 0, 0) 2 | ZEND_END_ARG_INFO() 3 | PHP_METHOD(Color, [colorName]) 4 | { 5 | zval *obj = malloc(sizeof(zval)); 6 | object_init_ex(obj, php_raylib_color_ce); 7 | 8 | php_raylib_color_object *result = Z_COLOR_OBJ_P(obj); 9 | *php_raylib_color_fetch_data(result) = (Color){[r], [g], [b], [a]}; 10 | 11 | RETURN_OBJ(&result->std); 12 | } 13 | -------------------------------------------------------------------------------- /clean.sh: -------------------------------------------------------------------------------- 1 | rm -f config.log 2 | rm -f config.h 3 | rm -f config.h.in 4 | rm -f config.h.in~ 5 | rm -f config.nice 6 | rm -f config.status 7 | rm -f configure 8 | rm -f configure.ac 9 | rm -f libtool 10 | rm -f Makefile 11 | rm -f Makefile.fragments 12 | rm -f Makefile.objects 13 | rm -rf build 14 | rm -rf autom4te.cache 15 | rm -rf modules 16 | rm -f *.dep 17 | rm -f *.lo 18 | rm -f *.loT 19 | rm -f *.la 20 | rm -rf .libs 21 | rm -rf cmake-build-debug -------------------------------------------------------------------------------- /.gitattributes: -------------------------------------------------------------------------------- 1 | # Set the default behavior for all files. 2 | * text=auto 3 | * -crlf 4 | 5 | # Normalized and converts to 6 | # native line endings on checkout. 7 | *.c text eol=lf 8 | *.h text eol=lf 9 | *.php text eol=lf 10 | *.json text eol=lf 11 | 12 | # Convert to CRLF line endings on checkout. 13 | *.sln text eol=crlf 14 | 15 | # Convert to LF line endings on checkout. 16 | *.sh text eol=lf 17 | 18 | # Binary files. 19 | *.png binary 20 | *.jpg binary 21 | -------------------------------------------------------------------------------- /tests/vector3.php: -------------------------------------------------------------------------------- 1 | position = $vector; 10 | $camera->position->x++; 11 | 12 | var_dump($camera->position); 13 | echo "unset\n"; 14 | unset($vector); 15 | echo "dump\n"; 16 | var_dump($camera->position); 17 | 18 | 19 | // $nex_v2 = $camera->getPosition(); 20 | // $nex_v2->x++; 21 | // $camera->setPosition($nex_v2); 22 | // $nex_v2->y = 3; -------------------------------------------------------------------------------- /generate/src/EnumValue.php: -------------------------------------------------------------------------------- 1 | value = $value; 17 | $this->name = $name; 18 | $this->nameLower = strtolower($name); 19 | $this->nameUpper = strtoupper($name); 20 | $this->description = $description; 21 | } 22 | } -------------------------------------------------------------------------------- /generate/examples/models/resources/shaders/glsl330/cubemap.vs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes 4 | in vec3 vertexPosition; 5 | 6 | // Input uniform values 7 | uniform mat4 matProjection; 8 | uniform mat4 matView; 9 | 10 | // Output vertex attributes (to fragment shader) 11 | out vec3 fragPosition; 12 | 13 | void main() 14 | { 15 | // Calculate fragment position based on model transformations 16 | fragPosition = vertexPosition; 17 | 18 | // Calculate final vertex position 19 | gl_Position = matProjection*matView*vec4(vertexPosition, 1.0); 20 | } 21 | -------------------------------------------------------------------------------- /raylib-utils.h: -------------------------------------------------------------------------------- 1 | // 2 | // Created by Joseph Montanez on 4/6/18. 3 | // 4 | 5 | #ifndef RAYLIB_RAYLIB_UTILS_H 6 | #define RAYLIB_RAYLIB_UTILS_H 7 | 8 | #include "php.h" 9 | #undef LOG_INFO 10 | #undef LOG_WARNING 11 | #undef LOG_DEBUG 12 | #include "raylib.h" 13 | 14 | struct Color php_array_to_color(zval *ar); 15 | struct Vector3 php_array_to_vector3(zval *ar); 16 | struct Vector2 php_array_to_vector2(zval *ar); 17 | int zend_long_2int(zend_long val); 18 | float zend_double_2float(zval *val); 19 | struct Rectangle php_array_to_rec(zval *ar); 20 | 21 | #endif //RAYLIB_RAYLIB_UTILS_H 22 | -------------------------------------------------------------------------------- /generate/examples/models/resources/shaders/glsl100/cubemap.vs: -------------------------------------------------------------------------------- 1 | #version 100 2 | 3 | // Input vertex attributes 4 | attribute vec3 vertexPosition; 5 | 6 | // Input uniform values 7 | uniform mat4 matProjection; 8 | uniform mat4 matView; 9 | 10 | // Output vertex attributes (to fragment shader) 11 | varying vec3 fragPosition; 12 | 13 | void main() 14 | { 15 | // Calculate fragment position based on model transformations 16 | fragPosition = vertexPosition; 17 | 18 | // Calculate final vertex position 19 | gl_Position = matProjection*matView*vec4(vertexPosition, 1.0); 20 | } 21 | -------------------------------------------------------------------------------- /composer.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "raylib", 3 | "type": "extension", 4 | "license": [ 5 | "PHP License" 6 | ], 7 | "authors": [ 8 | { 9 | "name": "Joseph Monta\u00f1ez", 10 | "email": "sutabi@gmail.com" 11 | } 12 | ], 13 | "description": "Provides a wrapper to the RayLib library.", 14 | "extra": { 15 | "configure-options": { 16 | "with-raylib": { 17 | "default": "autodetect", 18 | "prompt": "Please provide the prefix of RayLib installation" 19 | } 20 | } 21 | } 22 | } -------------------------------------------------------------------------------- /tests/001.phpt: -------------------------------------------------------------------------------- 1 | --TEST-- 2 | Check for raylib presence 3 | --SKIPIF-- 4 | 5 | --FILE-- 6 | 20 | --EXPECT-- 21 | raylib extension is available 22 | -------------------------------------------------------------------------------- /generate/src/Generate/ObjectFreePropertyHandler.php: -------------------------------------------------------------------------------- 1 | nameLower . '_free_prop_handler(zval *el) /* {{{ */'; 15 | $input[] = '{'; 16 | $input[] = ' pefree(Z_PTR_P(el), 1);'; 17 | $input[] = '} /* }}} */'; 18 | $input[] = ''; 19 | 20 | return $input; 21 | } 22 | } -------------------------------------------------------------------------------- /generate/composer.lock: -------------------------------------------------------------------------------- 1 | { 2 | "_readme": [ 3 | "This file locks the dependencies of your project to a known state", 4 | "Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies", 5 | "This file is @generated automatically" 6 | ], 7 | "content-hash": "d825e16a1fc2e6034f64ac3dd4821882", 8 | "packages": [], 9 | "packages-dev": [], 10 | "aliases": [], 11 | "minimum-stability": "stable", 12 | "stability-flags": [], 13 | "prefer-stable": false, 14 | "prefer-lowest": false, 15 | "platform": [], 16 | "platform-dev": [], 17 | "plugin-api-version": "2.2.0" 18 | } 19 | -------------------------------------------------------------------------------- /generate/examples/models/resources/models/vox/LICENSE: -------------------------------------------------------------------------------- 1 | The following models are provided by the official github repo of voxel-model format by MagikaVoxel developer @ephtracy 2 | 3 | GitHub official repo: https://github.com/ephtracy/voxel-model 4 | 5 | - chr_knight.vox - https://github.com/ephtracy/voxel-model/blob/master/vox/character/chr_knight.vox 6 | - chr_sword.vox - https://github.com/ephtracy/voxel-model/blob/master/vox/character/chr_sword.vox 7 | - monu9.vox - https://github.com/ephtracy/voxel-model/blob/master/vox/monument/monu9.vox 8 | 9 | Worth mentioning there is no license specified for the models yet: https://github.com/ephtracy/voxel-model/issues/22 10 | -------------------------------------------------------------------------------- /php-docker-versions/php-8.0/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:8.0.29-zts 2 | 3 | RUN apt-get update && apt-get install -y build-essential git cmake libasound2-dev mesa-common-dev libx11-dev libxrandr-dev libxi-dev xorg-dev libgl1-mesa-dev libglu1-mesa-dev libzip-dev xvfb 4 | 5 | RUN git clone --depth 1 -b 4.5.0 https://github.com/raysan5/raylib.git raylib 6 | RUN cd raylib && mkdir build && cd build && cmake -DOpenGL_GL_PREFERENCE=GLVND -DBUILD_EXAMPLES=OFF -DBUILD_SHARED_LIBS=ON .. && make && make install 7 | 8 | # Build PHP 9 | RUN docker-php-ext-install zip 10 | 11 | # PHP Composer 12 | RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer -------------------------------------------------------------------------------- /generate/examples/models/resources/shaders/glsl330/skybox.vs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes 4 | in vec3 vertexPosition; 5 | 6 | // Input uniform values 7 | uniform mat4 matProjection; 8 | uniform mat4 matView; 9 | 10 | // Output vertex attributes (to fragment shader) 11 | out vec3 fragPosition; 12 | 13 | void main() 14 | { 15 | // Calculate fragment position based on model transformations 16 | fragPosition = vertexPosition; 17 | 18 | // Remove translation from the view matrix 19 | mat4 rotView = mat4(mat3(matView)); 20 | vec4 clipPos = matProjection*rotView*vec4(vertexPosition, 1.0); 21 | 22 | // Calculate final vertex position 23 | gl_Position = clipPos; 24 | } 25 | -------------------------------------------------------------------------------- /generate/examples/models/resources/shaders/glsl100/skybox.vs: -------------------------------------------------------------------------------- 1 | #version 100 2 | 3 | // Input vertex attributes 4 | attribute vec3 vertexPosition; 5 | 6 | // Input uniform values 7 | uniform mat4 matProjection; 8 | uniform mat4 matView; 9 | 10 | // Output vertex attributes (to fragment shader) 11 | varying vec3 fragPosition; 12 | 13 | void main() 14 | { 15 | // Calculate fragment position based on model transformations 16 | fragPosition = vertexPosition; 17 | 18 | // Remove translation from the view matrix 19 | mat4 rotView = mat4(mat3(matView)); 20 | vec4 clipPos = matProjection*rotView*vec4(vertexPosition, 1.0); 21 | 22 | // Calculate final vertex position 23 | gl_Position = clipPos; 24 | } 25 | -------------------------------------------------------------------------------- /generate/examples/models/resources/shaders/glsl100/cubemap.fs: -------------------------------------------------------------------------------- 1 | #version 100 2 | 3 | precision mediump float; 4 | 5 | // Input vertex attributes (from vertex shader) 6 | varying vec3 fragPosition; 7 | 8 | // Input uniform values 9 | uniform sampler2D equirectangularMap; 10 | 11 | vec2 SampleSphericalMap(vec3 v) 12 | { 13 | vec2 uv = vec2(atan(v.z, v.x), asin(v.y)); 14 | uv *= vec2(0.1591, 0.3183); 15 | uv += 0.5; 16 | return uv; 17 | } 18 | 19 | void main() 20 | { 21 | // Normalize local position 22 | vec2 uv = SampleSphericalMap(normalize(fragPosition)); 23 | 24 | // Fetch color from texture map 25 | vec3 color = texture2D(equirectangularMap, uv).rgb; 26 | 27 | // Calculate final fragment color 28 | gl_FragColor = vec4(color, 1.0); 29 | } 30 | -------------------------------------------------------------------------------- /generate/examples/models/resources/shaders/glsl330/cubemap.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes (from vertex shader) 4 | in vec3 fragPosition; 5 | 6 | // Input uniform values 7 | uniform sampler2D equirectangularMap; 8 | 9 | // Output fragment color 10 | out vec4 finalColor; 11 | 12 | vec2 SampleSphericalMap(vec3 v) 13 | { 14 | vec2 uv = vec2(atan(v.z, v.x), asin(v.y)); 15 | uv *= vec2(0.1591, 0.3183); 16 | uv += 0.5; 17 | return uv; 18 | } 19 | 20 | void main() 21 | { 22 | // Normalize local position 23 | vec2 uv = SampleSphericalMap(normalize(fragPosition)); 24 | 25 | // Fetch color from texture map 26 | vec3 color = texture(equirectangularMap, uv).rgb; 27 | 28 | // Calculate final fragment color 29 | finalColor = vec4(color, 1.0); 30 | } 31 | -------------------------------------------------------------------------------- /generate/src/Generate/ObjectMethods.php: -------------------------------------------------------------------------------- 1 | nameLower . '_methods[] = {'; 15 | $input [] = ' PHP_ME(' . $struct->name . ', __construct, arginfo_' . $struct->nameLower . '__construct, ZEND_ACC_PUBLIC)'; 16 | foreach ($extras as $extra) { 17 | $input [] = ' ' . $extra; 18 | } 19 | $input [] = ' PHP_FE_END'; 20 | $input [] = '};'; 21 | 22 | return $input; 23 | } 24 | } -------------------------------------------------------------------------------- /generate/src/Generate/ObjectNew.php: -------------------------------------------------------------------------------- 1 | nameLower . '_new(zend_class_entry *class_type) /* {{{ */'; 21 | $input [] = '{'; 22 | $input [] = ' return php_raylib_' . $struct->nameLower . '_new_ex(class_type, NULL);'; 23 | $input [] = '}'; 24 | $input [] = '/* }}} */'; 25 | $input [] = ''; 26 | 27 | return $input; 28 | } 29 | } -------------------------------------------------------------------------------- /generate/src/Generate/ObjectGetGarbageCollector.php: -------------------------------------------------------------------------------- 1 | nameLower . '_get_gc(zend_object *object, zval **gc_data, int *gc_data_count) /* {{{ */'; 15 | $input[] = '{'; 16 | $input[] = ' *gc_data = NULL;'; 17 | $input[] = ' *gc_data_count = 0;'; 18 | $input[] = ' return zend_std_get_properties(object);'; 19 | $input[] = '}'; 20 | $input[] = '/* }}} */'; 21 | $input[] = ''; 22 | 23 | return $input; 24 | } 25 | } -------------------------------------------------------------------------------- /generate/examples/models/resources/shaders/glsl330/skybox.fs: -------------------------------------------------------------------------------- 1 | #version 330 2 | 3 | // Input vertex attributes (from vertex shader) 4 | in vec3 fragPosition; 5 | 6 | // Input uniform values 7 | uniform samplerCube environmentMap; 8 | uniform bool vflipped; 9 | uniform bool doGamma; 10 | 11 | // Output fragment color 12 | out vec4 finalColor; 13 | 14 | void main() 15 | { 16 | // Fetch color from texture map 17 | vec3 color = vec3(0.0); 18 | 19 | if (vflipped) color = texture(environmentMap, vec3(fragPosition.x, -fragPosition.y, fragPosition.z)).rgb; 20 | else color = texture(environmentMap, fragPosition).rgb; 21 | 22 | if (doGamma)// Apply gamma correction 23 | { 24 | color = color/(color + vec3(1.0)); 25 | color = pow(color, vec3(1.0/2.2)); 26 | } 27 | 28 | // Calculate final fragment color 29 | finalColor = vec4(color, 1.0); 30 | } 31 | -------------------------------------------------------------------------------- /LICENSE.md: -------------------------------------------------------------------------------- 1 | Copyright (c) 2018 Joseph Montanez (@joseph-montanez) 2 | 3 | This software is provided 'as-is', without any express or implied warranty. In no event will the authors be held liable for any damages arising from the use of this software. 4 | 5 | Permission is granted to anyone to use this software for any purpose, including commercial applications, and to alter it and redistribute it freely, subject to the following restrictions: 6 | 7 | 1. The origin of this software must not be misrepresented; you must not claim that you wrote the original software. If you use this software in a product, an acknowledgment in the product documentation would be appreciated but is not required. 8 | 9 | 2. Altered source versions must be plainly marked as such, and must not be misrepresented as being the original software. 10 | 11 | 3. This notice may not be removed or altered from any source distribution. -------------------------------------------------------------------------------- /docker-compose.yml: -------------------------------------------------------------------------------- 1 | version: "3.3" 2 | services: 3 | php_raylib_php80: 4 | build: php-docker-versions/php-8.0 5 | working_dir: /var/www/ 6 | volumes: 7 | - ./:/var/www/ 8 | stdin_open: true 9 | tty: true 10 | command: pbash build.sh 11 | php_raylib_php81: 12 | build: php-docker-versions/php-8.1 13 | working_dir: /var/www/ 14 | volumes: 15 | - ./:/var/www/ 16 | stdin_open: true 17 | tty: true 18 | command: bash build.sh 19 | php_raylib_php82: 20 | build: php-docker-versions/php-8.2 21 | working_dir: /var/www/ 22 | volumes: 23 | - ./:/var/www/ 24 | stdin_open: true 25 | tty: true 26 | command: bash build.sh 27 | php_raylib_php83: 28 | build: php-docker-versions/php-8.3 29 | working_dir: /var/www/ 30 | volumes: 31 | - ./:/var/www/ 32 | stdin_open: true 33 | tty: true 34 | command: bash build.sh -------------------------------------------------------------------------------- /generate/examples/models/resources/shaders/glsl100/skybox.fs: -------------------------------------------------------------------------------- 1 | #version 100 2 | 3 | precision mediump float; 4 | 5 | // Input vertex attributes (from vertex shader) 6 | varying vec3 fragPosition; 7 | 8 | // Input uniform values 9 | uniform samplerCube environmentMap; 10 | uniform bool vflipped; 11 | uniform bool doGamma; 12 | 13 | void main() 14 | { 15 | // Fetch color from texture map 16 | vec4 texelColor = vec4(0.0); 17 | 18 | if (vflipped) texelColor = textureCube(environmentMap, vec3(fragPosition.x, -fragPosition.y, fragPosition.z)); 19 | else texelColor = textureCube(environmentMap, fragPosition); 20 | 21 | vec3 color = vec3(texelColor.x, texelColor.y, texelColor.z); 22 | 23 | if (doGamma) // Apply gamma correction 24 | { 25 | color = color/(color + vec3(1.0)); 26 | color = pow(color, vec3(1.0/2.2)); 27 | } 28 | 29 | // Calculate final fragment color 30 | gl_FragColor = vec4(color, 1.0); 31 | } 32 | -------------------------------------------------------------------------------- /php-docker-versions/php-8.2/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:8.2.8-zts 2 | 3 | RUN apt-get update && apt-get install -y build-essential git cmake libasound2-dev mesa-common-dev libx11-dev libxrandr-dev libxi-dev xorg-dev libgl1-mesa-dev libglu1-mesa-dev libzip-dev xvfb pkg-config 4 | 5 | RUN git clone --depth 1 -b 4.5.0 https://github.com/raysan5/raylib.git raylib 6 | # CMAKE 7 | #RUN cd raylib && mkdir build && cd build && cmake -DOpenGL_GL_PREFERENCE=GLVND -DBUILD_EXAMPLES=OFF -DBUILD_SHARED_LIBS=ON .. && make && make install 8 | # Old Build 9 | #RUN cd raylib/src && make && make install 10 | RUN cd raylib && mkdir build && cd build && cmake -DOpenGL_GL_PREFERENCE=GLVND -DBUILD_EXAMPLES=OFF -DBUILD_SHARED_LIBS=ON .. && make && make install 11 | 12 | #RUN mkdir ~/.vnc 13 | # Setup a password 14 | #RUN x11vnc -storepasswd 1234 ~/.vnc/passwd 15 | 16 | # Build PHP 17 | RUN docker-php-ext-install zip 18 | 19 | # PHP Composer 20 | RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer -------------------------------------------------------------------------------- /php-docker-versions/php-8.1/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:8.1.21-zts 2 | 3 | RUN apt-get update && apt-get install -y build-essential git cmake libasound2-dev mesa-common-dev libx11-dev libxrandr-dev libxi-dev xorg-dev libgl1-mesa-dev libglu1-mesa-dev libzip-dev xvfb pkg-config 4 | 5 | RUN git clone --depth 1 -b 4.5.0 https://github.com/raysan5/raylib.git raylib 6 | # CMAKE 7 | #RUN cd raylib && mkdir build && cd build && cmake -DOpenGL_GL_PREFERENCE=GLVND -DBUILD_EXAMPLES=OFF -DBUILD_SHARED_LIBS=ON .. && make && make install 8 | # Old Build 9 | #RUN cd raylib/src && make && make install 10 | RUN cd raylib && mkdir build && cd build && cmake -DOpenGL_GL_PREFERENCE=GLVND -DBUILD_EXAMPLES=OFF -DBUILD_SHARED_LIBS=ON .. && make && make install 11 | 12 | #RUN mkdir ~/.vnc 13 | # Setup a password 14 | #RUN x11vnc -storepasswd 1234 ~/.vnc/passwd 15 | 16 | # Build PHP 17 | RUN docker-php-ext-install zip 18 | 19 | # PHP Composer 20 | RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer -------------------------------------------------------------------------------- /php-docker-versions/php-8.3/Dockerfile: -------------------------------------------------------------------------------- 1 | FROM php:8.3-rc-zts 2 | 3 | RUN apt-get update && apt-get install -y build-essential git cmake libasound2-dev mesa-common-dev libx11-dev libxrandr-dev libxi-dev xorg-dev libgl1-mesa-dev libglu1-mesa-dev libzip-dev xvfb pkg-config 4 | 5 | RUN git clone --depth 1 -b 4.5.0 https://github.com/raysan5/raylib.git raylib 6 | # CMAKE 7 | #RUN cd raylib && mkdir build && cd build && cmake -DOpenGL_GL_PREFERENCE=GLVND -DBUILD_EXAMPLES=OFF -DBUILD_SHARED_LIBS=ON .. && make && make install 8 | # Old Build 9 | #RUN cd raylib/src && make && make install 10 | RUN cd raylib && mkdir build && cd build && cmake -DOpenGL_GL_PREFERENCE=GLVND -DBUILD_EXAMPLES=OFF -DBUILD_SHARED_LIBS=ON .. && make && make install 11 | 12 | #RUN mkdir ~/.vnc 13 | # Setup a password 14 | #RUN x11vnc -storepasswd 1234 ~/.vnc/passwd 15 | 16 | # Build PHP 17 | RUN docker-php-ext-install zip 18 | 19 | # PHP Composer 20 | RUN curl -sS https://getcomposer.org/installer | php -- --install-dir=/usr/local/bin --filename=composer -------------------------------------------------------------------------------- /installer.nsi: -------------------------------------------------------------------------------- 1 | Name "RayLib PHP" 2 | # define installer name 3 | OutFile "raylib-php.exe" 4 | 5 | # set desktop as install directory 6 | InstallDir $PROGRAMFILES\RayLib-PHP 7 | 8 | # default section start 9 | Section 10 | 11 | # define output path 12 | SetOutPath $INSTDIR 13 | 14 | # specify file to go in output path 15 | ZipDLL::extractall "C:\Users\Admin\Apps\php-7.4.4-ts-Win32-vc15-x64\php-7.4.4-ts-Win32-vc15-x64.zip" "$INSTDIR" 16 | 17 | # define uninstaller name 18 | WriteUninstaller $INSTDIR\uninstaller.exe 19 | 20 | createShortCut "$SMPROGRAMS\raylib-php.lnk" "$INSTDIR\php.exe" 21 | 22 | EnVar::AddValue "Path" "$INSTDIR" 23 | 24 | #------- 25 | # default section end 26 | SectionEnd 27 | 28 | # create a section to define what the uninstaller does. 29 | # the section will always be named "Uninstall" 30 | Section "Uninstall" 31 | 32 | # Always delete uninstaller first 33 | Delete $INSTDIR\uninstaller.exe 34 | 35 | Delete "$SMPROGRAMS\raylib-php.lnk" 36 | 37 | # now delete installed file 38 | Delete $INSTDIR 39 | 40 | SectionEnd -------------------------------------------------------------------------------- /generate/src/Enum.php: -------------------------------------------------------------------------------- 1 | name = $name; 27 | $this->nameLower = strtolower($name); 28 | $this->nameUpper = strtoupper($name); 29 | $this->description = $description; 30 | 31 | $this->values = []; 32 | /** @var array{name:string,value:string,description:string} $value */ 33 | foreach ($values as $value) { 34 | $this->values[] = new EnumValue($value['name'], $value['value'], $value['description']); 35 | } 36 | 37 | } 38 | 39 | } -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | raylib 2 | .idea 3 | vendor 4 | raylib.la 5 | *.la 6 | *.dep 7 | *.lo 8 | run-tests.php 9 | /build/ax_check_compile_flag.m4 10 | /build/ax_gcc_func_attribute.m4 11 | /build/config.guess 12 | /config.h 13 | /config.h.in 14 | /config.log 15 | /config.nice 16 | /config.status 17 | /build/config.sub 18 | /configure 19 | /configure.ac 20 | /build/gen_stub.php 21 | /libtool 22 | /build/libtool.m4 23 | /build/ltmain.sh 24 | /Makefile 25 | /Makefile.fragments 26 | /build/Makefile.global 27 | /Makefile.objects 28 | /autom4te.cache/output.0 29 | /autom4te.cache/output.1 30 | /build/php.m4 31 | /build/php_cxx_compile_stdcxx.m4 32 | /build/pkg.m4 33 | /.libs/raylib.o 34 | /.libs/raylib-color.o 35 | /raylib-font.loT 36 | /.libs/raylib-glyphinfo.o 37 | /.libs/raylib-image.o 38 | /.libs/raylib-matrix.o 39 | /.libs/raylib-npatchinfo.o 40 | /.libs/raylib-rectangle.o 41 | /.libs/raylib-rendertexture.o 42 | /.libs/raylib-texture.o 43 | /.libs/raylib-vector2.o 44 | /.libs/raylib-vector3.o 45 | /.libs/raylib-vector4.o 46 | /autom4te.cache/requests 47 | /build/shtool 48 | /autom4te.cache/traces.0 49 | /autom4te.cache/traces.1 50 | /x64 51 | /notes/.obsidian 52 | /external -------------------------------------------------------------------------------- /generate/src/Generate/ObjectClone.php: -------------------------------------------------------------------------------- 1 | nameLower . '_clone(zend_object *old_object) /* {{{ */'; 21 | $input [] = '{'; 22 | $input [] = ' zend_object *new_object;'; 23 | $input [] = ''; 24 | $input [] = ' new_object = php_raylib_' . $struct->nameLower . '_new_ex(old_object->ce, old_object);'; 25 | $input [] = ''; 26 | $input [] = ' zend_objects_clone_members(new_object, old_object);'; 27 | $input [] = ''; 28 | $input [] = ' return new_object;'; 29 | $input [] = '}'; 30 | $input [] = '/* }}} */'; 31 | $input [] = ''; 32 | 33 | return $input; 34 | } 35 | } -------------------------------------------------------------------------------- /generate/src/Generate/ObjectFreeStorage.php: -------------------------------------------------------------------------------- 1 | nameLower . '_free_storage(zend_object *object)/* {{{ */'; 15 | $input[] = '{'; 16 | $input[] = ' php_raylib_' . $struct->nameLower . '_object *intern = php_raylib_' . $struct->nameLower . '_fetch_object(object);'; 17 | $input[] = ''; 18 | 19 | $input[] = ' intern->' . $struct->nameLower . '->refCount--;'; 20 | $input[] = ' if (intern->' . $struct->nameLower . '->refCount < 1) {'; 21 | $input[] = ' RL_' . $struct->name . '_Free(intern->' . $struct->nameLower . ');'; 22 | $input[] = ' }'; 23 | $input[] = ''; 24 | 25 | $input[] = ' zend_object_std_dtor(&intern->std);'; 26 | $input[] = '}'; 27 | $input[] = '/* }}} */'; 28 | $input[] = ''; 29 | 30 | return $input; 31 | } 32 | } 33 | -------------------------------------------------------------------------------- /generate/examples/models/resources/models/gltf/LICENSE: -------------------------------------------------------------------------------- 1 | Rigged Figure model has been created by Cesium (https://cesium.com/cesiumjs/), 2 | and licensed as Creative Commons Attribution 4.0 International License. 3 | 4 | Box Animated model has been created by Cesium (https://cesium.com/cesiumjs/) 5 | and is licensed as Creative Commons Attribution 4.0 International License 6 | 7 | Avocado model is provided by Microsoft 8 | and licensed as CC0 Universal Public Domain 9 | 10 | Animated Morph Cube model is provided by Microsoft 11 | and licensed as CC0 Universal Public Domain 12 | 13 | Animated Triangle model is licensed as CC0 Universal Public Domain 14 | 15 | Gearbox Assy model has been provided by Okino Computer Graphics, using Okino Polytrans Software. 16 | no license information was provided 17 | 18 | Girl model has been provided by Hristo Stamenov (https://thatonegamedev.com/) 19 | and licensed as CC0 Universal Public Domain 20 | 21 | Check for details on CC0: https://creativecommons.org/publicdomain/zero/1.0/ 22 | Check for details on CC4: http://creativecommons.org/licenses/by/4.0/ 23 | GLTF sample models for testing are taken from: https://github.com/KhronosGroup/glTF-Sample-Models/ 24 | -------------------------------------------------------------------------------- /generate/examples/models/resources/models/obj/cube.obj: -------------------------------------------------------------------------------- 1 | # reference material 2 | #mtllib cube.mtl 3 | 4 | # object box 5 | 6 | # vertex (XZY) 7 | v 5.5 0 1.5 8 | v 8.5 0 1.5 9 | v 5.5 0 -1.5 10 | v 8.5 0 -1.5 11 | v 5.5 3 1.5 12 | v 8.5 3 1.5 13 | v 5.5 3 -1.5 14 | v 8.5 3 -1.5 15 | 16 | # normals (XYZ) 17 | vn 0 -1 0 18 | vn 0 1 0 19 | vn 0 0 1 20 | vn 1 0 0 21 | vn 0 0 -1 22 | vn -1 0 0 23 | 24 | # UVs (XY) 25 | vt 0.5 0 0 26 | vt 1 0 0 27 | vt 1 0.5 0 28 | vt 0.5 0.5 0 29 | vt 0.5 0.5 0 30 | vt 1 0.5 0 31 | vt 0.5 1 0 32 | vt 1 1 0 33 | vt 0 0.5 0 34 | vt 1 0.5 0 35 | vt 1 0 0 36 | vt 0 0 0 37 | vt 0 0.5 0 38 | vt 1 0.5 0 39 | vt 1 1 0 40 | vt 0 1 0 41 | vt 0.5 0 0 42 | vt 0 0 0 43 | vt 0 0.5 0 44 | vt 0.5 0.5 0 45 | vt 0 0.5 0 46 | vt 0.5 0.5 0 47 | vt 0.5 1 0 48 | vt 0 1 0 49 | 50 | # merger 51 | g box 52 | 53 | # reference material 54 | #usemtl mat01 55 | 56 | # faces 57 | f 1/9/1 3/10/1 4/11/1 58 | f 4/11/1 2/12/1 1/9/1 59 | f 5/13/2 6/14/2 8/15/2 60 | f 8/15/2 7/16/2 5/13/2 61 | f 1/17/6 2/18/6 6/19/6 62 | f 6/19/6 5/20/6 1/17/6 63 | f 2/6/1 4/5/1 8/7/1 64 | f 8/7/1 6/8/1 2/6/1 65 | f 4/2/3 3/1/3 7/4/3 66 | f 7/4/3 8/3/3 4/2/3 67 | f 3/22/5 1/21/5 5/24/5 68 | f 5/24/5 7/23/5 3/22/5 69 | -------------------------------------------------------------------------------- /generate/src/Generate/ObjectPropertyReader.php: -------------------------------------------------------------------------------- 1 | nameLower . '_read_property(zend_object *object, zend_string *name, int type, void **cache_slot, zval *rv) /* {{{ */'; 12 | $input[] = '{'; 13 | $input[] = ' php_raylib_' . $struct->nameLower . '_object *obj;'; 14 | $input[] = ' zval *retval = NULL;'; 15 | $input[] = ' raylib_' . $struct->nameLower . '_prop_handler *hnd = NULL;'; 16 | $input[] = ''; 17 | $input[] = ' obj = php_raylib_' . $struct->nameLower . '_fetch_object(object);'; 18 | $input[] = ''; 19 | $input[] = ' if (obj->prop_handler != NULL) {'; 20 | $input[] = ' hnd = zend_hash_find_ptr(obj->prop_handler, name);'; 21 | $input[] = ' }'; 22 | $input[] = ''; 23 | $input[] = ' if (hnd) {'; 24 | $input[] = ' retval = php_raylib_' . $struct->nameLower . '_property_reader(obj, hnd, rv);'; 25 | $input[] = ' } else {'; 26 | $input[] = ' retval = zend_std_read_property(object, name, type, cache_slot, rv);'; 27 | $input[] = ' }'; 28 | $input[] = ''; 29 | $input[] = ' return retval;'; 30 | $input[] = '}'; 31 | $input[] = '/* }}} */'; 32 | $input[] = ''; 33 | 34 | return $input; 35 | } 36 | } -------------------------------------------------------------------------------- /generate/test.php: -------------------------------------------------------------------------------- 1 | nameLower . '_get_property_ptr_ptr(zend_object *object, zend_string *name, int type, void **cache_slot) /* {{{ */'; 20 | $input[] = '{'; 21 | $input[] = ' php_raylib_' . $struct->nameLower . '_object *obj;'; 22 | $input[] = ' zval *retval = NULL;'; 23 | $input[] = ' raylib_' . $struct->nameLower . '_prop_handler *hnd = NULL;'; 24 | $input[] = ''; 25 | $input[] = ' obj = php_raylib_' . $struct->nameLower . '_fetch_object(object);'; 26 | $input[] = ''; 27 | $input[] = ' if (obj->prop_handler != NULL) {'; 28 | $input[] = ' hnd = zend_hash_find_ptr(obj->prop_handler, name);'; 29 | $input[] = ' }'; 30 | $input[] = ''; 31 | $input[] = ' if (hnd == NULL) {'; 32 | $input[] = ' retval = zend_std_get_property_ptr_ptr(object, name, type, cache_slot);'; 33 | $input[] = ' }'; 34 | $input[] = ''; 35 | $input[] = ' return retval;'; 36 | $input[] = '}'; 37 | $input[] = '/* }}} */'; 38 | $input[] = ''; 39 | 40 | return $input; 41 | } 42 | } -------------------------------------------------------------------------------- /generate/src/Generate/ObjectPropertyWriter.php: -------------------------------------------------------------------------------- 1 | nameLower . '_write_property(zend_object *object, zend_string *member, zval *value, void **cache_slot) /* {{{ */'; 12 | $input[] = '{'; 13 | $input[] = ' php_raylib_' . $struct->nameLower . '_object *obj;'; 14 | $input[] = ' raylib_' . $struct->nameLower . '_prop_handler *hnd;'; 15 | $input[] = ''; 16 | $input[] = ' obj = php_raylib_' . $struct->nameLower . '_fetch_object(object);'; 17 | $input[] = ''; 18 | $input[] = ' if (obj->prop_handler != NULL) {'; 19 | $input[] = ' hnd = zend_hash_find_ptr(obj->prop_handler, member);'; 20 | $input[] = ' }'; 21 | $input[] = ''; 22 | 23 | $stmts = []; 24 | foreach ($struct->fieldsByType() as $field) { 25 | $stmt = []; 26 | $stmt[] = 'if (hnd && hnd->write_' . $field->typeName . '_func) {'; 27 | $stmt[] = ' hnd->write_' . $field->typeName . '_func(obj, value);'; 28 | $stmt[] = ' }'; 29 | 30 | $stmts[] = implode("\n", $stmt); 31 | } 32 | $input[] = ' ' . implode(" else ", $stmts). ' else {'; 33 | $input[] = ' value = zend_std_write_property(object, member, value, cache_slot);'; 34 | $input[] = ' }'; 35 | $input[] = ''; 36 | $input[] = ' return value;'; 37 | $input[] = '}'; 38 | $input[] = '/* }}} */'; 39 | $input[] = ''; 40 | 41 | return $input; 42 | } 43 | } -------------------------------------------------------------------------------- /generate/src/Generate/ObjectGetProperties.php: -------------------------------------------------------------------------------- 1 | nameLower . '_get_properties(zend_object *object)/* {{{ */'; 15 | $input[] = '{'; 16 | $input[] = ' php_raylib_' . $struct->nameLower . '_object *obj;'; 17 | $input[] = ' HashTable *props;'; 18 | $input[] = ' raylib_' . $struct->nameLower . '_prop_handler *hnd;'; 19 | $input[] = ' zend_string *key;'; 20 | $input[] = ''; 21 | $input[] = ' obj = php_raylib_' . $struct->nameLower . '_fetch_object(object);'; 22 | $input[] = ' props = zend_std_get_properties(object);'; 23 | $input[] = ''; 24 | $input[] = ' if (obj->prop_handler == NULL) {'; 25 | $input[] = ' return NULL;'; 26 | $input[] = ' }'; 27 | $input[] = ''; 28 | $input[] = ' ZEND_HASH_FOREACH_STR_KEY_PTR(obj->prop_handler, key, hnd) {'; 29 | $input[] = ' zval *ret, val;'; 30 | $input[] = ' ret = php_raylib_' . $struct->nameLower . '_property_reader(obj, hnd, &val);'; 31 | $input[] = ' if (ret == NULL) {'; 32 | $input[] = ' ret = &EG(uninitialized_zval);'; 33 | $input[] = ' }'; 34 | $input[] = ' zend_hash_update(props, key, ret);'; 35 | $input[] = ' } ZEND_HASH_FOREACH_END();'; 36 | $input[] = ''; 37 | $input[] = ' return props;'; 38 | $input[] = '}'; 39 | $input[] = '/* }}} */'; 40 | $input[] = ''; 41 | 42 | return $input; 43 | } 44 | } -------------------------------------------------------------------------------- /bundle/runtime/src/main.rs: -------------------------------------------------------------------------------- 1 | #[allow(non_camel_case_types,non_snake_case,non_upper_case_globals,dead_code)] 2 | mod zend { 3 | include!(concat!(env!("CARGO_MANIFEST_DIR"), "/zend-bindings.rs")); 4 | } 5 | 6 | extern crate libc; 7 | use libc::{c_int, c_char}; 8 | use std::ffi::CString; 9 | 10 | mod php; 11 | 12 | fn main() { 13 | let args: Vec = std::env::args().map(|arg| CString::new(arg).unwrap()).collect(); 14 | let mut c_args: Vec<*mut c_char> = args.iter().map(|arg| arg.as_ptr() as *mut c_char).collect(); 15 | 16 | unsafe { 17 | php::php_embed_init(c_args.len() as c_int, c_args.as_mut_ptr()); 18 | php::executor_globals.bailout = std::ptr::null_mut(); 19 | 20 | let __orig_bailout = php::executor_globals.bailout; 21 | let mut __bailout: zend::sigjmp_buf = [0; 49]; // Initializing with zeroes 22 | php::executor_globals.bailout = &mut __bailout; 23 | 24 | if php::sigsetjmp(&mut __bailout, 0) == 0 { 25 | let mut file_handle_uninit: std::mem::MaybeUninit = std::mem::MaybeUninit::uninit(); 26 | let filename = CString::new("example.php").unwrap(); 27 | let file_handle_ptr = file_handle_uninit.as_mut_ptr(); 28 | 29 | php::zend_stream_init_filename(file_handle_ptr, filename.as_ptr()); 30 | let mut file_handle: php::zend_file_handle = file_handle_uninit.assume_init(); 31 | 32 | if php::php_execute_script(&mut file_handle) == -1 { 33 | let error_message = CString::new("Failed to execute PHP script.\n").unwrap(); // Added extra newline 34 | 35 | php::php_printf(error_message.as_ptr()); 36 | } 37 | } else { 38 | php::executor_globals.bailout = __orig_bailout; 39 | } 40 | 41 | php::executor_globals.bailout = __orig_bailout; 42 | php::php_embed_shutdown(); 43 | } 44 | } -------------------------------------------------------------------------------- /generate/src/Generate/ObjectRL.php: -------------------------------------------------------------------------------- 1 | nameUpper . '_IS_POINTER,'; 17 | $input[] = ' RL_' . $struct->nameUpper . '_IS_VALUE'; 18 | $input[] = '} RL' . $struct->name . 'DataType;'; 19 | $input[] = ''; 20 | 21 | $input[] = 'typedef union {'; 22 | $input[] = ' ' . $struct->name . ' *p;'; 23 | $input[] = ' ' . $struct->name . ' v;'; 24 | $input[] = '} ' . $struct->name . 'Union;'; 25 | $input[] = ''; 26 | 27 | $input[] = 'struct RL_' . $struct->name . ' {'; 28 | $input[] = ' unsigned int id;'; 29 | $input[] = ' char *guid;'; 30 | $input[] = ' ' . $struct->name . 'Union data;'; 31 | $input[] = ' RL' . $struct->name . 'DataType type;'; 32 | $input[] = ' unsigned refCount;'; 33 | $input[] = ' unsigned char deleted;'; 34 | $input[] = '};'; 35 | $input[] = ''; 36 | $input[] = 'static struct RL_' . $struct->name . ' **RL_' . $struct->name . '_Object_List;'; 37 | $input[] = 'static hashmap *RL_' . $struct->name . '_Object_Map;'; 38 | $input[] = ''; 39 | $input[] = 'char* RL_' . $struct->name . '_Hash_Id(char *str, size_t size);'; 40 | $input[] = 'struct RL_' . $struct->name . '* RL_' . $struct->name . '_Create();'; 41 | $input[] = 'void RL_' . $struct->name . '_Delete(struct RL_' . $struct->name . '* object, int index);'; 42 | $input[] = 'void RL_' . $struct->name . '_Free(struct RL_' . $struct->name . '* object);'; 43 | $input[] = ''; 44 | 45 | return $input; 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /bundle/runtime/src/php.rs: -------------------------------------------------------------------------------- 1 | #[allow(non_camel_case_types,non_snake_case,non_upper_case_globals,dead_code)] 2 | mod zend { 3 | include!(concat!(env!("CARGO_MANIFEST_DIR"), "/zend-bindings.rs")); 4 | } 5 | 6 | use libc::{c_int, c_char}; 7 | use std::os::raw::c_void; 8 | use std::mem::ManuallyDrop; 9 | 10 | type JmpBuf = [libc::c_int; 49]; 11 | 12 | type ZendStreamFsizerT = extern "C" fn(handle: *mut libc::c_void) -> libc::size_t; 13 | type ZendStreamReaderT = extern "C" fn(handle: *mut libc::c_void, buf: *mut libc::c_char, len: libc::size_t) -> libc::ssize_t; 14 | type ZendStreamCloserT = extern "C" fn(handle: *mut libc::c_void); 15 | 16 | #[repr(C)] 17 | pub struct zend_stream { 18 | handle: *mut c_void, 19 | isatty: c_int, 20 | reader: Option, 21 | fsizer: Option, 22 | closer: Option, 23 | } 24 | 25 | #[repr(C)] 26 | pub union Handle { 27 | fp: *mut std::ffi::c_void, 28 | stream: ManuallyDrop, 29 | } 30 | 31 | #[repr(C)] 32 | pub struct zend_file_handle { 33 | handle: Handle, 34 | filename: *mut libc::c_char, 35 | opened_path: *mut libc::c_char, 36 | type_: u8, 37 | primary_script: bool, 38 | in_list: bool, 39 | buf: *mut libc::c_char, 40 | len: usize, 41 | } 42 | 43 | extern "C" { 44 | // Assuming these functions and types are defined in your FFI bindings 45 | pub(crate) fn php_embed_init(argc: c_int, argv: *mut *mut c_char); 46 | pub(crate) fn php_embed_shutdown(); 47 | pub(crate) fn zend_stream_init_filename(file_handle: *mut zend_file_handle, filename: *const c_char); 48 | pub(crate) fn php_execute_script(file_handle: *mut zend_file_handle) -> c_int; 49 | pub(crate) fn php_printf(format: *const c_char, ...); 50 | 51 | pub(crate) fn sigsetjmp(env: *mut JmpBuf, savesigs: libc::c_int) -> libc::c_int; 52 | 53 | // Executor globals and jump buffer types 54 | pub(crate) static mut executor_globals: zend::_zend_executor_globals; 55 | } -------------------------------------------------------------------------------- /generate/examples/core/core_3d_camera.php: -------------------------------------------------------------------------------- 1 | position %f, %f, %f\n", $camera->position->x, $camera->position->y, $camera->position->z); 43 | SetCameraMode($camera, CAMERA_FIRST_PERSON); // Set a first person camera mode 44 | printf("0: \$camera->position %f, %f, %f\n", $camera->position->x, $camera->position->y, $camera->position->z); 45 | 46 | SetTargetFPS(60); // Set our game to run at 60 frames-per-second 47 | 48 | UpdateCamera($camera); 49 | 50 | unset($camera); 51 | 52 | echo "Done!\n"; -------------------------------------------------------------------------------- /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.21) 2 | project(raylib C) 3 | 4 | set(CMAKE_C_STANDARD 11) 5 | 6 | include_directories( 7 | external/php-src 8 | external/php-src/main 9 | external/php-src/Zend 10 | external/php-src/TSRM 11 | external/php-src/ext 12 | /Volumes/External/opt/homebrew/Cellar/raylib/4.5.0/include 13 | ) 14 | include_directories(. ../../main/ ../../../deps/include) 15 | 16 | add_executable(raylib 17 | audiostream.c 18 | audiostream.h 19 | boneinfo.c 20 | boneinfo.h 21 | boundingbox.c 22 | boundingbox.h 23 | camera2d.c 24 | camera2d.h 25 | camera3d.c 26 | camera3d.h 27 | color.c 28 | color.h 29 | font.c 30 | font.h 31 | glyphinfo.c 32 | glyphinfo.h 33 | image.c 34 | image.h 35 | material.c 36 | material.h 37 | materialmap.c 38 | materialmap.h 39 | matrix.c 40 | matrix.h 41 | mesh.c 42 | mesh.h 43 | model.c 44 | model.h 45 | modelanimation.c 46 | modelanimation.h 47 | music.c 48 | music.h 49 | npatchinfo.c 50 | npatchinfo.h 51 | php_raylib.h 52 | ray.c 53 | ray.h 54 | raycollision.c 55 | raycollision.h 56 | raylib.c 57 | rectangle.c 58 | rectangle.h 59 | rendertexture.c 60 | rendertexture.h 61 | shader.c 62 | shader.h 63 | sound.c 64 | sound.h 65 | texture.c 66 | texture.h 67 | transform.c 68 | transform.h 69 | vector2.c 70 | vector2.h 71 | vector3.c 72 | vector3.h 73 | vector4.c 74 | vector4.h 75 | vrdeviceinfo.c 76 | vrdeviceinfo.h 77 | vrstereoconfig.c 78 | vrstereoconfig.h 79 | wave.c 80 | wave.h include/hashmap.h include/hashmap.c 81 | generate/manual/LoadModelAnimations.c) 82 | -------------------------------------------------------------------------------- /color.h: -------------------------------------------------------------------------------- 1 | #ifndef PHP_RAYLIB_COLOR_H 2 | #define PHP_RAYLIB_COLOR_H 3 | 4 | #include "include/hashmap.h" 5 | 6 | extern zend_class_entry * php_raylib_color_ce; 7 | 8 | // External Free Objects - Prevent Circular Dependency 9 | 10 | extern void php_raylib_color_free_storage(zend_object * object); 11 | 12 | extern zend_object * php_raylib_color_new(zend_class_entry * ce); 13 | 14 | extern zend_object * php_raylib_color_new_ex(zend_class_entry *ce, zend_object *orig); 15 | 16 | extern zend_object_handlers php_raylib_color_object_handlers; 17 | 18 | typedef enum { 19 | RL_COLOR_IS_POINTER, 20 | RL_COLOR_IS_VALUE 21 | } RLColorDataType; 22 | 23 | typedef union { 24 | Color *p; 25 | Color v; 26 | } ColorUnion; 27 | 28 | struct RL_Color { 29 | unsigned int id; 30 | char *guid; 31 | ColorUnion data; 32 | RLColorDataType type; 33 | unsigned refCount; 34 | unsigned char deleted; 35 | }; 36 | 37 | static struct RL_Color **RL_Color_Object_List; 38 | static hashmap *RL_Color_Object_Map; 39 | 40 | char* RL_Color_Hash_Id(char *str, size_t size); 41 | struct RL_Color* RL_Color_Create(); 42 | void RL_Color_Delete(struct RL_Color* object, int index); 43 | void RL_Color_Free(struct RL_Color* object); 44 | 45 | typedef struct _php_raylib_color_object { 46 | struct RL_Color *color; 47 | HashTable *prop_handler; 48 | zend_object std; 49 | } php_raylib_color_object; 50 | 51 | static inline php_raylib_color_object *php_raylib_color_fetch_object(zend_object *obj) { 52 | return (php_raylib_color_object *)((char *)obj - XtOffsetOf(php_raylib_color_object, std)); 53 | } 54 | 55 | static inline Color *php_raylib_color_fetch_data(php_raylib_color_object *obj) { 56 | Color *my_color; 57 | if (obj->color->type == RL_COLOR_IS_POINTER) { 58 | my_color = obj->color->data.p; 59 | } else { 60 | my_color = &obj->color->data.v; 61 | } 62 | 63 | return my_color; 64 | } 65 | 66 | #define Z_COLOR_OBJ_P(zv) php_raylib_color_fetch_object(Z_OBJ_P(zv)); 67 | 68 | void php_raylib_color_startup(INIT_FUNC_ARGS); 69 | 70 | #endif //PHP_RAYLIB_COLOR_H 71 | -------------------------------------------------------------------------------- /ray.h: -------------------------------------------------------------------------------- 1 | #ifndef PHP_RAYLIB_RAY_H 2 | #define PHP_RAYLIB_RAY_H 3 | 4 | #include "include/hashmap.h" 5 | #include "vector3.h" 6 | 7 | extern zend_class_entry * php_raylib_ray_ce; 8 | 9 | // External Free Objects - Prevent Circular Dependency 10 | extern void php_raylib_vector3_free_storage(zend_object *object); 11 | 12 | extern void php_raylib_ray_free_storage(zend_object * object); 13 | 14 | extern zend_object * php_raylib_ray_new(zend_class_entry * ce); 15 | 16 | extern zend_object * php_raylib_ray_new_ex(zend_class_entry *ce, zend_object *orig); 17 | 18 | extern zend_object_handlers php_raylib_ray_object_handlers; 19 | 20 | typedef enum { 21 | RL_RAY_IS_POINTER, 22 | RL_RAY_IS_VALUE 23 | } RLRayDataType; 24 | 25 | typedef union { 26 | Ray *p; 27 | Ray v; 28 | } RayUnion; 29 | 30 | struct RL_Ray { 31 | unsigned int id; 32 | char *guid; 33 | RayUnion data; 34 | RLRayDataType type; 35 | unsigned refCount; 36 | unsigned char deleted; 37 | }; 38 | 39 | static struct RL_Ray **RL_Ray_Object_List; 40 | static hashmap *RL_Ray_Object_Map; 41 | 42 | char* RL_Ray_Hash_Id(char *str, size_t size); 43 | struct RL_Ray* RL_Ray_Create(); 44 | void RL_Ray_Delete(struct RL_Ray* object, int index); 45 | void RL_Ray_Free(struct RL_Ray* object); 46 | 47 | typedef struct _php_raylib_ray_object { 48 | struct RL_Ray *ray; 49 | HashTable *prop_handler; 50 | zval position; 51 | zval direction; 52 | zend_object std; 53 | } php_raylib_ray_object; 54 | 55 | static inline php_raylib_ray_object *php_raylib_ray_fetch_object(zend_object *obj) { 56 | return (php_raylib_ray_object *)((char *)obj - XtOffsetOf(php_raylib_ray_object, std)); 57 | } 58 | 59 | static inline Ray *php_raylib_ray_fetch_data(php_raylib_ray_object *obj) { 60 | Ray *my_ray; 61 | if (obj->ray->type == RL_RAY_IS_POINTER) { 62 | my_ray = obj->ray->data.p; 63 | } else { 64 | my_ray = &obj->ray->data.v; 65 | } 66 | 67 | return my_ray; 68 | } 69 | 70 | #define Z_RAY_OBJ_P(zv) php_raylib_ray_fetch_object(Z_OBJ_P(zv)); 71 | 72 | void php_raylib_ray_startup(INIT_FUNC_ARGS); 73 | 74 | #endif //PHP_RAYLIB_RAY_H 75 | -------------------------------------------------------------------------------- /matrix.h: -------------------------------------------------------------------------------- 1 | #ifndef PHP_RAYLIB_MATRIX_H 2 | #define PHP_RAYLIB_MATRIX_H 3 | 4 | #include "include/hashmap.h" 5 | 6 | extern zend_class_entry * php_raylib_matrix_ce; 7 | 8 | // External Free Objects - Prevent Circular Dependency 9 | 10 | extern void php_raylib_matrix_free_storage(zend_object * object); 11 | 12 | extern zend_object * php_raylib_matrix_new(zend_class_entry * ce); 13 | 14 | extern zend_object * php_raylib_matrix_new_ex(zend_class_entry *ce, zend_object *orig); 15 | 16 | extern zend_object_handlers php_raylib_matrix_object_handlers; 17 | 18 | typedef enum { 19 | RL_MATRIX_IS_POINTER, 20 | RL_MATRIX_IS_VALUE 21 | } RLMatrixDataType; 22 | 23 | typedef union { 24 | Matrix *p; 25 | Matrix v; 26 | } MatrixUnion; 27 | 28 | struct RL_Matrix { 29 | unsigned int id; 30 | char *guid; 31 | MatrixUnion data; 32 | RLMatrixDataType type; 33 | unsigned refCount; 34 | unsigned char deleted; 35 | }; 36 | 37 | static struct RL_Matrix **RL_Matrix_Object_List; 38 | static hashmap *RL_Matrix_Object_Map; 39 | 40 | char* RL_Matrix_Hash_Id(char *str, size_t size); 41 | struct RL_Matrix* RL_Matrix_Create(); 42 | void RL_Matrix_Delete(struct RL_Matrix* object, int index); 43 | void RL_Matrix_Free(struct RL_Matrix* object); 44 | 45 | typedef struct _php_raylib_matrix_object { 46 | struct RL_Matrix *matrix; 47 | HashTable *prop_handler; 48 | zend_object std; 49 | } php_raylib_matrix_object; 50 | 51 | static inline php_raylib_matrix_object *php_raylib_matrix_fetch_object(zend_object *obj) { 52 | return (php_raylib_matrix_object *)((char *)obj - XtOffsetOf(php_raylib_matrix_object, std)); 53 | } 54 | 55 | static inline Matrix *php_raylib_matrix_fetch_data(php_raylib_matrix_object *obj) { 56 | Matrix *my_matrix; 57 | if (obj->matrix->type == RL_MATRIX_IS_POINTER) { 58 | my_matrix = obj->matrix->data.p; 59 | } else { 60 | my_matrix = &obj->matrix->data.v; 61 | } 62 | 63 | return my_matrix; 64 | } 65 | 66 | #define Z_MATRIX_OBJ_P(zv) php_raylib_matrix_fetch_object(Z_OBJ_P(zv)); 67 | 68 | void php_raylib_matrix_startup(INIT_FUNC_ARGS); 69 | 70 | #endif //PHP_RAYLIB_MATRIX_H 71 | -------------------------------------------------------------------------------- /wave.h: -------------------------------------------------------------------------------- 1 | #ifndef PHP_RAYLIB_WAVE_H 2 | #define PHP_RAYLIB_WAVE_H 3 | 4 | #include "include/hashmap.h" 5 | 6 | extern zend_class_entry * php_raylib_wave_ce; 7 | 8 | // External Free Objects - Prevent Circular Dependency 9 | 10 | extern void php_raylib_wave_free_storage(zend_object * object); 11 | 12 | extern zend_object * php_raylib_wave_new(zend_class_entry * ce); 13 | 14 | extern zend_object * php_raylib_wave_new_ex(zend_class_entry *ce, zend_object *orig); 15 | 16 | extern zend_object_handlers php_raylib_wave_object_handlers; 17 | 18 | typedef enum { 19 | RL_WAVE_IS_POINTER, 20 | RL_WAVE_IS_VALUE 21 | } RLWaveDataType; 22 | 23 | typedef union { 24 | Wave *p; 25 | Wave v; 26 | } WaveUnion; 27 | 28 | struct RL_Wave { 29 | unsigned int id; 30 | char *guid; 31 | WaveUnion data; 32 | RLWaveDataType type; 33 | unsigned refCount; 34 | unsigned char deleted; 35 | }; 36 | 37 | static struct RL_Wave **RL_Wave_Object_List; 38 | static hashmap *RL_Wave_Object_Map; 39 | 40 | char* RL_Wave_Hash_Id(char *str, size_t size); 41 | struct RL_Wave* RL_Wave_Create(); 42 | void RL_Wave_Delete(struct RL_Wave* object, int index); 43 | void RL_Wave_Free(struct RL_Wave* object); 44 | 45 | typedef struct _php_raylib_wave_object { 46 | struct RL_Wave *wave; 47 | HashTable *prop_handler; 48 | // Cannot support primitive data structure like void * (an array) as zval 49 | // zval data; 50 | zend_object std; 51 | } php_raylib_wave_object; 52 | 53 | static inline php_raylib_wave_object *php_raylib_wave_fetch_object(zend_object *obj) { 54 | return (php_raylib_wave_object *)((char *)obj - XtOffsetOf(php_raylib_wave_object, std)); 55 | } 56 | 57 | static inline Wave *php_raylib_wave_fetch_data(php_raylib_wave_object *obj) { 58 | Wave *my_wave; 59 | if (obj->wave->type == RL_WAVE_IS_POINTER) { 60 | my_wave = obj->wave->data.p; 61 | } else { 62 | my_wave = &obj->wave->data.v; 63 | } 64 | 65 | return my_wave; 66 | } 67 | 68 | #define Z_WAVE_OBJ_P(zv) php_raylib_wave_fetch_object(Z_OBJ_P(zv)); 69 | 70 | void php_raylib_wave_startup(INIT_FUNC_ARGS); 71 | 72 | #endif //PHP_RAYLIB_WAVE_H 73 | -------------------------------------------------------------------------------- /generate/src/Generate/ObjectStruct.php: -------------------------------------------------------------------------------- 1 | nameLower . '_object {'; 15 | $input[] = ' struct RL_' . $struct->name . ' *' . $struct->nameLower . ';'; 16 | $input[] = ' HashTable *prop_handler;'; 17 | 18 | //-- External Object Fields 19 | // These are the pointers in the struct 20 | foreach ($struct->nonPrimitiveFields() as $field) { 21 | if ($field->isArray || $field->isPointer) { 22 | if ($field->typePlainLower === 'raudiobuffer') { 23 | $input[] = '// NO idea what to do with rAudioBuffer'; 24 | $input[] = '//php_raylib_' . $field->typePlainLower . '_object *' . $field->nameLower . ';'; 25 | } else { 26 | // if ($field->arrayCountNumber > 0) { 27 | // $input[] = ' zval ' . $field->nameLower . '[' . $field->arrayCountNumber . '];'; 28 | // } else { 29 | $input[] = ' zval ' . $field->nameLower . ';'; 30 | // } 31 | } 32 | } else { 33 | $input[] = ' zval ' . $field->nameLower . ';'; 34 | } 35 | } 36 | 37 | foreach ($struct->fields as $field) { 38 | if ($field->isPrimitive && $field->isArray) { 39 | $input[] = ' // Cannot support primitive data structure like ' . $field->type . ' (an array) as zval'; 40 | $input[] = ' // zval ' . $field->nameLower . ';'; 41 | } 42 | } 43 | 44 | //-- zend_object MUST be at the end of the struct to work correctly 45 | $input[] = ' zend_object std;'; 46 | $input[] = '} php_raylib_' . $struct->nameLower . '_object;'; 47 | $input[] = ''; 48 | 49 | return $input; 50 | } 51 | } 52 | -------------------------------------------------------------------------------- /texture.h: -------------------------------------------------------------------------------- 1 | #ifndef PHP_RAYLIB_TEXTURE_H 2 | #define PHP_RAYLIB_TEXTURE_H 3 | 4 | #include "include/hashmap.h" 5 | 6 | extern zend_class_entry * php_raylib_texture_ce; 7 | 8 | // External Free Objects - Prevent Circular Dependency 9 | 10 | extern void php_raylib_texture_free_storage(zend_object * object); 11 | 12 | extern zend_object * php_raylib_texture_new(zend_class_entry * ce); 13 | 14 | extern zend_object * php_raylib_texture_new_ex(zend_class_entry *ce, zend_object *orig); 15 | 16 | extern zend_object_handlers php_raylib_texture_object_handlers; 17 | 18 | typedef enum { 19 | RL_TEXTURE_IS_POINTER, 20 | RL_TEXTURE_IS_VALUE 21 | } RLTextureDataType; 22 | 23 | typedef union { 24 | Texture *p; 25 | Texture v; 26 | } TextureUnion; 27 | 28 | struct RL_Texture { 29 | unsigned int id; 30 | char *guid; 31 | TextureUnion data; 32 | RLTextureDataType type; 33 | unsigned refCount; 34 | unsigned char deleted; 35 | }; 36 | 37 | static struct RL_Texture **RL_Texture_Object_List; 38 | static hashmap *RL_Texture_Object_Map; 39 | 40 | char* RL_Texture_Hash_Id(char *str, size_t size); 41 | struct RL_Texture* RL_Texture_Create(); 42 | void RL_Texture_Delete(struct RL_Texture* object, int index); 43 | void RL_Texture_Free(struct RL_Texture* object); 44 | 45 | typedef struct _php_raylib_texture_object { 46 | struct RL_Texture *texture; 47 | HashTable *prop_handler; 48 | zend_object std; 49 | } php_raylib_texture_object; 50 | 51 | static inline php_raylib_texture_object *php_raylib_texture_fetch_object(zend_object *obj) { 52 | return (php_raylib_texture_object *)((char *)obj - XtOffsetOf(php_raylib_texture_object, std)); 53 | } 54 | 55 | static inline Texture *php_raylib_texture_fetch_data(php_raylib_texture_object *obj) { 56 | Texture *my_texture; 57 | if (obj->texture->type == RL_TEXTURE_IS_POINTER) { 58 | my_texture = obj->texture->data.p; 59 | } else { 60 | my_texture = &obj->texture->data.v; 61 | } 62 | 63 | return my_texture; 64 | } 65 | 66 | #define Z_TEXTURE_OBJ_P(zv) php_raylib_texture_fetch_object(Z_OBJ_P(zv)); 67 | 68 | void php_raylib_texture_startup(INIT_FUNC_ARGS); 69 | 70 | #endif //PHP_RAYLIB_TEXTURE_H 71 | -------------------------------------------------------------------------------- /vector2.h: -------------------------------------------------------------------------------- 1 | #ifndef PHP_RAYLIB_VECTOR2_H 2 | #define PHP_RAYLIB_VECTOR2_H 3 | 4 | #include "include/hashmap.h" 5 | 6 | extern zend_class_entry * php_raylib_vector2_ce; 7 | 8 | // External Free Objects - Prevent Circular Dependency 9 | 10 | extern void php_raylib_vector2_free_storage(zend_object * object); 11 | 12 | extern zend_object * php_raylib_vector2_new(zend_class_entry * ce); 13 | 14 | extern zend_object * php_raylib_vector2_new_ex(zend_class_entry *ce, zend_object *orig); 15 | 16 | extern zend_object_handlers php_raylib_vector2_object_handlers; 17 | 18 | typedef enum { 19 | RL_VECTOR2_IS_POINTER, 20 | RL_VECTOR2_IS_VALUE 21 | } RLVector2DataType; 22 | 23 | typedef union { 24 | Vector2 *p; 25 | Vector2 v; 26 | } Vector2Union; 27 | 28 | struct RL_Vector2 { 29 | unsigned int id; 30 | char *guid; 31 | Vector2Union data; 32 | RLVector2DataType type; 33 | unsigned refCount; 34 | unsigned char deleted; 35 | }; 36 | 37 | static struct RL_Vector2 **RL_Vector2_Object_List; 38 | static hashmap *RL_Vector2_Object_Map; 39 | 40 | char* RL_Vector2_Hash_Id(char *str, size_t size); 41 | struct RL_Vector2* RL_Vector2_Create(); 42 | void RL_Vector2_Delete(struct RL_Vector2* object, int index); 43 | void RL_Vector2_Free(struct RL_Vector2* object); 44 | 45 | typedef struct _php_raylib_vector2_object { 46 | struct RL_Vector2 *vector2; 47 | HashTable *prop_handler; 48 | zend_object std; 49 | } php_raylib_vector2_object; 50 | 51 | static inline php_raylib_vector2_object *php_raylib_vector2_fetch_object(zend_object *obj) { 52 | return (php_raylib_vector2_object *)((char *)obj - XtOffsetOf(php_raylib_vector2_object, std)); 53 | } 54 | 55 | static inline Vector2 *php_raylib_vector2_fetch_data(php_raylib_vector2_object *obj) { 56 | Vector2 *my_vector2; 57 | if (obj->vector2->type == RL_VECTOR2_IS_POINTER) { 58 | my_vector2 = obj->vector2->data.p; 59 | } else { 60 | my_vector2 = &obj->vector2->data.v; 61 | } 62 | 63 | return my_vector2; 64 | } 65 | 66 | #define Z_VECTOR2_OBJ_P(zv) php_raylib_vector2_fetch_object(Z_OBJ_P(zv)); 67 | 68 | void php_raylib_vector2_startup(INIT_FUNC_ARGS); 69 | 70 | #endif //PHP_RAYLIB_VECTOR2_H 71 | -------------------------------------------------------------------------------- /vector3.h: -------------------------------------------------------------------------------- 1 | #ifndef PHP_RAYLIB_VECTOR3_H 2 | #define PHP_RAYLIB_VECTOR3_H 3 | 4 | #include "include/hashmap.h" 5 | 6 | extern zend_class_entry * php_raylib_vector3_ce; 7 | 8 | // External Free Objects - Prevent Circular Dependency 9 | 10 | extern void php_raylib_vector3_free_storage(zend_object * object); 11 | 12 | extern zend_object * php_raylib_vector3_new(zend_class_entry * ce); 13 | 14 | extern zend_object * php_raylib_vector3_new_ex(zend_class_entry *ce, zend_object *orig); 15 | 16 | extern zend_object_handlers php_raylib_vector3_object_handlers; 17 | 18 | typedef enum { 19 | RL_VECTOR3_IS_POINTER, 20 | RL_VECTOR3_IS_VALUE 21 | } RLVector3DataType; 22 | 23 | typedef union { 24 | Vector3 *p; 25 | Vector3 v; 26 | } Vector3Union; 27 | 28 | struct RL_Vector3 { 29 | unsigned int id; 30 | char *guid; 31 | Vector3Union data; 32 | RLVector3DataType type; 33 | unsigned refCount; 34 | unsigned char deleted; 35 | }; 36 | 37 | static struct RL_Vector3 **RL_Vector3_Object_List; 38 | static hashmap *RL_Vector3_Object_Map; 39 | 40 | char* RL_Vector3_Hash_Id(char *str, size_t size); 41 | struct RL_Vector3* RL_Vector3_Create(); 42 | void RL_Vector3_Delete(struct RL_Vector3* object, int index); 43 | void RL_Vector3_Free(struct RL_Vector3* object); 44 | 45 | typedef struct _php_raylib_vector3_object { 46 | struct RL_Vector3 *vector3; 47 | HashTable *prop_handler; 48 | zend_object std; 49 | } php_raylib_vector3_object; 50 | 51 | static inline php_raylib_vector3_object *php_raylib_vector3_fetch_object(zend_object *obj) { 52 | return (php_raylib_vector3_object *)((char *)obj - XtOffsetOf(php_raylib_vector3_object, std)); 53 | } 54 | 55 | static inline Vector3 *php_raylib_vector3_fetch_data(php_raylib_vector3_object *obj) { 56 | Vector3 *my_vector3; 57 | if (obj->vector3->type == RL_VECTOR3_IS_POINTER) { 58 | my_vector3 = obj->vector3->data.p; 59 | } else { 60 | my_vector3 = &obj->vector3->data.v; 61 | } 62 | 63 | return my_vector3; 64 | } 65 | 66 | #define Z_VECTOR3_OBJ_P(zv) php_raylib_vector3_fetch_object(Z_OBJ_P(zv)); 67 | 68 | void php_raylib_vector3_startup(INIT_FUNC_ARGS); 69 | 70 | #endif //PHP_RAYLIB_VECTOR3_H 71 | -------------------------------------------------------------------------------- /vector4.h: -------------------------------------------------------------------------------- 1 | #ifndef PHP_RAYLIB_VECTOR4_H 2 | #define PHP_RAYLIB_VECTOR4_H 3 | 4 | #include "include/hashmap.h" 5 | 6 | extern zend_class_entry * php_raylib_vector4_ce; 7 | 8 | // External Free Objects - Prevent Circular Dependency 9 | 10 | extern void php_raylib_vector4_free_storage(zend_object * object); 11 | 12 | extern zend_object * php_raylib_vector4_new(zend_class_entry * ce); 13 | 14 | extern zend_object * php_raylib_vector4_new_ex(zend_class_entry *ce, zend_object *orig); 15 | 16 | extern zend_object_handlers php_raylib_vector4_object_handlers; 17 | 18 | typedef enum { 19 | RL_VECTOR4_IS_POINTER, 20 | RL_VECTOR4_IS_VALUE 21 | } RLVector4DataType; 22 | 23 | typedef union { 24 | Vector4 *p; 25 | Vector4 v; 26 | } Vector4Union; 27 | 28 | struct RL_Vector4 { 29 | unsigned int id; 30 | char *guid; 31 | Vector4Union data; 32 | RLVector4DataType type; 33 | unsigned refCount; 34 | unsigned char deleted; 35 | }; 36 | 37 | static struct RL_Vector4 **RL_Vector4_Object_List; 38 | static hashmap *RL_Vector4_Object_Map; 39 | 40 | char* RL_Vector4_Hash_Id(char *str, size_t size); 41 | struct RL_Vector4* RL_Vector4_Create(); 42 | void RL_Vector4_Delete(struct RL_Vector4* object, int index); 43 | void RL_Vector4_Free(struct RL_Vector4* object); 44 | 45 | typedef struct _php_raylib_vector4_object { 46 | struct RL_Vector4 *vector4; 47 | HashTable *prop_handler; 48 | zend_object std; 49 | } php_raylib_vector4_object; 50 | 51 | static inline php_raylib_vector4_object *php_raylib_vector4_fetch_object(zend_object *obj) { 52 | return (php_raylib_vector4_object *)((char *)obj - XtOffsetOf(php_raylib_vector4_object, std)); 53 | } 54 | 55 | static inline Vector4 *php_raylib_vector4_fetch_data(php_raylib_vector4_object *obj) { 56 | Vector4 *my_vector4; 57 | if (obj->vector4->type == RL_VECTOR4_IS_POINTER) { 58 | my_vector4 = obj->vector4->data.p; 59 | } else { 60 | my_vector4 = &obj->vector4->data.v; 61 | } 62 | 63 | return my_vector4; 64 | } 65 | 66 | #define Z_VECTOR4_OBJ_P(zv) php_raylib_vector4_fetch_object(Z_OBJ_P(zv)); 67 | 68 | void php_raylib_vector4_startup(INIT_FUNC_ARGS); 69 | 70 | #endif //PHP_RAYLIB_VECTOR4_H 71 | -------------------------------------------------------------------------------- /image.h: -------------------------------------------------------------------------------- 1 | #ifndef PHP_RAYLIB_IMAGE_H 2 | #define PHP_RAYLIB_IMAGE_H 3 | 4 | #include "include/hashmap.h" 5 | 6 | extern zend_class_entry * php_raylib_image_ce; 7 | 8 | // External Free Objects - Prevent Circular Dependency 9 | 10 | extern void php_raylib_image_free_storage(zend_object * object); 11 | 12 | extern zend_object * php_raylib_image_new(zend_class_entry * ce); 13 | 14 | extern zend_object * php_raylib_image_new_ex(zend_class_entry *ce, zend_object *orig); 15 | 16 | extern zend_object_handlers php_raylib_image_object_handlers; 17 | 18 | typedef enum { 19 | RL_IMAGE_IS_POINTER, 20 | RL_IMAGE_IS_VALUE 21 | } RLImageDataType; 22 | 23 | typedef union { 24 | Image *p; 25 | Image v; 26 | } ImageUnion; 27 | 28 | struct RL_Image { 29 | unsigned int id; 30 | char *guid; 31 | ImageUnion data; 32 | RLImageDataType type; 33 | unsigned refCount; 34 | unsigned char deleted; 35 | }; 36 | 37 | static struct RL_Image **RL_Image_Object_List; 38 | static hashmap *RL_Image_Object_Map; 39 | 40 | char* RL_Image_Hash_Id(char *str, size_t size); 41 | struct RL_Image* RL_Image_Create(); 42 | void RL_Image_Delete(struct RL_Image* object, int index); 43 | void RL_Image_Free(struct RL_Image* object); 44 | 45 | typedef struct _php_raylib_image_object { 46 | struct RL_Image *image; 47 | HashTable *prop_handler; 48 | // Cannot support primitive data structure like void * (an array) as zval 49 | // zval data; 50 | zend_object std; 51 | } php_raylib_image_object; 52 | 53 | static inline php_raylib_image_object *php_raylib_image_fetch_object(zend_object *obj) { 54 | return (php_raylib_image_object *)((char *)obj - XtOffsetOf(php_raylib_image_object, std)); 55 | } 56 | 57 | static inline Image *php_raylib_image_fetch_data(php_raylib_image_object *obj) { 58 | Image *my_image; 59 | if (obj->image->type == RL_IMAGE_IS_POINTER) { 60 | my_image = obj->image->data.p; 61 | } else { 62 | my_image = &obj->image->data.v; 63 | } 64 | 65 | return my_image; 66 | } 67 | 68 | #define Z_IMAGE_OBJ_P(zv) php_raylib_image_fetch_object(Z_OBJ_P(zv)); 69 | 70 | void php_raylib_image_startup(INIT_FUNC_ARGS); 71 | 72 | #endif //PHP_RAYLIB_IMAGE_H 73 | -------------------------------------------------------------------------------- /sound.h: -------------------------------------------------------------------------------- 1 | #ifndef PHP_RAYLIB_SOUND_H 2 | #define PHP_RAYLIB_SOUND_H 3 | 4 | #include "include/hashmap.h" 5 | #include "audiostream.h" 6 | 7 | extern zend_class_entry * php_raylib_sound_ce; 8 | 9 | // External Free Objects - Prevent Circular Dependency 10 | extern void php_raylib_audiostream_free_storage(zend_object *object); 11 | 12 | extern void php_raylib_sound_free_storage(zend_object * object); 13 | 14 | extern zend_object * php_raylib_sound_new(zend_class_entry * ce); 15 | 16 | extern zend_object * php_raylib_sound_new_ex(zend_class_entry *ce, zend_object *orig); 17 | 18 | extern zend_object_handlers php_raylib_sound_object_handlers; 19 | 20 | typedef enum { 21 | RL_SOUND_IS_POINTER, 22 | RL_SOUND_IS_VALUE 23 | } RLSoundDataType; 24 | 25 | typedef union { 26 | Sound *p; 27 | Sound v; 28 | } SoundUnion; 29 | 30 | struct RL_Sound { 31 | unsigned int id; 32 | char *guid; 33 | SoundUnion data; 34 | RLSoundDataType type; 35 | unsigned refCount; 36 | unsigned char deleted; 37 | }; 38 | 39 | static struct RL_Sound **RL_Sound_Object_List; 40 | static hashmap *RL_Sound_Object_Map; 41 | 42 | char* RL_Sound_Hash_Id(char *str, size_t size); 43 | struct RL_Sound* RL_Sound_Create(); 44 | void RL_Sound_Delete(struct RL_Sound* object, int index); 45 | void RL_Sound_Free(struct RL_Sound* object); 46 | 47 | typedef struct _php_raylib_sound_object { 48 | struct RL_Sound *sound; 49 | HashTable *prop_handler; 50 | zval stream; 51 | zend_object std; 52 | } php_raylib_sound_object; 53 | 54 | static inline php_raylib_sound_object *php_raylib_sound_fetch_object(zend_object *obj) { 55 | return (php_raylib_sound_object *)((char *)obj - XtOffsetOf(php_raylib_sound_object, std)); 56 | } 57 | 58 | static inline Sound *php_raylib_sound_fetch_data(php_raylib_sound_object *obj) { 59 | Sound *my_sound; 60 | if (obj->sound->type == RL_SOUND_IS_POINTER) { 61 | my_sound = obj->sound->data.p; 62 | } else { 63 | my_sound = &obj->sound->data.v; 64 | } 65 | 66 | return my_sound; 67 | } 68 | 69 | #define Z_SOUND_OBJ_P(zv) php_raylib_sound_fetch_object(Z_OBJ_P(zv)); 70 | 71 | void php_raylib_sound_startup(INIT_FUNC_ARGS); 72 | 73 | #endif //PHP_RAYLIB_SOUND_H 74 | -------------------------------------------------------------------------------- /shader.h: -------------------------------------------------------------------------------- 1 | #ifndef PHP_RAYLIB_SHADER_H 2 | #define PHP_RAYLIB_SHADER_H 3 | 4 | #include "include/hashmap.h" 5 | 6 | extern zend_class_entry * php_raylib_shader_ce; 7 | 8 | // External Free Objects - Prevent Circular Dependency 9 | 10 | extern void php_raylib_shader_free_storage(zend_object * object); 11 | 12 | extern zend_object * php_raylib_shader_new(zend_class_entry * ce); 13 | 14 | extern zend_object * php_raylib_shader_new_ex(zend_class_entry *ce, zend_object *orig); 15 | 16 | extern zend_object_handlers php_raylib_shader_object_handlers; 17 | 18 | typedef enum { 19 | RL_SHADER_IS_POINTER, 20 | RL_SHADER_IS_VALUE 21 | } RLShaderDataType; 22 | 23 | typedef union { 24 | Shader *p; 25 | Shader v; 26 | } ShaderUnion; 27 | 28 | struct RL_Shader { 29 | unsigned int id; 30 | char *guid; 31 | ShaderUnion data; 32 | RLShaderDataType type; 33 | unsigned refCount; 34 | unsigned char deleted; 35 | }; 36 | 37 | static struct RL_Shader **RL_Shader_Object_List; 38 | static hashmap *RL_Shader_Object_Map; 39 | 40 | char* RL_Shader_Hash_Id(char *str, size_t size); 41 | struct RL_Shader* RL_Shader_Create(); 42 | void RL_Shader_Delete(struct RL_Shader* object, int index); 43 | void RL_Shader_Free(struct RL_Shader* object); 44 | 45 | typedef struct _php_raylib_shader_object { 46 | struct RL_Shader *shader; 47 | HashTable *prop_handler; 48 | // Cannot support primitive data structure like int * (an array) as zval 49 | // zval locs; 50 | zend_object std; 51 | } php_raylib_shader_object; 52 | 53 | static inline php_raylib_shader_object *php_raylib_shader_fetch_object(zend_object *obj) { 54 | return (php_raylib_shader_object *)((char *)obj - XtOffsetOf(php_raylib_shader_object, std)); 55 | } 56 | 57 | static inline Shader *php_raylib_shader_fetch_data(php_raylib_shader_object *obj) { 58 | Shader *my_shader; 59 | if (obj->shader->type == RL_SHADER_IS_POINTER) { 60 | my_shader = obj->shader->data.p; 61 | } else { 62 | my_shader = &obj->shader->data.v; 63 | } 64 | 65 | return my_shader; 66 | } 67 | 68 | #define Z_SHADER_OBJ_P(zv) php_raylib_shader_fetch_object(Z_OBJ_P(zv)); 69 | 70 | void php_raylib_shader_startup(INIT_FUNC_ARGS); 71 | 72 | #endif //PHP_RAYLIB_SHADER_H 73 | -------------------------------------------------------------------------------- /rectangle.h: -------------------------------------------------------------------------------- 1 | #ifndef PHP_RAYLIB_RECTANGLE_H 2 | #define PHP_RAYLIB_RECTANGLE_H 3 | 4 | #include "include/hashmap.h" 5 | 6 | extern zend_class_entry * php_raylib_rectangle_ce; 7 | 8 | // External Free Objects - Prevent Circular Dependency 9 | 10 | extern void php_raylib_rectangle_free_storage(zend_object * object); 11 | 12 | extern zend_object * php_raylib_rectangle_new(zend_class_entry * ce); 13 | 14 | extern zend_object * php_raylib_rectangle_new_ex(zend_class_entry *ce, zend_object *orig); 15 | 16 | extern zend_object_handlers php_raylib_rectangle_object_handlers; 17 | 18 | typedef enum { 19 | RL_RECTANGLE_IS_POINTER, 20 | RL_RECTANGLE_IS_VALUE 21 | } RLRectangleDataType; 22 | 23 | typedef union { 24 | Rectangle *p; 25 | Rectangle v; 26 | } RectangleUnion; 27 | 28 | struct RL_Rectangle { 29 | unsigned int id; 30 | char *guid; 31 | RectangleUnion data; 32 | RLRectangleDataType type; 33 | unsigned refCount; 34 | unsigned char deleted; 35 | }; 36 | 37 | static struct RL_Rectangle **RL_Rectangle_Object_List; 38 | static hashmap *RL_Rectangle_Object_Map; 39 | 40 | char* RL_Rectangle_Hash_Id(char *str, size_t size); 41 | struct RL_Rectangle* RL_Rectangle_Create(); 42 | void RL_Rectangle_Delete(struct RL_Rectangle* object, int index); 43 | void RL_Rectangle_Free(struct RL_Rectangle* object); 44 | 45 | typedef struct _php_raylib_rectangle_object { 46 | struct RL_Rectangle *rectangle; 47 | HashTable *prop_handler; 48 | zend_object std; 49 | } php_raylib_rectangle_object; 50 | 51 | static inline php_raylib_rectangle_object *php_raylib_rectangle_fetch_object(zend_object *obj) { 52 | return (php_raylib_rectangle_object *)((char *)obj - XtOffsetOf(php_raylib_rectangle_object, std)); 53 | } 54 | 55 | static inline Rectangle *php_raylib_rectangle_fetch_data(php_raylib_rectangle_object *obj) { 56 | Rectangle *my_rectangle; 57 | if (obj->rectangle->type == RL_RECTANGLE_IS_POINTER) { 58 | my_rectangle = obj->rectangle->data.p; 59 | } else { 60 | my_rectangle = &obj->rectangle->data.v; 61 | } 62 | 63 | return my_rectangle; 64 | } 65 | 66 | #define Z_RECTANGLE_OBJ_P(zv) php_raylib_rectangle_fetch_object(Z_OBJ_P(zv)); 67 | 68 | void php_raylib_rectangle_startup(INIT_FUNC_ARGS); 69 | 70 | #endif //PHP_RAYLIB_RECTANGLE_H 71 | -------------------------------------------------------------------------------- /music.h: -------------------------------------------------------------------------------- 1 | #ifndef PHP_RAYLIB_MUSIC_H 2 | #define PHP_RAYLIB_MUSIC_H 3 | 4 | #include "include/hashmap.h" 5 | #include "audiostream.h" 6 | 7 | extern zend_class_entry * php_raylib_music_ce; 8 | 9 | // External Free Objects - Prevent Circular Dependency 10 | extern void php_raylib_audiostream_free_storage(zend_object *object); 11 | 12 | extern void php_raylib_music_free_storage(zend_object * object); 13 | 14 | extern zend_object * php_raylib_music_new(zend_class_entry * ce); 15 | 16 | extern zend_object * php_raylib_music_new_ex(zend_class_entry *ce, zend_object *orig); 17 | 18 | extern zend_object_handlers php_raylib_music_object_handlers; 19 | 20 | typedef enum { 21 | RL_MUSIC_IS_POINTER, 22 | RL_MUSIC_IS_VALUE 23 | } RLMusicDataType; 24 | 25 | typedef union { 26 | Music *p; 27 | Music v; 28 | } MusicUnion; 29 | 30 | struct RL_Music { 31 | unsigned int id; 32 | char *guid; 33 | MusicUnion data; 34 | RLMusicDataType type; 35 | unsigned refCount; 36 | unsigned char deleted; 37 | }; 38 | 39 | static struct RL_Music **RL_Music_Object_List; 40 | static hashmap *RL_Music_Object_Map; 41 | 42 | char* RL_Music_Hash_Id(char *str, size_t size); 43 | struct RL_Music* RL_Music_Create(); 44 | void RL_Music_Delete(struct RL_Music* object, int index); 45 | void RL_Music_Free(struct RL_Music* object); 46 | 47 | typedef struct _php_raylib_music_object { 48 | struct RL_Music *music; 49 | HashTable *prop_handler; 50 | zval stream; 51 | // Cannot support primitive data structure like void * (an array) as zval 52 | // zval ctxdata; 53 | zend_object std; 54 | } php_raylib_music_object; 55 | 56 | static inline php_raylib_music_object *php_raylib_music_fetch_object(zend_object *obj) { 57 | return (php_raylib_music_object *)((char *)obj - XtOffsetOf(php_raylib_music_object, std)); 58 | } 59 | 60 | static inline Music *php_raylib_music_fetch_data(php_raylib_music_object *obj) { 61 | Music *my_music; 62 | if (obj->music->type == RL_MUSIC_IS_POINTER) { 63 | my_music = obj->music->data.p; 64 | } else { 65 | my_music = &obj->music->data.v; 66 | } 67 | 68 | return my_music; 69 | } 70 | 71 | #define Z_MUSIC_OBJ_P(zv) php_raylib_music_fetch_object(Z_OBJ_P(zv)); 72 | 73 | void php_raylib_music_startup(INIT_FUNC_ARGS); 74 | 75 | #endif //PHP_RAYLIB_MUSIC_H 76 | -------------------------------------------------------------------------------- /boneinfo.h: -------------------------------------------------------------------------------- 1 | #ifndef PHP_RAYLIB_BONEINFO_H 2 | #define PHP_RAYLIB_BONEINFO_H 3 | 4 | #include "include/hashmap.h" 5 | 6 | extern zend_class_entry * php_raylib_boneinfo_ce; 7 | 8 | // External Free Objects - Prevent Circular Dependency 9 | 10 | extern void php_raylib_boneinfo_free_storage(zend_object * object); 11 | 12 | extern zend_object * php_raylib_boneinfo_new(zend_class_entry * ce); 13 | 14 | extern zend_object * php_raylib_boneinfo_new_ex(zend_class_entry *ce, zend_object *orig); 15 | 16 | extern zend_object_handlers php_raylib_boneinfo_object_handlers; 17 | 18 | typedef enum { 19 | RL_BONEINFO_IS_POINTER, 20 | RL_BONEINFO_IS_VALUE 21 | } RLBoneInfoDataType; 22 | 23 | typedef union { 24 | BoneInfo *p; 25 | BoneInfo v; 26 | } BoneInfoUnion; 27 | 28 | struct RL_BoneInfo { 29 | unsigned int id; 30 | char *guid; 31 | BoneInfoUnion data; 32 | RLBoneInfoDataType type; 33 | unsigned refCount; 34 | unsigned char deleted; 35 | }; 36 | 37 | static struct RL_BoneInfo **RL_BoneInfo_Object_List; 38 | static hashmap *RL_BoneInfo_Object_Map; 39 | 40 | char* RL_BoneInfo_Hash_Id(char *str, size_t size); 41 | struct RL_BoneInfo* RL_BoneInfo_Create(); 42 | void RL_BoneInfo_Delete(struct RL_BoneInfo* object, int index); 43 | void RL_BoneInfo_Free(struct RL_BoneInfo* object); 44 | 45 | typedef struct _php_raylib_boneinfo_object { 46 | struct RL_BoneInfo *boneinfo; 47 | HashTable *prop_handler; 48 | // Cannot support primitive data structure like char (an array) as zval 49 | // zval name; 50 | zend_object std; 51 | } php_raylib_boneinfo_object; 52 | 53 | static inline php_raylib_boneinfo_object *php_raylib_boneinfo_fetch_object(zend_object *obj) { 54 | return (php_raylib_boneinfo_object *)((char *)obj - XtOffsetOf(php_raylib_boneinfo_object, std)); 55 | } 56 | 57 | static inline BoneInfo *php_raylib_boneinfo_fetch_data(php_raylib_boneinfo_object *obj) { 58 | BoneInfo *my_boneinfo; 59 | if (obj->boneinfo->type == RL_BONEINFO_IS_POINTER) { 60 | my_boneinfo = obj->boneinfo->data.p; 61 | } else { 62 | my_boneinfo = &obj->boneinfo->data.v; 63 | } 64 | 65 | return my_boneinfo; 66 | } 67 | 68 | #define Z_BONEINFO_OBJ_P(zv) php_raylib_boneinfo_fetch_object(Z_OBJ_P(zv)); 69 | 70 | void php_raylib_boneinfo_startup(INIT_FUNC_ARGS); 71 | 72 | #endif //PHP_RAYLIB_BONEINFO_H 73 | -------------------------------------------------------------------------------- /camera2d.h: -------------------------------------------------------------------------------- 1 | #ifndef PHP_RAYLIB_CAMERA2D_H 2 | #define PHP_RAYLIB_CAMERA2D_H 3 | 4 | #include "include/hashmap.h" 5 | #include "vector2.h" 6 | 7 | extern zend_class_entry * php_raylib_camera2d_ce; 8 | 9 | // External Free Objects - Prevent Circular Dependency 10 | extern void php_raylib_vector2_free_storage(zend_object *object); 11 | 12 | extern void php_raylib_camera2d_free_storage(zend_object * object); 13 | 14 | extern zend_object * php_raylib_camera2d_new(zend_class_entry * ce); 15 | 16 | extern zend_object * php_raylib_camera2d_new_ex(zend_class_entry *ce, zend_object *orig); 17 | 18 | extern zend_object_handlers php_raylib_camera2d_object_handlers; 19 | 20 | typedef enum { 21 | RL_CAMERA2D_IS_POINTER, 22 | RL_CAMERA2D_IS_VALUE 23 | } RLCamera2DDataType; 24 | 25 | typedef union { 26 | Camera2D *p; 27 | Camera2D v; 28 | } Camera2DUnion; 29 | 30 | struct RL_Camera2D { 31 | unsigned int id; 32 | char *guid; 33 | Camera2DUnion data; 34 | RLCamera2DDataType type; 35 | unsigned refCount; 36 | unsigned char deleted; 37 | }; 38 | 39 | static struct RL_Camera2D **RL_Camera2D_Object_List; 40 | static hashmap *RL_Camera2D_Object_Map; 41 | 42 | char* RL_Camera2D_Hash_Id(char *str, size_t size); 43 | struct RL_Camera2D* RL_Camera2D_Create(); 44 | void RL_Camera2D_Delete(struct RL_Camera2D* object, int index); 45 | void RL_Camera2D_Free(struct RL_Camera2D* object); 46 | 47 | typedef struct _php_raylib_camera2d_object { 48 | struct RL_Camera2D *camera2d; 49 | HashTable *prop_handler; 50 | zval offset; 51 | zval target; 52 | zend_object std; 53 | } php_raylib_camera2d_object; 54 | 55 | static inline php_raylib_camera2d_object *php_raylib_camera2d_fetch_object(zend_object *obj) { 56 | return (php_raylib_camera2d_object *)((char *)obj - XtOffsetOf(php_raylib_camera2d_object, std)); 57 | } 58 | 59 | static inline Camera2D *php_raylib_camera2d_fetch_data(php_raylib_camera2d_object *obj) { 60 | Camera2D *my_camera2d; 61 | if (obj->camera2d->type == RL_CAMERA2D_IS_POINTER) { 62 | my_camera2d = obj->camera2d->data.p; 63 | } else { 64 | my_camera2d = &obj->camera2d->data.v; 65 | } 66 | 67 | return my_camera2d; 68 | } 69 | 70 | #define Z_CAMERA2D_OBJ_P(zv) php_raylib_camera2d_fetch_object(Z_OBJ_P(zv)); 71 | 72 | void php_raylib_camera2d_startup(INIT_FUNC_ARGS); 73 | 74 | #endif //PHP_RAYLIB_CAMERA2D_H 75 | -------------------------------------------------------------------------------- /camera3d.h: -------------------------------------------------------------------------------- 1 | #ifndef PHP_RAYLIB_CAMERA3D_H 2 | #define PHP_RAYLIB_CAMERA3D_H 3 | 4 | #include "include/hashmap.h" 5 | #include "vector3.h" 6 | 7 | extern zend_class_entry * php_raylib_camera3d_ce; 8 | 9 | // External Free Objects - Prevent Circular Dependency 10 | extern void php_raylib_vector3_free_storage(zend_object *object); 11 | 12 | extern void php_raylib_camera3d_free_storage(zend_object * object); 13 | 14 | extern zend_object * php_raylib_camera3d_new(zend_class_entry * ce); 15 | 16 | extern zend_object * php_raylib_camera3d_new_ex(zend_class_entry *ce, zend_object *orig); 17 | 18 | extern zend_object_handlers php_raylib_camera3d_object_handlers; 19 | 20 | typedef enum { 21 | RL_CAMERA3D_IS_POINTER, 22 | RL_CAMERA3D_IS_VALUE 23 | } RLCamera3DDataType; 24 | 25 | typedef union { 26 | Camera3D *p; 27 | Camera3D v; 28 | } Camera3DUnion; 29 | 30 | struct RL_Camera3D { 31 | unsigned int id; 32 | char *guid; 33 | Camera3DUnion data; 34 | RLCamera3DDataType type; 35 | unsigned refCount; 36 | unsigned char deleted; 37 | }; 38 | 39 | static struct RL_Camera3D **RL_Camera3D_Object_List; 40 | static hashmap *RL_Camera3D_Object_Map; 41 | 42 | char* RL_Camera3D_Hash_Id(char *str, size_t size); 43 | struct RL_Camera3D* RL_Camera3D_Create(); 44 | void RL_Camera3D_Delete(struct RL_Camera3D* object, int index); 45 | void RL_Camera3D_Free(struct RL_Camera3D* object); 46 | 47 | typedef struct _php_raylib_camera3d_object { 48 | struct RL_Camera3D *camera3d; 49 | HashTable *prop_handler; 50 | zval position; 51 | zval target; 52 | zval up; 53 | zend_object std; 54 | } php_raylib_camera3d_object; 55 | 56 | static inline php_raylib_camera3d_object *php_raylib_camera3d_fetch_object(zend_object *obj) { 57 | return (php_raylib_camera3d_object *)((char *)obj - XtOffsetOf(php_raylib_camera3d_object, std)); 58 | } 59 | 60 | static inline Camera3D *php_raylib_camera3d_fetch_data(php_raylib_camera3d_object *obj) { 61 | Camera3D *my_camera3d; 62 | if (obj->camera3d->type == RL_CAMERA3D_IS_POINTER) { 63 | my_camera3d = obj->camera3d->data.p; 64 | } else { 65 | my_camera3d = &obj->camera3d->data.v; 66 | } 67 | 68 | return my_camera3d; 69 | } 70 | 71 | #define Z_CAMERA3D_OBJ_P(zv) php_raylib_camera3d_fetch_object(Z_OBJ_P(zv)); 72 | 73 | void php_raylib_camera3d_startup(INIT_FUNC_ARGS); 74 | 75 | #endif //PHP_RAYLIB_CAMERA3D_H 76 | -------------------------------------------------------------------------------- /glyphinfo.h: -------------------------------------------------------------------------------- 1 | #ifndef PHP_RAYLIB_GLYPHINFO_H 2 | #define PHP_RAYLIB_GLYPHINFO_H 3 | 4 | #include "include/hashmap.h" 5 | #include "image.h" 6 | 7 | extern zend_class_entry * php_raylib_glyphinfo_ce; 8 | 9 | // External Free Objects - Prevent Circular Dependency 10 | extern void php_raylib_image_free_storage(zend_object *object); 11 | 12 | extern void php_raylib_glyphinfo_free_storage(zend_object * object); 13 | 14 | extern zend_object * php_raylib_glyphinfo_new(zend_class_entry * ce); 15 | 16 | extern zend_object * php_raylib_glyphinfo_new_ex(zend_class_entry *ce, zend_object *orig); 17 | 18 | extern zend_object_handlers php_raylib_glyphinfo_object_handlers; 19 | 20 | typedef enum { 21 | RL_GLYPHINFO_IS_POINTER, 22 | RL_GLYPHINFO_IS_VALUE 23 | } RLGlyphInfoDataType; 24 | 25 | typedef union { 26 | GlyphInfo *p; 27 | GlyphInfo v; 28 | } GlyphInfoUnion; 29 | 30 | struct RL_GlyphInfo { 31 | unsigned int id; 32 | char *guid; 33 | GlyphInfoUnion data; 34 | RLGlyphInfoDataType type; 35 | unsigned refCount; 36 | unsigned char deleted; 37 | }; 38 | 39 | static struct RL_GlyphInfo **RL_GlyphInfo_Object_List; 40 | static hashmap *RL_GlyphInfo_Object_Map; 41 | 42 | char* RL_GlyphInfo_Hash_Id(char *str, size_t size); 43 | struct RL_GlyphInfo* RL_GlyphInfo_Create(); 44 | void RL_GlyphInfo_Delete(struct RL_GlyphInfo* object, int index); 45 | void RL_GlyphInfo_Free(struct RL_GlyphInfo* object); 46 | 47 | typedef struct _php_raylib_glyphinfo_object { 48 | struct RL_GlyphInfo *glyphinfo; 49 | HashTable *prop_handler; 50 | zval image; 51 | zend_object std; 52 | } php_raylib_glyphinfo_object; 53 | 54 | static inline php_raylib_glyphinfo_object *php_raylib_glyphinfo_fetch_object(zend_object *obj) { 55 | return (php_raylib_glyphinfo_object *)((char *)obj - XtOffsetOf(php_raylib_glyphinfo_object, std)); 56 | } 57 | 58 | static inline GlyphInfo *php_raylib_glyphinfo_fetch_data(php_raylib_glyphinfo_object *obj) { 59 | GlyphInfo *my_glyphinfo; 60 | if (obj->glyphinfo->type == RL_GLYPHINFO_IS_POINTER) { 61 | my_glyphinfo = obj->glyphinfo->data.p; 62 | } else { 63 | my_glyphinfo = &obj->glyphinfo->data.v; 64 | } 65 | 66 | return my_glyphinfo; 67 | } 68 | 69 | #define Z_GLYPHINFO_OBJ_P(zv) php_raylib_glyphinfo_fetch_object(Z_OBJ_P(zv)); 70 | 71 | void php_raylib_glyphinfo_startup(INIT_FUNC_ARGS); 72 | 73 | #endif //PHP_RAYLIB_GLYPHINFO_H 74 | -------------------------------------------------------------------------------- /filepathlist.h: -------------------------------------------------------------------------------- 1 | #ifndef PHP_RAYLIB_FILEPATHLIST_H 2 | #define PHP_RAYLIB_FILEPATHLIST_H 3 | 4 | #include "include/hashmap.h" 5 | 6 | extern zend_class_entry * php_raylib_filepathlist_ce; 7 | 8 | // External Free Objects - Prevent Circular Dependency 9 | 10 | extern void php_raylib_filepathlist_free_storage(zend_object * object); 11 | 12 | extern zend_object * php_raylib_filepathlist_new(zend_class_entry * ce); 13 | 14 | extern zend_object * php_raylib_filepathlist_new_ex(zend_class_entry *ce, zend_object *orig); 15 | 16 | extern zend_object_handlers php_raylib_filepathlist_object_handlers; 17 | 18 | typedef enum { 19 | RL_FILEPATHLIST_IS_POINTER, 20 | RL_FILEPATHLIST_IS_VALUE 21 | } RLFilePathListDataType; 22 | 23 | typedef union { 24 | FilePathList *p; 25 | FilePathList v; 26 | } FilePathListUnion; 27 | 28 | struct RL_FilePathList { 29 | unsigned int id; 30 | char *guid; 31 | FilePathListUnion data; 32 | RLFilePathListDataType type; 33 | unsigned refCount; 34 | unsigned char deleted; 35 | }; 36 | 37 | static struct RL_FilePathList **RL_FilePathList_Object_List; 38 | static hashmap *RL_FilePathList_Object_Map; 39 | 40 | char* RL_FilePathList_Hash_Id(char *str, size_t size); 41 | struct RL_FilePathList* RL_FilePathList_Create(); 42 | void RL_FilePathList_Delete(struct RL_FilePathList* object, int index); 43 | void RL_FilePathList_Free(struct RL_FilePathList* object); 44 | 45 | typedef struct _php_raylib_filepathlist_object { 46 | struct RL_FilePathList *filepathlist; 47 | HashTable *prop_handler; 48 | zend_object std; 49 | } php_raylib_filepathlist_object; 50 | 51 | static inline php_raylib_filepathlist_object *php_raylib_filepathlist_fetch_object(zend_object *obj) { 52 | return (php_raylib_filepathlist_object *)((char *)obj - XtOffsetOf(php_raylib_filepathlist_object, std)); 53 | } 54 | 55 | static inline FilePathList *php_raylib_filepathlist_fetch_data(php_raylib_filepathlist_object *obj) { 56 | FilePathList *my_filepathlist; 57 | if (obj->filepathlist->type == RL_FILEPATHLIST_IS_POINTER) { 58 | my_filepathlist = obj->filepathlist->data.p; 59 | } else { 60 | my_filepathlist = &obj->filepathlist->data.v; 61 | } 62 | 63 | return my_filepathlist; 64 | } 65 | 66 | #define Z_FILEPATHLIST_OBJ_P(zv) php_raylib_filepathlist_fetch_object(Z_OBJ_P(zv)); 67 | 68 | void php_raylib_filepathlist_startup(INIT_FUNC_ARGS); 69 | 70 | #endif //PHP_RAYLIB_FILEPATHLIST_H 71 | -------------------------------------------------------------------------------- /bundle/runtime/build.rs: -------------------------------------------------------------------------------- 1 | extern crate bindgen; 2 | 3 | use std::env; 4 | use std::path::PathBuf; 5 | use std::process::Command; 6 | 7 | fn main() { 8 | let manifest_dir = env::var("CARGO_MANIFEST_DIR").unwrap(); 9 | 10 | // Get the path to the PHP include directory 11 | // let include_path = PathBuf::from(&manifest_dir).join("../../external/php-src/include"); 12 | // let php_include_path = include_path.display(); 13 | let php_include_path = "/usr/local/include"; 14 | let zend_include_path = "/usr/local/include/php"; 15 | 16 | // Generate the bindings 17 | let bindings = bindgen::Builder::default() 18 | .clang_arg(format!("-I{}/main", zend_include_path)) 19 | .clang_arg(format!("-I{}/Zend", zend_include_path)) 20 | .clang_arg(format!("-I{}/TSRM", zend_include_path)) 21 | .clang_arg(format!("-I{}", zend_include_path)) 22 | .header(format!("{}/php/main/php.h", php_include_path)) 23 | .clang_arg("-DHAVE_SIGSETJMP") 24 | .allowlist_type("_zend_executor_globals") 25 | .generate() 26 | .expect("Failed to generate bindings"); 27 | 28 | // Write the bindings to the src/bindings.rs file 29 | let out_path = PathBuf::from(env::var("CARGO_MANIFEST_DIR").unwrap()); 30 | bindings 31 | .write_to_file(out_path.join("zend-bindings.rs")) 32 | .expect("Couldn't write bindings!"); 33 | 34 | 35 | let lib_path = PathBuf::from(&manifest_dir).join("../../external/php-src/libs"); 36 | 37 | println!("cargo:rustc-link-search=native={}", lib_path.display()); 38 | println!("cargo:rustc-link-lib=static=php"); 39 | 40 | // Depending on PHP's dependencies, you may need to link additional libraries. 41 | println!("cargo:rustc-link-lib=dylib=xml2"); 42 | println!("cargo:rustc-link-lib=dylib=sqlite3"); 43 | println!("cargo:rustc-link-lib=dylib=resolv"); 44 | 45 | // Getting libiconv path from Homebrew 46 | let libiconv_prefix = Command::new("brew") 47 | .arg("--prefix") 48 | .arg("libiconv") 49 | .output() 50 | .expect("Failed to get libiconv prefix") 51 | .stdout; 52 | let libiconv_prefix = String::from_utf8(libiconv_prefix).expect("Failed to convert libiconv prefix to string"); 53 | let libiconv_path = libiconv_prefix.trim().to_owned() + "/lib"; 54 | 55 | println!("cargo:rustc-link-search=native={}", libiconv_path); 56 | println!("cargo:rustc-link-lib=dylib=iconv"); 57 | } -------------------------------------------------------------------------------- /npatchinfo.h: -------------------------------------------------------------------------------- 1 | #ifndef PHP_RAYLIB_NPATCHINFO_H 2 | #define PHP_RAYLIB_NPATCHINFO_H 3 | 4 | #include "include/hashmap.h" 5 | #include "rectangle.h" 6 | 7 | extern zend_class_entry * php_raylib_npatchinfo_ce; 8 | 9 | // External Free Objects - Prevent Circular Dependency 10 | extern void php_raylib_rectangle_free_storage(zend_object *object); 11 | 12 | extern void php_raylib_npatchinfo_free_storage(zend_object * object); 13 | 14 | extern zend_object * php_raylib_npatchinfo_new(zend_class_entry * ce); 15 | 16 | extern zend_object * php_raylib_npatchinfo_new_ex(zend_class_entry *ce, zend_object *orig); 17 | 18 | extern zend_object_handlers php_raylib_npatchinfo_object_handlers; 19 | 20 | typedef enum { 21 | RL_NPATCHINFO_IS_POINTER, 22 | RL_NPATCHINFO_IS_VALUE 23 | } RLNPatchInfoDataType; 24 | 25 | typedef union { 26 | NPatchInfo *p; 27 | NPatchInfo v; 28 | } NPatchInfoUnion; 29 | 30 | struct RL_NPatchInfo { 31 | unsigned int id; 32 | char *guid; 33 | NPatchInfoUnion data; 34 | RLNPatchInfoDataType type; 35 | unsigned refCount; 36 | unsigned char deleted; 37 | }; 38 | 39 | static struct RL_NPatchInfo **RL_NPatchInfo_Object_List; 40 | static hashmap *RL_NPatchInfo_Object_Map; 41 | 42 | char* RL_NPatchInfo_Hash_Id(char *str, size_t size); 43 | struct RL_NPatchInfo* RL_NPatchInfo_Create(); 44 | void RL_NPatchInfo_Delete(struct RL_NPatchInfo* object, int index); 45 | void RL_NPatchInfo_Free(struct RL_NPatchInfo* object); 46 | 47 | typedef struct _php_raylib_npatchinfo_object { 48 | struct RL_NPatchInfo *npatchinfo; 49 | HashTable *prop_handler; 50 | zval source; 51 | zend_object std; 52 | } php_raylib_npatchinfo_object; 53 | 54 | static inline php_raylib_npatchinfo_object *php_raylib_npatchinfo_fetch_object(zend_object *obj) { 55 | return (php_raylib_npatchinfo_object *)((char *)obj - XtOffsetOf(php_raylib_npatchinfo_object, std)); 56 | } 57 | 58 | static inline NPatchInfo *php_raylib_npatchinfo_fetch_data(php_raylib_npatchinfo_object *obj) { 59 | NPatchInfo *my_npatchinfo; 60 | if (obj->npatchinfo->type == RL_NPATCHINFO_IS_POINTER) { 61 | my_npatchinfo = obj->npatchinfo->data.p; 62 | } else { 63 | my_npatchinfo = &obj->npatchinfo->data.v; 64 | } 65 | 66 | return my_npatchinfo; 67 | } 68 | 69 | #define Z_NPATCHINFO_OBJ_P(zv) php_raylib_npatchinfo_fetch_object(Z_OBJ_P(zv)); 70 | 71 | void php_raylib_npatchinfo_startup(INIT_FUNC_ARGS); 72 | 73 | #endif //PHP_RAYLIB_NPATCHINFO_H 74 | -------------------------------------------------------------------------------- /font.h: -------------------------------------------------------------------------------- 1 | #ifndef PHP_RAYLIB_FONT_H 2 | #define PHP_RAYLIB_FONT_H 3 | 4 | #include "include/hashmap.h" 5 | #include "texture.h" 6 | #include "rectangle.h" 7 | #include "glyphinfo.h" 8 | 9 | extern zend_class_entry * php_raylib_font_ce; 10 | 11 | // External Free Objects - Prevent Circular Dependency 12 | extern void php_raylib_texture_free_storage(zend_object *object); 13 | //TODO: Support array/hash 14 | //extern void php_raylib_rectangle_array_free_storage(zend_object *object); 15 | //TODO: Support array/hash 16 | //extern void php_raylib_glyphinfo_array_free_storage(zend_object *object); 17 | 18 | extern void php_raylib_font_free_storage(zend_object * object); 19 | 20 | extern zend_object * php_raylib_font_new(zend_class_entry * ce); 21 | 22 | extern zend_object * php_raylib_font_new_ex(zend_class_entry *ce, zend_object *orig); 23 | 24 | extern zend_object_handlers php_raylib_font_object_handlers; 25 | 26 | typedef enum { 27 | RL_FONT_IS_POINTER, 28 | RL_FONT_IS_VALUE 29 | } RLFontDataType; 30 | 31 | typedef union { 32 | Font *p; 33 | Font v; 34 | } FontUnion; 35 | 36 | struct RL_Font { 37 | unsigned int id; 38 | char *guid; 39 | FontUnion data; 40 | RLFontDataType type; 41 | unsigned refCount; 42 | unsigned char deleted; 43 | }; 44 | 45 | static struct RL_Font **RL_Font_Object_List; 46 | static hashmap *RL_Font_Object_Map; 47 | 48 | char* RL_Font_Hash_Id(char *str, size_t size); 49 | struct RL_Font* RL_Font_Create(); 50 | void RL_Font_Delete(struct RL_Font* object, int index); 51 | void RL_Font_Free(struct RL_Font* object); 52 | 53 | typedef struct _php_raylib_font_object { 54 | struct RL_Font *font; 55 | HashTable *prop_handler; 56 | zval texture; 57 | zval recs; 58 | zval glyphs; 59 | zend_object std; 60 | } php_raylib_font_object; 61 | 62 | static inline php_raylib_font_object *php_raylib_font_fetch_object(zend_object *obj) { 63 | return (php_raylib_font_object *)((char *)obj - XtOffsetOf(php_raylib_font_object, std)); 64 | } 65 | 66 | static inline Font *php_raylib_font_fetch_data(php_raylib_font_object *obj) { 67 | Font *my_font; 68 | if (obj->font->type == RL_FONT_IS_POINTER) { 69 | my_font = obj->font->data.p; 70 | } else { 71 | my_font = &obj->font->data.v; 72 | } 73 | 74 | return my_font; 75 | } 76 | 77 | #define Z_FONT_OBJ_P(zv) php_raylib_font_fetch_object(Z_OBJ_P(zv)); 78 | 79 | void php_raylib_font_startup(INIT_FUNC_ARGS); 80 | 81 | #endif //PHP_RAYLIB_FONT_H 82 | -------------------------------------------------------------------------------- /boundingbox.h: -------------------------------------------------------------------------------- 1 | #ifndef PHP_RAYLIB_BOUNDINGBOX_H 2 | #define PHP_RAYLIB_BOUNDINGBOX_H 3 | 4 | #include "include/hashmap.h" 5 | #include "vector3.h" 6 | 7 | extern zend_class_entry * php_raylib_boundingbox_ce; 8 | 9 | // External Free Objects - Prevent Circular Dependency 10 | extern void php_raylib_vector3_free_storage(zend_object *object); 11 | 12 | extern void php_raylib_boundingbox_free_storage(zend_object * object); 13 | 14 | extern zend_object * php_raylib_boundingbox_new(zend_class_entry * ce); 15 | 16 | extern zend_object * php_raylib_boundingbox_new_ex(zend_class_entry *ce, zend_object *orig); 17 | 18 | extern zend_object_handlers php_raylib_boundingbox_object_handlers; 19 | 20 | typedef enum { 21 | RL_BOUNDINGBOX_IS_POINTER, 22 | RL_BOUNDINGBOX_IS_VALUE 23 | } RLBoundingBoxDataType; 24 | 25 | typedef union { 26 | BoundingBox *p; 27 | BoundingBox v; 28 | } BoundingBoxUnion; 29 | 30 | struct RL_BoundingBox { 31 | unsigned int id; 32 | char *guid; 33 | BoundingBoxUnion data; 34 | RLBoundingBoxDataType type; 35 | unsigned refCount; 36 | unsigned char deleted; 37 | }; 38 | 39 | static struct RL_BoundingBox **RL_BoundingBox_Object_List; 40 | static hashmap *RL_BoundingBox_Object_Map; 41 | 42 | char* RL_BoundingBox_Hash_Id(char *str, size_t size); 43 | struct RL_BoundingBox* RL_BoundingBox_Create(); 44 | void RL_BoundingBox_Delete(struct RL_BoundingBox* object, int index); 45 | void RL_BoundingBox_Free(struct RL_BoundingBox* object); 46 | 47 | typedef struct _php_raylib_boundingbox_object { 48 | struct RL_BoundingBox *boundingbox; 49 | HashTable *prop_handler; 50 | zval min; 51 | zval max; 52 | zend_object std; 53 | } php_raylib_boundingbox_object; 54 | 55 | static inline php_raylib_boundingbox_object *php_raylib_boundingbox_fetch_object(zend_object *obj) { 56 | return (php_raylib_boundingbox_object *)((char *)obj - XtOffsetOf(php_raylib_boundingbox_object, std)); 57 | } 58 | 59 | static inline BoundingBox *php_raylib_boundingbox_fetch_data(php_raylib_boundingbox_object *obj) { 60 | BoundingBox *my_boundingbox; 61 | if (obj->boundingbox->type == RL_BOUNDINGBOX_IS_POINTER) { 62 | my_boundingbox = obj->boundingbox->data.p; 63 | } else { 64 | my_boundingbox = &obj->boundingbox->data.v; 65 | } 66 | 67 | return my_boundingbox; 68 | } 69 | 70 | #define Z_BOUNDINGBOX_OBJ_P(zv) php_raylib_boundingbox_fetch_object(Z_OBJ_P(zv)); 71 | 72 | void php_raylib_boundingbox_startup(INIT_FUNC_ARGS); 73 | 74 | #endif //PHP_RAYLIB_BOUNDINGBOX_H 75 | -------------------------------------------------------------------------------- /transform.h: -------------------------------------------------------------------------------- 1 | #ifndef PHP_RAYLIB_TRANSFORM_H 2 | #define PHP_RAYLIB_TRANSFORM_H 3 | 4 | #include "include/hashmap.h" 5 | #include "vector3.h" 6 | #include "vector4.h" 7 | 8 | extern zend_class_entry * php_raylib_transform_ce; 9 | 10 | // External Free Objects - Prevent Circular Dependency 11 | extern void php_raylib_vector3_free_storage(zend_object *object); 12 | extern void php_raylib_vector4_free_storage(zend_object *object); 13 | 14 | extern void php_raylib_transform_free_storage(zend_object * object); 15 | 16 | extern zend_object * php_raylib_transform_new(zend_class_entry * ce); 17 | 18 | extern zend_object * php_raylib_transform_new_ex(zend_class_entry *ce, zend_object *orig); 19 | 20 | extern zend_object_handlers php_raylib_transform_object_handlers; 21 | 22 | typedef enum { 23 | RL_TRANSFORM_IS_POINTER, 24 | RL_TRANSFORM_IS_VALUE 25 | } RLTransformDataType; 26 | 27 | typedef union { 28 | Transform *p; 29 | Transform v; 30 | } TransformUnion; 31 | 32 | struct RL_Transform { 33 | unsigned int id; 34 | char *guid; 35 | TransformUnion data; 36 | RLTransformDataType type; 37 | unsigned refCount; 38 | unsigned char deleted; 39 | }; 40 | 41 | static struct RL_Transform **RL_Transform_Object_List; 42 | static hashmap *RL_Transform_Object_Map; 43 | 44 | char* RL_Transform_Hash_Id(char *str, size_t size); 45 | struct RL_Transform* RL_Transform_Create(); 46 | void RL_Transform_Delete(struct RL_Transform* object, int index); 47 | void RL_Transform_Free(struct RL_Transform* object); 48 | 49 | typedef struct _php_raylib_transform_object { 50 | struct RL_Transform *transform; 51 | HashTable *prop_handler; 52 | zval translation; 53 | zval rotation; 54 | zval scale; 55 | zend_object std; 56 | } php_raylib_transform_object; 57 | 58 | static inline php_raylib_transform_object *php_raylib_transform_fetch_object(zend_object *obj) { 59 | return (php_raylib_transform_object *)((char *)obj - XtOffsetOf(php_raylib_transform_object, std)); 60 | } 61 | 62 | static inline Transform *php_raylib_transform_fetch_data(php_raylib_transform_object *obj) { 63 | Transform *my_transform; 64 | if (obj->transform->type == RL_TRANSFORM_IS_POINTER) { 65 | my_transform = obj->transform->data.p; 66 | } else { 67 | my_transform = &obj->transform->data.v; 68 | } 69 | 70 | return my_transform; 71 | } 72 | 73 | #define Z_TRANSFORM_OBJ_P(zv) php_raylib_transform_fetch_object(Z_OBJ_P(zv)); 74 | 75 | void php_raylib_transform_startup(INIT_FUNC_ARGS); 76 | 77 | #endif //PHP_RAYLIB_TRANSFORM_H 78 | -------------------------------------------------------------------------------- /raycollision.h: -------------------------------------------------------------------------------- 1 | #ifndef PHP_RAYLIB_RAYCOLLISION_H 2 | #define PHP_RAYLIB_RAYCOLLISION_H 3 | 4 | #include "include/hashmap.h" 5 | #include "vector3.h" 6 | 7 | extern zend_class_entry * php_raylib_raycollision_ce; 8 | 9 | // External Free Objects - Prevent Circular Dependency 10 | extern void php_raylib_vector3_free_storage(zend_object *object); 11 | 12 | extern void php_raylib_raycollision_free_storage(zend_object * object); 13 | 14 | extern zend_object * php_raylib_raycollision_new(zend_class_entry * ce); 15 | 16 | extern zend_object * php_raylib_raycollision_new_ex(zend_class_entry *ce, zend_object *orig); 17 | 18 | extern zend_object_handlers php_raylib_raycollision_object_handlers; 19 | 20 | typedef enum { 21 | RL_RAYCOLLISION_IS_POINTER, 22 | RL_RAYCOLLISION_IS_VALUE 23 | } RLRayCollisionDataType; 24 | 25 | typedef union { 26 | RayCollision *p; 27 | RayCollision v; 28 | } RayCollisionUnion; 29 | 30 | struct RL_RayCollision { 31 | unsigned int id; 32 | char *guid; 33 | RayCollisionUnion data; 34 | RLRayCollisionDataType type; 35 | unsigned refCount; 36 | unsigned char deleted; 37 | }; 38 | 39 | static struct RL_RayCollision **RL_RayCollision_Object_List; 40 | static hashmap *RL_RayCollision_Object_Map; 41 | 42 | char* RL_RayCollision_Hash_Id(char *str, size_t size); 43 | struct RL_RayCollision* RL_RayCollision_Create(); 44 | void RL_RayCollision_Delete(struct RL_RayCollision* object, int index); 45 | void RL_RayCollision_Free(struct RL_RayCollision* object); 46 | 47 | typedef struct _php_raylib_raycollision_object { 48 | struct RL_RayCollision *raycollision; 49 | HashTable *prop_handler; 50 | zval point; 51 | zval normal; 52 | zend_object std; 53 | } php_raylib_raycollision_object; 54 | 55 | static inline php_raylib_raycollision_object *php_raylib_raycollision_fetch_object(zend_object *obj) { 56 | return (php_raylib_raycollision_object *)((char *)obj - XtOffsetOf(php_raylib_raycollision_object, std)); 57 | } 58 | 59 | static inline RayCollision *php_raylib_raycollision_fetch_data(php_raylib_raycollision_object *obj) { 60 | RayCollision *my_raycollision; 61 | if (obj->raycollision->type == RL_RAYCOLLISION_IS_POINTER) { 62 | my_raycollision = obj->raycollision->data.p; 63 | } else { 64 | my_raycollision = &obj->raycollision->data.v; 65 | } 66 | 67 | return my_raycollision; 68 | } 69 | 70 | #define Z_RAYCOLLISION_OBJ_P(zv) php_raylib_raycollision_fetch_object(Z_OBJ_P(zv)); 71 | 72 | void php_raylib_raycollision_startup(INIT_FUNC_ARGS); 73 | 74 | #endif //PHP_RAYLIB_RAYCOLLISION_H 75 | -------------------------------------------------------------------------------- /generate/examples/models/models_billboard.php: -------------------------------------------------------------------------------- 1 | material->type == RL_MATERIAL_IS_POINTER) { 67 | my_material = obj->material->data.p; 68 | } else { 69 | my_material = &obj->material->data.v; 70 | } 71 | 72 | return my_material; 73 | } 74 | 75 | #define Z_MATERIAL_OBJ_P(zv) php_raylib_material_fetch_object(Z_OBJ_P(zv)); 76 | 77 | void php_raylib_material_startup(INIT_FUNC_ARGS); 78 | 79 | #endif //PHP_RAYLIB_MATERIAL_H 80 | -------------------------------------------------------------------------------- /materialmap.h: -------------------------------------------------------------------------------- 1 | #ifndef PHP_RAYLIB_MATERIALMAP_H 2 | #define PHP_RAYLIB_MATERIALMAP_H 3 | 4 | #include "include/hashmap.h" 5 | #include "texture.h" 6 | #include "color.h" 7 | 8 | extern zend_class_entry * php_raylib_materialmap_ce; 9 | 10 | // External Free Objects - Prevent Circular Dependency 11 | extern void php_raylib_texture_free_storage(zend_object *object); 12 | extern void php_raylib_color_free_storage(zend_object *object); 13 | 14 | extern void php_raylib_materialmap_free_storage(zend_object * object); 15 | 16 | extern zend_object * php_raylib_materialmap_new(zend_class_entry * ce); 17 | 18 | extern zend_object * php_raylib_materialmap_new_ex(zend_class_entry *ce, zend_object *orig); 19 | 20 | extern zend_object_handlers php_raylib_materialmap_object_handlers; 21 | 22 | typedef enum { 23 | RL_MATERIALMAP_IS_POINTER, 24 | RL_MATERIALMAP_IS_VALUE 25 | } RLMaterialMapDataType; 26 | 27 | typedef union { 28 | MaterialMap *p; 29 | MaterialMap v; 30 | } MaterialMapUnion; 31 | 32 | struct RL_MaterialMap { 33 | unsigned int id; 34 | char *guid; 35 | MaterialMapUnion data; 36 | RLMaterialMapDataType type; 37 | unsigned refCount; 38 | unsigned char deleted; 39 | }; 40 | 41 | static struct RL_MaterialMap **RL_MaterialMap_Object_List; 42 | static hashmap *RL_MaterialMap_Object_Map; 43 | 44 | char* RL_MaterialMap_Hash_Id(char *str, size_t size); 45 | struct RL_MaterialMap* RL_MaterialMap_Create(); 46 | void RL_MaterialMap_Delete(struct RL_MaterialMap* object, int index); 47 | void RL_MaterialMap_Free(struct RL_MaterialMap* object); 48 | 49 | typedef struct _php_raylib_materialmap_object { 50 | struct RL_MaterialMap *materialmap; 51 | HashTable *prop_handler; 52 | zval texture; 53 | zval color; 54 | zend_object std; 55 | } php_raylib_materialmap_object; 56 | 57 | static inline php_raylib_materialmap_object *php_raylib_materialmap_fetch_object(zend_object *obj) { 58 | return (php_raylib_materialmap_object *)((char *)obj - XtOffsetOf(php_raylib_materialmap_object, std)); 59 | } 60 | 61 | static inline MaterialMap *php_raylib_materialmap_fetch_data(php_raylib_materialmap_object *obj) { 62 | MaterialMap *my_materialmap; 63 | if (obj->materialmap->type == RL_MATERIALMAP_IS_POINTER) { 64 | my_materialmap = obj->materialmap->data.p; 65 | } else { 66 | my_materialmap = &obj->materialmap->data.v; 67 | } 68 | 69 | return my_materialmap; 70 | } 71 | 72 | #define Z_MATERIALMAP_OBJ_P(zv) php_raylib_materialmap_fetch_object(Z_OBJ_P(zv)); 73 | 74 | void php_raylib_materialmap_startup(INIT_FUNC_ARGS); 75 | 76 | #endif //PHP_RAYLIB_MATERIALMAP_H 77 | -------------------------------------------------------------------------------- /rendertexture.h: -------------------------------------------------------------------------------- 1 | #ifndef PHP_RAYLIB_RENDERTEXTURE_H 2 | #define PHP_RAYLIB_RENDERTEXTURE_H 3 | 4 | #include "include/hashmap.h" 5 | #include "texture.h" 6 | 7 | extern zend_class_entry * php_raylib_rendertexture_ce; 8 | 9 | // External Free Objects - Prevent Circular Dependency 10 | extern void php_raylib_texture_free_storage(zend_object *object); 11 | 12 | extern void php_raylib_rendertexture_free_storage(zend_object * object); 13 | 14 | extern zend_object * php_raylib_rendertexture_new(zend_class_entry * ce); 15 | 16 | extern zend_object * php_raylib_rendertexture_new_ex(zend_class_entry *ce, zend_object *orig); 17 | 18 | extern zend_object_handlers php_raylib_rendertexture_object_handlers; 19 | 20 | typedef enum { 21 | RL_RENDERTEXTURE_IS_POINTER, 22 | RL_RENDERTEXTURE_IS_VALUE 23 | } RLRenderTextureDataType; 24 | 25 | typedef union { 26 | RenderTexture *p; 27 | RenderTexture v; 28 | } RenderTextureUnion; 29 | 30 | struct RL_RenderTexture { 31 | unsigned int id; 32 | char *guid; 33 | RenderTextureUnion data; 34 | RLRenderTextureDataType type; 35 | unsigned refCount; 36 | unsigned char deleted; 37 | }; 38 | 39 | static struct RL_RenderTexture **RL_RenderTexture_Object_List; 40 | static hashmap *RL_RenderTexture_Object_Map; 41 | 42 | char* RL_RenderTexture_Hash_Id(char *str, size_t size); 43 | struct RL_RenderTexture* RL_RenderTexture_Create(); 44 | void RL_RenderTexture_Delete(struct RL_RenderTexture* object, int index); 45 | void RL_RenderTexture_Free(struct RL_RenderTexture* object); 46 | 47 | typedef struct _php_raylib_rendertexture_object { 48 | struct RL_RenderTexture *rendertexture; 49 | HashTable *prop_handler; 50 | zval texture; 51 | zval depth; 52 | zend_object std; 53 | } php_raylib_rendertexture_object; 54 | 55 | static inline php_raylib_rendertexture_object *php_raylib_rendertexture_fetch_object(zend_object *obj) { 56 | return (php_raylib_rendertexture_object *)((char *)obj - XtOffsetOf(php_raylib_rendertexture_object, std)); 57 | } 58 | 59 | static inline RenderTexture *php_raylib_rendertexture_fetch_data(php_raylib_rendertexture_object *obj) { 60 | RenderTexture *my_rendertexture; 61 | if (obj->rendertexture->type == RL_RENDERTEXTURE_IS_POINTER) { 62 | my_rendertexture = obj->rendertexture->data.p; 63 | } else { 64 | my_rendertexture = &obj->rendertexture->data.v; 65 | } 66 | 67 | return my_rendertexture; 68 | } 69 | 70 | #define Z_RENDERTEXTURE_OBJ_P(zv) php_raylib_rendertexture_fetch_object(Z_OBJ_P(zv)); 71 | 72 | void php_raylib_rendertexture_startup(INIT_FUNC_ARGS); 73 | 74 | #endif //PHP_RAYLIB_RENDERTEXTURE_H 75 | -------------------------------------------------------------------------------- /generate/src/Func.php: -------------------------------------------------------------------------------- 1 | rename = $functionInfo['rename'] ?? null; 45 | $this->name = $functionInfo['name']; 46 | $this->returnType = Helper::replaceAlias($aliases, $functionInfo['returnType']); 47 | 48 | $this->nameLower = strtolower($functionInfo['name']); 49 | $this->nameUpper = strtoupper($functionInfo['name']); 50 | 51 | $this->returnTypeLower = strtolower($this->returnType); 52 | $this->returnTypeUpper = strtoupper($this->returnType); 53 | 54 | $this->description = $functionInfo['description'] ?? ''; 55 | 56 | $this->params = []; 57 | /** @var array{name:string,type:string} $paramInfo */ 58 | foreach ($functionInfo['params'] ?? [] as $paramInfo) { 59 | $paramInfo['type'] = Helper::replaceAlias($aliases, $paramInfo['type']); 60 | 61 | $param = new Param($paramInfo); 62 | 63 | $this->params[] = $param; 64 | } 65 | $this->paramCount = count($this->params); 66 | 67 | $this->returnIsArray = $functionInfo['isArray'] ?? Helper::isArray($this->returnType); 68 | $this->returnArrayCountField = $functionInfo['arrayCountField'] ?? ''; 69 | $this->isConstructor = $functionInfo['isConstructor'] ?? ''; 70 | $this->returnIsPrimitive = Helper::isPrimitive($this->returnType); 71 | $this->manualCFile = ''; 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /vrdeviceinfo.h: -------------------------------------------------------------------------------- 1 | #ifndef PHP_RAYLIB_VRDEVICEINFO_H 2 | #define PHP_RAYLIB_VRDEVICEINFO_H 3 | 4 | #include "include/hashmap.h" 5 | 6 | extern zend_class_entry * php_raylib_vrdeviceinfo_ce; 7 | 8 | // External Free Objects - Prevent Circular Dependency 9 | 10 | extern void php_raylib_vrdeviceinfo_free_storage(zend_object * object); 11 | 12 | extern zend_object * php_raylib_vrdeviceinfo_new(zend_class_entry * ce); 13 | 14 | extern zend_object * php_raylib_vrdeviceinfo_new_ex(zend_class_entry *ce, zend_object *orig); 15 | 16 | extern zend_object_handlers php_raylib_vrdeviceinfo_object_handlers; 17 | 18 | typedef enum { 19 | RL_VRDEVICEINFO_IS_POINTER, 20 | RL_VRDEVICEINFO_IS_VALUE 21 | } RLVrDeviceInfoDataType; 22 | 23 | typedef union { 24 | VrDeviceInfo *p; 25 | VrDeviceInfo v; 26 | } VrDeviceInfoUnion; 27 | 28 | struct RL_VrDeviceInfo { 29 | unsigned int id; 30 | char *guid; 31 | VrDeviceInfoUnion data; 32 | RLVrDeviceInfoDataType type; 33 | unsigned refCount; 34 | unsigned char deleted; 35 | }; 36 | 37 | static struct RL_VrDeviceInfo **RL_VrDeviceInfo_Object_List; 38 | static hashmap *RL_VrDeviceInfo_Object_Map; 39 | 40 | char* RL_VrDeviceInfo_Hash_Id(char *str, size_t size); 41 | struct RL_VrDeviceInfo* RL_VrDeviceInfo_Create(); 42 | void RL_VrDeviceInfo_Delete(struct RL_VrDeviceInfo* object, int index); 43 | void RL_VrDeviceInfo_Free(struct RL_VrDeviceInfo* object); 44 | 45 | typedef struct _php_raylib_vrdeviceinfo_object { 46 | struct RL_VrDeviceInfo *vrdeviceinfo; 47 | HashTable *prop_handler; 48 | // Cannot support primitive data structure like float (an array) as zval 49 | // zval lensdistortionvalues; 50 | // Cannot support primitive data structure like float (an array) as zval 51 | // zval chromaabcorrection; 52 | zend_object std; 53 | } php_raylib_vrdeviceinfo_object; 54 | 55 | static inline php_raylib_vrdeviceinfo_object *php_raylib_vrdeviceinfo_fetch_object(zend_object *obj) { 56 | return (php_raylib_vrdeviceinfo_object *)((char *)obj - XtOffsetOf(php_raylib_vrdeviceinfo_object, std)); 57 | } 58 | 59 | static inline VrDeviceInfo *php_raylib_vrdeviceinfo_fetch_data(php_raylib_vrdeviceinfo_object *obj) { 60 | VrDeviceInfo *my_vrdeviceinfo; 61 | if (obj->vrdeviceinfo->type == RL_VRDEVICEINFO_IS_POINTER) { 62 | my_vrdeviceinfo = obj->vrdeviceinfo->data.p; 63 | } else { 64 | my_vrdeviceinfo = &obj->vrdeviceinfo->data.v; 65 | } 66 | 67 | return my_vrdeviceinfo; 68 | } 69 | 70 | #define Z_VRDEVICEINFO_OBJ_P(zv) php_raylib_vrdeviceinfo_fetch_object(Z_OBJ_P(zv)); 71 | 72 | void php_raylib_vrdeviceinfo_startup(INIT_FUNC_ARGS); 73 | 74 | #endif //PHP_RAYLIB_VRDEVICEINFO_H 75 | -------------------------------------------------------------------------------- /audiostream.h: -------------------------------------------------------------------------------- 1 | #ifndef PHP_RAYLIB_AUDIOSTREAM_H 2 | #define PHP_RAYLIB_AUDIOSTREAM_H 3 | 4 | #include "include/hashmap.h" 5 | 6 | extern zend_class_entry * php_raylib_audiostream_ce; 7 | 8 | // External Free Objects - Prevent Circular Dependency 9 | //TODO: Support array/hash 10 | //extern void php_raylib_raudiobuffer_array_free_storage(zend_object *object); 11 | extern void php_raylib_raudioprocessor__free_storage(zend_object *object); 12 | 13 | extern void php_raylib_audiostream_free_storage(zend_object * object); 14 | 15 | extern zend_object * php_raylib_audiostream_new(zend_class_entry * ce); 16 | 17 | extern zend_object * php_raylib_audiostream_new_ex(zend_class_entry *ce, zend_object *orig); 18 | 19 | extern zend_object_handlers php_raylib_audiostream_object_handlers; 20 | 21 | typedef enum { 22 | RL_AUDIOSTREAM_IS_POINTER, 23 | RL_AUDIOSTREAM_IS_VALUE 24 | } RLAudioStreamDataType; 25 | 26 | typedef union { 27 | AudioStream *p; 28 | AudioStream v; 29 | } AudioStreamUnion; 30 | 31 | struct RL_AudioStream { 32 | unsigned int id; 33 | char *guid; 34 | AudioStreamUnion data; 35 | RLAudioStreamDataType type; 36 | unsigned refCount; 37 | unsigned char deleted; 38 | }; 39 | 40 | static struct RL_AudioStream **RL_AudioStream_Object_List; 41 | static hashmap *RL_AudioStream_Object_Map; 42 | 43 | char* RL_AudioStream_Hash_Id(char *str, size_t size); 44 | struct RL_AudioStream* RL_AudioStream_Create(); 45 | void RL_AudioStream_Delete(struct RL_AudioStream* object, int index); 46 | void RL_AudioStream_Free(struct RL_AudioStream* object); 47 | 48 | typedef struct _php_raylib_audiostream_object { 49 | struct RL_AudioStream *audiostream; 50 | HashTable *prop_handler; 51 | // NO idea what to do with rAudioBuffer 52 | //php_raylib_raudiobuffer_object *buffer; 53 | zval processor; 54 | zend_object std; 55 | } php_raylib_audiostream_object; 56 | 57 | static inline php_raylib_audiostream_object *php_raylib_audiostream_fetch_object(zend_object *obj) { 58 | return (php_raylib_audiostream_object *)((char *)obj - XtOffsetOf(php_raylib_audiostream_object, std)); 59 | } 60 | 61 | static inline AudioStream *php_raylib_audiostream_fetch_data(php_raylib_audiostream_object *obj) { 62 | AudioStream *my_audiostream; 63 | if (obj->audiostream->type == RL_AUDIOSTREAM_IS_POINTER) { 64 | my_audiostream = obj->audiostream->data.p; 65 | } else { 66 | my_audiostream = &obj->audiostream->data.v; 67 | } 68 | 69 | return my_audiostream; 70 | } 71 | 72 | #define Z_AUDIOSTREAM_OBJ_P(zv) php_raylib_audiostream_fetch_object(Z_OBJ_P(zv)); 73 | 74 | void php_raylib_audiostream_startup(INIT_FUNC_ARGS); 75 | 76 | #endif //PHP_RAYLIB_AUDIOSTREAM_H 77 | -------------------------------------------------------------------------------- /generate/templates/struct-array.c: -------------------------------------------------------------------------------- 1 | unsigned int RL_VECTOR3_OBJECT_ID = 0; 2 | unsigned char RL_VECTOR3_INIT = 0; 3 | const unsigned int RL_VECTOR3_MAX_OBJECTS = 999999; 4 | 5 | struct RL_Vector3 { 6 | unsigned int id; 7 | const char guid[36]; 8 | Vector3 data; 9 | unsigned refCount; 10 | unsigned char deleted; 11 | }; 12 | 13 | struct RL_Vector3 **RL_Vector3_Object_List; 14 | hashmap *RL_Vector3_Object_Map; 15 | 16 | char[32] RL_Vector3_Hash_Id(char *str, size_t size) { 17 | const char charset[] = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; 18 | const int charset_size = sizeof(charset) - 1; 19 | srand((unsigned int) time(NULL)); 20 | for (size_t i = 0; i < size - 1; i++) { 21 | int index = rand() % charset_size; 22 | str[i] = charset[index]; 23 | } 24 | str[size-1] = '\0'; 25 | return str; 26 | } 27 | 28 | struct RL_Vector3* RL_Vector3_Create() { 29 | //-- Create the initial data structures 30 | if (RL_VECTOR3_INIT == 0) { 31 | RL_Vector3_Object_List = (struct RL_Vector3**) malloc(0); 32 | RL_Vector3_Object_Map = hashmap_create(); 33 | RL_VECTOR3_INIT = 1; 34 | } 35 | 36 | //-- Create the container object 37 | struct RL_Vector3* object = (struct RL_Vector3*) malloc(sizeof(struct RL_Vector3)); 38 | object->id = RL_VECTOR3_OBJECT_ID++; 39 | object->guid = RL_Vector3_Hash_Id(object->guid, sizeof(object->guid)); // Generate hash ID 40 | object->refCount = 1; 41 | object->deleted = 0; 42 | 43 | //-- Push to the dynamic array list 44 | RL_Vector3_Object_List = (struct RL_Vector3**) realloc(RL_Vector3_Object_List, RL_VECTOR3_OBJECT_ID * sizeof(struct RL_Vector3*)); 45 | RL_Vector3_Object_List[object->id] = object; 46 | 47 | //-- Add to hashmap 48 | hashmap_set(RL_Vector3_Object_Map, object->guid, sizeof(object->guid) - 1, object); 49 | 50 | return object; 51 | } 52 | 53 | void RL_Vector3_Delete(struct RL_Vector3* object, int index) { 54 | if (index < 0 || index >= RL_VECTOR3_OBJECT_ID) { 55 | // Error: invalid index 56 | return; 57 | } 58 | 59 | hashmap_remove(RL_Vector3_Object_Map, object->guid, sizeof(object->guid) -1); 60 | 61 | // Free the memory for the element being deleted 62 | free(RL_Vector3_Object_List[index]); 63 | 64 | // Shift the remaining elements over by one 65 | memmove(&RL_Vector3_Object_List[index], &RL_Vector3_Object_List[index + 1], (RL_VECTOR3_OBJECT_ID - index - 1) * sizeof(struct RL_Vector3 *)); 66 | 67 | // Decrement the count and resize the array 68 | RL_VECTOR3_OBJECT_ID--; 69 | RL_Vector3_Object_List = (struct RL_Vector3 **)realloc(list, (RL_VECTOR3_OBJECT_ID) * sizeof(struct RL_Vector3 *)); 70 | } 71 | 72 | void RL_Vector3_Free(struct RL_Vector3* object) { 73 | free(object); 74 | } -------------------------------------------------------------------------------- /generate/examples/textures/resources/LICENSE.md: -------------------------------------------------------------------------------- 1 | | resource | author | licence | notes | 2 | | :------------------- | :---------: | :------ | :---- | 3 | | boom.wav | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Made with [rFXGen](https://raylibtech.itch.io/rfxgen) | 4 | | buttonfx.wav | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Made with [rFXGen](https://raylibtech.itch.io/rfxgen) | 5 | | button.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Made with [rFXGen](https://raylibtech.itch.io/rfxgen) | 6 | | spark_flame.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | Made with [EffectTextureMaker](https://mebiusbox.github.io/contents/EffectTextureMaker/) | 7 | | ninepatch_button.png | [@overdev](https://github.com/overdev) | ❔ | 8 | | explosion.png | [Unity Labs Paris](https://blogs.unity3d.com/2016/11/28/free-vfx-image-sequences-flipbooks/) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | 9 | | parrots.png | [Kodak set](http://r0k.us/graphics/kodak/) | ❔ | Original name: `kodim23.png` 10 | | cat.png | ❔ | ❔ | - | 11 | | wabbit_alpha.png | ❔ | ❔ | - | 12 | | custom_jupiter_crash.png | [Brian Kent (AEnigma)](https://www.dafont.com/es/aenigma.d188) | [Freeware](https://www.dafont.com/es/jupiter-crash.font) | Atlas created by [@raysan5](https://github.com/raysan5) | 13 | | KAISG.ttf | [Dieter Steffmann](http://www.steffmann.de/wordpress/) | [Freeware](https://www.1001fonts.com/users/steffmann/) | [Kaiserzeit Gotisch](https://www.dafont.com/es/kaiserzeit-gotisch.font) font | 14 | | fudesumi.png | [Eiden Marsal](https://www.artstation.com/marshall_z) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/) | - | 15 | | scarfy.png | [Eiden Marsal](https://www.artstation.com/marshall_z) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - | 16 | | cyberpunk_street_background.png | [Luis Zuno](http://ansimuz.com/site/) | [CC-BY-3.0](http://creativecommons.org/licenses/by/3.0/) | [Cyberpunk Street Environment](https://ansimuz.itch.io/cyberpunk-street-environment) | 17 | | cyberpunk_street_foreground.png | [Luis Zuno](http://ansimuz.com/site/) | [CC-BY-3.0](http://creativecommons.org/licenses/by/3.0/) | [Cyberpunk Street Environment](https://ansimuz.itch.io/cyberpunk-street-environment) | 18 | | cyberpunk_street_midground.png | [Luis Zuno](http://ansimuz.com/site/) | [CC-BY-3.0](http://creativecommons.org/licenses/by/3.0/) | [Cyberpunk Street Environment](https://ansimuz.itch.io/cyberpunk-street-environment) | 19 | -------------------------------------------------------------------------------- /generate/src/Param.php: -------------------------------------------------------------------------------- 1 | isPrimitive = Helper::isPrimitive($paramInfo['type']); 28 | $this->name = $paramInfo['name']; 29 | $this->type = (!$this->isPrimitive) ? str_replace(['const', ' '], '', $paramInfo['type']) : $paramInfo['type']; 30 | $this->isRef = $paramInfo['isRef'] ?? false; 31 | $this->typeLower = trim(str_replace(['*', 'const'], '', strtolower($paramInfo['type']))); 32 | $this->typeUpper = trim(str_replace(['*', 'const'], '', strtoupper($paramInfo['type']))); 33 | $this->typeUpperFirst = ucfirst($paramInfo['type']); 34 | $this->nameUpperFirst = ucfirst($paramInfo['name']); 35 | $this->nameLower = strtolower($paramInfo['name']); 36 | $this->nameUpper = strtoupper($paramInfo['name']); 37 | $this->isArray = $paramInfo['isArray'] ?? Helper::isArray($this->type); 38 | 39 | if ($paramInfo['isArray'] ?? false) { 40 | $this->isArray = $paramInfo['isArray']; 41 | } 42 | if ($paramInfo['arrayCountField'] ?? null) { 43 | $this->arrayCountField = $paramInfo['arrayCountField']; 44 | } 45 | if ($paramInfo['arrayCountEnum'] ?? null) { 46 | $this->arrayCountEnum = $paramInfo['arrayCountEnum']; 47 | } 48 | if ($paramInfo['arrayCountNumber'] ?? null) { 49 | $this->arrayCountNumber = $paramInfo['arrayCountNumber']; 50 | } 51 | 52 | } 53 | 54 | public function getTr() 55 | { 56 | return [ 57 | '[type]' => $this->type, 58 | '[typeNonConst]' => trim(str_replace('const', '', $this->type)), 59 | '[typeNoStar]' => trim(str_replace('*', '', $this->type)), 60 | '[typeLower]' => $this->typeLower, 61 | '[typeUpper]' => $this->typeUpper, 62 | '[name]' => $this->name, 63 | '[nameLower]' => $this->nameLower, 64 | '[nameUpperFirst]' => $this->nameUpperFirst, 65 | ]; 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /generate/src/Generate/ObjectHasProperty.php: -------------------------------------------------------------------------------- 1 | nameLower . '_has_property(zend_object *object, zend_string *name, int has_set_exists, void **cache_slot) /* {{{ */'; 15 | $input[] = '{'; 16 | $input[] = ' php_raylib_' . $struct->nameLower . '_object *obj;'; 17 | $input[] = ' raylib_' . $struct->nameLower . '_prop_handler *hnd = NULL;'; 18 | $input[] = ' int ret = 0;'; 19 | $input[] = ''; 20 | $input[] = ' if ((hnd = zend_hash_find_ptr(obj->prop_handler, name)) != NULL) {'; 21 | $input[] = ' switch (has_set_exists) {'; 22 | $input[] = ' case ZEND_PROPERTY_EXISTS:'; 23 | $input[] = ' ret = 1;'; 24 | $input[] = ' break;'; 25 | $input[] = ' case ZEND_PROPERTY_NOT_EMPTY: {'; 26 | $input[] = ' zval rv;'; 27 | $input[] = ' zval *value = php_raylib_' . $struct->nameLower . '_read_property(object, name, BP_VAR_IS, cache_slot, &rv);'; 28 | $input[] = ' if (value != &EG(uninitialized_zval)) {'; 29 | $input[] = ' convert_to_boolean(value);'; 30 | $input[] = ' ret = Z_TYPE_P(value) == IS_TRUE ? 1 : 0;'; 31 | $input[] = ' }'; 32 | $input[] = ' break;'; 33 | $input[] = ' }'; 34 | $input[] = ' case ZEND_PROPERTY_ISSET: {'; 35 | $input[] = ' zval rv;'; 36 | $input[] = ' zval *value = php_raylib_' . $struct->nameLower . '_read_property(object, name, BP_VAR_IS, cache_slot, &rv);'; 37 | $input[] = ' if (value != &EG(uninitialized_zval)) {'; 38 | $input[] = ' ret = Z_TYPE_P(value) != IS_NULL? 1 : 0;'; 39 | $input[] = ' zval_ptr_dtor(value);'; 40 | $input[] = ' }'; 41 | $input[] = ' break;'; 42 | $input[] = ' }'; 43 | $input[] = ' EMPTY_SWITCH_DEFAULT_CASE();'; 44 | $input[] = ' }'; 45 | $input[] = ' } else {'; 46 | $input[] = ' ret = zend_std_has_property(object, name, has_set_exists, cache_slot);'; 47 | $input[] = ' }'; 48 | $input[] = ''; 49 | $input[] = ' return ret;'; 50 | $input[] = '}'; 51 | $input[] = '/* }}} */'; 52 | $input[] = ''; 53 | 54 | return $input; 55 | } 56 | } -------------------------------------------------------------------------------- /modelanimation.h: -------------------------------------------------------------------------------- 1 | #ifndef PHP_RAYLIB_MODELANIMATION_H 2 | #define PHP_RAYLIB_MODELANIMATION_H 3 | 4 | #include "include/hashmap.h" 5 | #include "boneinfo.h" 6 | #include "transform.h" 7 | 8 | extern zend_class_entry * php_raylib_modelanimation_ce; 9 | 10 | // External Free Objects - Prevent Circular Dependency 11 | //TODO: Support array/hash 12 | //extern void php_raylib_boneinfo_array_free_storage(zend_object *object); 13 | //TODO: Support array/hash 14 | //extern void php_raylib_transform_array_free_storage(zend_object *object); 15 | 16 | extern void php_raylib_modelanimation_free_storage(zend_object * object); 17 | 18 | extern zend_object * php_raylib_modelanimation_new(zend_class_entry * ce); 19 | 20 | extern zend_object * php_raylib_modelanimation_new_ex(zend_class_entry *ce, zend_object *orig); 21 | 22 | extern zend_object_handlers php_raylib_modelanimation_object_handlers; 23 | 24 | typedef enum { 25 | RL_MODELANIMATION_IS_POINTER, 26 | RL_MODELANIMATION_IS_VALUE 27 | } RLModelAnimationDataType; 28 | 29 | typedef union { 30 | ModelAnimation *p; 31 | ModelAnimation v; 32 | } ModelAnimationUnion; 33 | 34 | struct RL_ModelAnimation { 35 | unsigned int id; 36 | char *guid; 37 | ModelAnimationUnion data; 38 | RLModelAnimationDataType type; 39 | unsigned refCount; 40 | unsigned char deleted; 41 | }; 42 | 43 | static struct RL_ModelAnimation **RL_ModelAnimation_Object_List; 44 | static hashmap *RL_ModelAnimation_Object_Map; 45 | 46 | char* RL_ModelAnimation_Hash_Id(char *str, size_t size); 47 | struct RL_ModelAnimation* RL_ModelAnimation_Create(); 48 | void RL_ModelAnimation_Delete(struct RL_ModelAnimation* object, int index); 49 | void RL_ModelAnimation_Free(struct RL_ModelAnimation* object); 50 | 51 | typedef struct _php_raylib_modelanimation_object { 52 | struct RL_ModelAnimation *modelanimation; 53 | HashTable *prop_handler; 54 | zval bones; 55 | zval frameposes; 56 | zend_object std; 57 | } php_raylib_modelanimation_object; 58 | 59 | static inline php_raylib_modelanimation_object *php_raylib_modelanimation_fetch_object(zend_object *obj) { 60 | return (php_raylib_modelanimation_object *)((char *)obj - XtOffsetOf(php_raylib_modelanimation_object, std)); 61 | } 62 | 63 | static inline ModelAnimation *php_raylib_modelanimation_fetch_data(php_raylib_modelanimation_object *obj) { 64 | ModelAnimation *my_modelanimation; 65 | if (obj->modelanimation->type == RL_MODELANIMATION_IS_POINTER) { 66 | my_modelanimation = obj->modelanimation->data.p; 67 | } else { 68 | my_modelanimation = &obj->modelanimation->data.v; 69 | } 70 | 71 | return my_modelanimation; 72 | } 73 | 74 | #define Z_MODELANIMATION_OBJ_P(zv) php_raylib_modelanimation_fetch_object(Z_OBJ_P(zv)); 75 | 76 | void php_raylib_modelanimation_startup(INIT_FUNC_ARGS); 77 | 78 | #endif //PHP_RAYLIB_MODELANIMATION_H 79 | -------------------------------------------------------------------------------- /generate/examples/models/resources/models/gltf/AnimatedTriangle.gltf: -------------------------------------------------------------------------------- 1 | { 2 | "scene" : 0, 3 | "scenes" : [ 4 | { 5 | "nodes" : [ 0 ] 6 | } 7 | ], 8 | 9 | "nodes" : [ 10 | { 11 | "mesh" : 0, 12 | "rotation" : [ 0.0, 0.0, 0.0, 1.0 ] 13 | } 14 | ], 15 | 16 | "meshes" : [ 17 | { 18 | "primitives" : [ { 19 | "attributes" : { 20 | "POSITION" : 1 21 | }, 22 | "indices" : 0 23 | } ] 24 | } 25 | ], 26 | 27 | "animations": [ 28 | { 29 | "samplers" : [ 30 | { 31 | "input" : 2, 32 | "interpolation" : "LINEAR", 33 | "output" : 3 34 | } 35 | ], 36 | "channels" : [ { 37 | "sampler" : 0, 38 | "target" : { 39 | "node" : 0, 40 | "path" : "rotation" 41 | } 42 | } ] 43 | } 44 | ], 45 | 46 | "buffers" : [ 47 | { 48 | "uri" : "data:application/octet-stream;base64,AAABAAIAAAAAAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAAAAAAAAACAPwAAAAA=", 49 | "byteLength" : 44 50 | }, 51 | { 52 | "uri" : "data:application/octet-stream;base64,AAAAAAAAgD4AAAA/AABAPwAAgD8AAAAAAAAAAAAAAAAAAIA/AAAAAAAAAAD0/TQ/9P00PwAAAAAAAAAAAACAPwAAAAAAAAAAAAAAAPT9ND/0/TS/AAAAAAAAAAAAAAAAAACAPw==", 53 | "byteLength" : 100 54 | } 55 | ], 56 | "bufferViews" : [ 57 | { 58 | "buffer" : 0, 59 | "byteOffset" : 0, 60 | "byteLength" : 6, 61 | "target" : 34963 62 | }, 63 | { 64 | "buffer" : 0, 65 | "byteOffset" : 8, 66 | "byteLength" : 36, 67 | "target" : 34962 68 | }, 69 | { 70 | "buffer" : 1, 71 | "byteOffset" : 0, 72 | "byteLength" : 100 73 | } 74 | ], 75 | "accessors" : [ 76 | { 77 | "bufferView" : 0, 78 | "byteOffset" : 0, 79 | "componentType" : 5123, 80 | "count" : 3, 81 | "type" : "SCALAR", 82 | "max" : [ 2 ], 83 | "min" : [ 0 ] 84 | }, 85 | { 86 | "bufferView" : 1, 87 | "byteOffset" : 0, 88 | "componentType" : 5126, 89 | "count" : 3, 90 | "type" : "VEC3", 91 | "max" : [ 1.0, 1.0, 0.0 ], 92 | "min" : [ 0.0, 0.0, 0.0 ] 93 | }, 94 | { 95 | "bufferView" : 2, 96 | "byteOffset" : 0, 97 | "componentType" : 5126, 98 | "count" : 5, 99 | "type" : "SCALAR", 100 | "max" : [ 1.0 ], 101 | "min" : [ 0.0 ] 102 | }, 103 | { 104 | "bufferView" : 2, 105 | "byteOffset" : 20, 106 | "componentType" : 5126, 107 | "count" : 5, 108 | "type" : "VEC4", 109 | "max" : [ 0.0, 0.0, 1.0, 1.0 ], 110 | "min" : [ 0.0, 0.0, 0.0, -0.707 ] 111 | } 112 | ], 113 | 114 | "asset" : { 115 | "version" : "2.0" 116 | } 117 | 118 | } -------------------------------------------------------------------------------- /config.w32: -------------------------------------------------------------------------------- 1 | // $Id$ 2 | // vim:ft=javascript 3 | 4 | ARG_WITH("raylib", "for raylib support", "yes,shared"); 5 | 6 | if (PHP_RAYLIB != "no") { 7 | raylib_lib_paths = PHP_PHP_BUILD + "\\lib;.\\lib"; 8 | raylib_include_paths = PHP_PHP_BUILD + "\\include;" + PHP_PHP_BUILD + "\\include\\GLFW;.\\include\\GLFW;.\\include"; 9 | 10 | raylib_check_lib = CHECK_LIB("raylib.lib", "raylib", raylib_lib_paths); 11 | raylib_check_header = CHECK_HEADER_ADD_INCLUDE("raylib.h", "CFLAGS_RAYLIB", raylib_include_paths); 12 | glfw_check_lib = CHECK_LIB("glfw3.lib", "raylib", raylib_lib_paths); 13 | glfw_check_header = CHECK_HEADER_ADD_INCLUDE("glfw3.h", "CFLAGS_RAYLIB", raylib_include_paths); 14 | glfw_check_header2 = CHECK_HEADER_ADD_INCLUDE("glfw3native.h", "CFLAGS_RAYLIB", raylib_include_paths); 15 | if ( 16 | //-- Raylib 17 | raylib_check_lib && 18 | raylib_check_header && 19 | //-- GLFW 20 | glfw_check_lib && 21 | glfw_check_header && 22 | glfw_check_header2 23 | ) { 24 | 25 | ADD_FLAG("LIBS_CLI", "raylib.lib glfw3.lib"); 26 | 27 | ADD_FLAG("LIBS_RAYLIB", "kernel32.lib user32.lib gdi32.lib winmm.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib") 28 | 29 | 30 | var raylib_sources = "raylib.c vector2.c vector3.c vector4.c matrix.c color.c rectangle.c image.c texture.c rendertexture.c npatchinfo.c glyphinfo.c font.c camera3d.c camera2d.c mesh.c shader.c materialmap.c material.c transform.c boneinfo.c model.c modelanimation.c ray.c raycollision.c boundingbox.c wave.c audiostream.c sound.c music.c vrdeviceinfo.c vrstereoconfig.c filepathlist.c includes\\hashmap.c"; 31 | PHP_INSTALL_HEADERS("ext/raylib", "php_raylib.h vector2.h vector3.h vector4.h matrix.h color.h rectangle.h image.h texture.h rendertexture.h npatchinfo.h glyphinfo.h font.h camera3d.h camera2d.h mesh.h shader.h materialmap.h material.h transform.h boneinfo.h model.h modelanimation.h ray.h raycollision.h boundingbox.h wave.h audiostream.h sound.h music.h vrdeviceinfo.h vrstereoconfig.h filepathlist.h includes\\hashmap.h"); 32 | EXTENSION("raylib", raylib_sources, true, "/DZEND_ENABLE_STATIC_TSRMLS_CACHE=1", "php_raylib.dll"); 33 | 34 | } else { 35 | WARNING("raylib not enabled; libraries not found"); 36 | if (!raylib_check_lib) { 37 | WARNING("raylib lib missing" + PHP_PHP_BUILD); 38 | } 39 | if (!raylib_check_header) { 40 | WARNING("raylib header missing"); 41 | } 42 | if (!glfw_check_lib) { 43 | WARNING("glfw lib missing"); 44 | } 45 | if (!glfw_check_header) { 46 | WARNING("glfw header missing"); 47 | } 48 | } 49 | } else { 50 | WARNING("raylib not enabled; not set with"); 51 | } -------------------------------------------------------------------------------- /generate/manual/LoadModelAnimations.c: -------------------------------------------------------------------------------- 1 | // Load model animations from file 2 | // RLAPI Model LoadModelFromMesh(Mesh mesh); 3 | ZEND_BEGIN_ARG_WITH_RETURN_TYPE_INFO_EX(arginfo_LoadModelAnimations, 0, 2, IS_ARRAY, 0) 4 | ZEND_ARG_INFO(0, fileName) 5 | ZEND_ARG_TYPE_INFO(1, animCount, IS_LONG, 0) 6 | ZEND_END_ARG_INFO() 7 | PHP_FUNCTION(LoadModelAnimations) 8 | { 9 | zend_string *fileName; 10 | zval *zAnimsCount = NULL; 11 | unsigned int i; 12 | 13 | ZEND_PARSE_PARAMETERS_START(2, 2) 14 | Z_PARAM_STR(fileName) 15 | Z_PARAM_ZVAL(zAnimsCount) 16 | ZEND_PARSE_PARAMETERS_END(); 17 | 18 | unsigned int animsCount = 0; 19 | ModelAnimation *anims = LoadModelAnimations(fileName->val, &animsCount); 20 | 21 | php_printf("animsCount: %d\n", animsCount); 22 | 23 | // Set output variable animsCount 24 | if (zAnimsCount) { 25 | ZEND_TRY_ASSIGN_REF_LONG(zAnimsCount, animsCount); 26 | } 27 | 28 | if (zend_parse_parameters_none() == FAILURE) { 29 | RETURN_THROWS(); 30 | } 31 | 32 | // Create a PHP array with the default size of the animation count 33 | array_init_size(return_value, animsCount); 34 | 35 | for (i = 0; i < animsCount; i++) { 36 | // Create the animation 37 | zend_object *modelAnimation = php_raylib_modelanimation_new_ex(php_raylib_modelanimation_ce, NULL); 38 | php_raylib_modelanimation_object *phpModelAnimation = php_raylib_modelanimation_fetch_object(modelAnimation); 39 | 40 | // Assign model animation to PHP object 41 | phpModelAnimation->modelanimation->type = RL_MODELANIMATION_IS_POINTER; 42 | phpModelAnimation->modelanimation->data.p = &anims[i]; 43 | 44 | // Create sub-object BoneInfo 45 | for (int n = 0; n < anims[i].boneCount; n++) { 46 | zend_object *boneInfo = php_raylib_boneinfo_new_ex(php_raylib_boneinfo_ce, NULL); 47 | php_raylib_boneinfo_object *phpBoneInfo = php_raylib_boneinfo_fetch_object(boneInfo); 48 | phpBoneInfo->boneinfo->type = RL_BONEINFO_IS_POINTER; 49 | phpBoneInfo->boneinfo->data.p = &anims[i].bones[n]; 50 | 51 | add_next_index_object(&phpModelAnimation->bones, boneInfo); 52 | } 53 | 54 | // Create sub-object Transform 55 | for (int w = 0; w < anims[i].frameCount; w++) { 56 | zend_object *transform = php_raylib_transform_new_ex(php_raylib_transform_ce, NULL); 57 | php_raylib_transform_object *phpTransform = php_raylib_transform_fetch_object(transform); 58 | phpTransform->transform->type = RL_TRANSFORM_IS_POINTER; 59 | phpTransform->transform->data.p = anims[i].framePoses[w]; 60 | 61 | add_next_index_object(&phpModelAnimation->frameposes, transform); 62 | } 63 | 64 | // Push PHP object to array 65 | add_next_index_object(return_value, &phpModelAnimation->std); 66 | } 67 | } 68 | -------------------------------------------------------------------------------- /generate/src/Field.php: -------------------------------------------------------------------------------- 1 | type = $type; 33 | 34 | $this->name = $name; 35 | $parts = explode('[', $this->name); 36 | $this->name = array_shift($parts); 37 | 38 | $this->nameLower = str_replace('const', '', strtolower($this->name)); 39 | $this->nameUpper = str_replace('CONST', '', strtoupper($this->name)); 40 | $this->description = $description; 41 | $this->isArray = $isArray; 42 | $this->arrayCountField = $arrayCountField; 43 | $this->arrayCountEnum = $arrayCountEnum; 44 | $this->arrayCountNumber = $arrayCountNumber; 45 | $this->isPointer = Helper::isPointer($this->type); 46 | $this->isPrimitive = Helper::isPrimitive($this->type); 47 | 48 | $this->typePlain = str_replace(['*', 'const', ' '], '', $this->type); 49 | $parts = explode('[', $this->typePlain); 50 | $this->typePlain = array_shift($parts); 51 | 52 | $this->typePlainLower = strtolower($this->typePlain); 53 | $this->typePlainUpper = strtoupper($this->typePlain); 54 | $this->typeName = str_replace([' ', '*', '__'], ['_', '', '_'], $this->isArray ? strtolower($this->type) . '_array' : strtolower($this->type)); 55 | $this->fieldName = str_replace([' ', '*'], ['_', ''], $this->typeName); 56 | } 57 | 58 | public function getTr() 59 | { 60 | return [ 61 | '[type]' => $this->type, 62 | '[typeNonConst]' => trim(str_replace('const', '', $this->type)), 63 | '[typeNoStar]' => trim(str_replace(['const', '*'], '', $this->type)), 64 | '[typeLower]' => $this->typePlainLower, 65 | '[typeUpper]' => $this->typePlainUpper, 66 | '[name]' => $this->name, 67 | '[nameLower]' => $this->nameLower, 68 | ]; 69 | } 70 | } 71 | -------------------------------------------------------------------------------- /model.h: -------------------------------------------------------------------------------- 1 | #ifndef PHP_RAYLIB_MODEL_H 2 | #define PHP_RAYLIB_MODEL_H 3 | 4 | #include "include/hashmap.h" 5 | #include "matrix.h" 6 | #include "mesh.h" 7 | #include "material.h" 8 | #include "boneinfo.h" 9 | #include "transform.h" 10 | 11 | extern zend_class_entry * php_raylib_model_ce; 12 | 13 | // External Free Objects - Prevent Circular Dependency 14 | extern void php_raylib_matrix_free_storage(zend_object *object); 15 | //TODO: Support array/hash 16 | //extern void php_raylib_mesh_array_free_storage(zend_object *object); 17 | //TODO: Support array/hash 18 | //extern void php_raylib_material_array_free_storage(zend_object *object); 19 | //TODO: Support array/hash 20 | //extern void php_raylib_boneinfo_array_free_storage(zend_object *object); 21 | //TODO: Support array/hash 22 | //extern void php_raylib_transform_array_free_storage(zend_object *object); 23 | 24 | extern void php_raylib_model_free_storage(zend_object * object); 25 | 26 | extern zend_object * php_raylib_model_new(zend_class_entry * ce); 27 | 28 | extern zend_object * php_raylib_model_new_ex(zend_class_entry *ce, zend_object *orig); 29 | 30 | extern zend_object_handlers php_raylib_model_object_handlers; 31 | 32 | typedef enum { 33 | RL_MODEL_IS_POINTER, 34 | RL_MODEL_IS_VALUE 35 | } RLModelDataType; 36 | 37 | typedef union { 38 | Model *p; 39 | Model v; 40 | } ModelUnion; 41 | 42 | struct RL_Model { 43 | unsigned int id; 44 | char *guid; 45 | ModelUnion data; 46 | RLModelDataType type; 47 | unsigned refCount; 48 | unsigned char deleted; 49 | }; 50 | 51 | static struct RL_Model **RL_Model_Object_List; 52 | static hashmap *RL_Model_Object_Map; 53 | 54 | char* RL_Model_Hash_Id(char *str, size_t size); 55 | struct RL_Model* RL_Model_Create(); 56 | void RL_Model_Delete(struct RL_Model* object, int index); 57 | void RL_Model_Free(struct RL_Model* object); 58 | 59 | typedef struct _php_raylib_model_object { 60 | struct RL_Model *model; 61 | HashTable *prop_handler; 62 | zval transform; 63 | zval meshes; 64 | zval materials; 65 | zval bones; 66 | zval bindpose; 67 | // Cannot support primitive data structure like int * (an array) as zval 68 | // zval meshmaterial; 69 | zend_object std; 70 | } php_raylib_model_object; 71 | 72 | static inline php_raylib_model_object *php_raylib_model_fetch_object(zend_object *obj) { 73 | return (php_raylib_model_object *)((char *)obj - XtOffsetOf(php_raylib_model_object, std)); 74 | } 75 | 76 | static inline Model *php_raylib_model_fetch_data(php_raylib_model_object *obj) { 77 | Model *my_model; 78 | if (obj->model->type == RL_MODEL_IS_POINTER) { 79 | my_model = obj->model->data.p; 80 | } else { 81 | my_model = &obj->model->data.v; 82 | } 83 | 84 | return my_model; 85 | } 86 | 87 | #define Z_MODEL_OBJ_P(zv) php_raylib_model_fetch_object(Z_OBJ_P(zv)); 88 | 89 | void php_raylib_model_startup(INIT_FUNC_ARGS); 90 | 91 | #endif //PHP_RAYLIB_MODEL_H 92 | -------------------------------------------------------------------------------- /generate/examples/audio/audio_sound_loading.php: -------------------------------------------------------------------------------- 1 | 18 | #include 19 | #include 20 | 21 | // hashmaps can associate keys with pointer values or integral types. 22 | typedef struct hashmap hashmap; 23 | 24 | // a callback type used for iterating over a map/freeing entries: 25 | // `void (void* key, size_t size, uintptr_t value, void* usr)` 26 | // `usr` is a user pointer which can be passed through `hashmap_iterate`. 27 | typedef void (*hashmap_callback)(void *key, size_t ksize, uintptr_t value, void *usr); 28 | 29 | hashmap* hashmap_create(void); 30 | 31 | // only frees the hashmap object and buckets. 32 | // does not call free on each element's `key` or `value`. 33 | // to free data associated with an element, call `hashmap_iterate`. 34 | void hashmap_free(hashmap* map); 35 | 36 | // does not make a copy of `key`. 37 | // you must copy it yourself if you want to guarantee its lifetime, 38 | // or if you intend to call `hashmap_key_free`. 39 | void hashmap_set(hashmap* map, void* key, size_t ksize, uintptr_t value); 40 | 41 | // adds an entry if it doesn't exist, using the value of `*out_in`. 42 | // if it does exist, it sets value in `*out_in`, meaning the value 43 | // of the entry will be in `*out_in` regardless of whether or not 44 | // it existed in the first place. 45 | // returns true if the entry already existed, returns false otherwise. 46 | bool hashmap_get_set(hashmap* map, void* key, size_t ksize, uintptr_t* out_in); 47 | 48 | // similar to `hashmap_set()`, but when overwriting an entry, 49 | // you'll be able properly free the old entry's data via a callback. 50 | // unlike `hashmap_set()`, this function will overwrite the original key pointer, 51 | // which means you can free the old key in the callback if applicable. 52 | void hashmap_set_free(hashmap* map, void* key, size_t ksize, uintptr_t value, hashmap_callback c, void* usr); 53 | 54 | bool hashmap_get(hashmap* map, void* key, size_t ksize, uintptr_t* out_val); 55 | 56 | #ifdef __HASHMAP_REMOVABLE 57 | void hashmap_remove(hashmap *map, void *key, size_t ksize); 58 | 59 | // same as `hashmap_remove()`, but it allows you to free an entry's data first via a callback. 60 | void hashmap_remove_free(hashmap* m, void* key, size_t ksize, hashmap_callback c, void* usr); 61 | #endif 62 | 63 | int hashmap_size(hashmap* map); 64 | 65 | // iterate over the map, calling `c` on every element. 66 | // goes through elements in the order they were added. 67 | // the element's key, key size, value, and `usr` will be passed to `c`. 68 | void hashmap_iterate(hashmap* map, hashmap_callback c, void* usr); 69 | 70 | // dumps bucket info for debugging. 71 | // allows you to see how many collisions you are getting. 72 | // `0` is an empty bucket, `1` is occupied, and `x` is removed. 73 | //void bucket_dump(hashmap *m); 74 | 75 | #endif // HASHMAP_H -------------------------------------------------------------------------------- /generate/examples/models/resources/LICENSE.md: -------------------------------------------------------------------------------- 1 | | resource | author | licence | notes | 2 | | :------------------- | :---------: | :------ | :---- | 3 | | models/obj/castle.obj,
models/castle_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - | 4 | | models/obj/bridge.obj,
models/bridge_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - | 5 | | models/obj/house.obj,
models/house_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - | 6 | | models/obj/market.obj,
models/market_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - | 7 | | models/obj/turret.obj,
models/turret_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - | 8 | | models/obj/well.obj,
models/well_diffuse.png | [Alberto Cano](https://www.artstation.com/albertocano) | [CC-BY-NC](https://creativecommons.org/licenses/by-nc/4.0/legalcode) | - | 9 | | models/obj/cube.obj,
models/cube_diffuse.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - | 10 | | models/obj/plane.gltf,
models/gltf/plane/plane.bin,
models/gltf/plane/plane_diffuse.png | [GiaHanLam](https://sketchfab.com/GiaHanLam) | [CC-BY](https://creativecommons.org/licenses/by/4.0/) | Used by: [`models_yaw_pitch_roll.c`](https://github.com/raysan5/raylib/blob/master/examples/models/models_yaw_pitch_roll.c) 11 | | models/iqm/guy.iqm,
models/iqm/guyanim.iqm,
models/iqm/guytex.png,
models/iqm/guy.blend | [@culacant](https://github.com/culacant) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - | 12 | | models/iqm/vertex_colored_object.iqm | ❔ | ❔ | - | 13 | | models/gltf/... | _various_ | Check [LICENSE](https://github.com/raysan5/raylib/blob/master/examples/models/resources/models/gltf/LICENSE) | - | 14 | | models/vox/chr_knight.vox | ❔ | ❔ | - | 15 | | models/vox/chr_sword.vox | ❔ | ❔ | - | 16 | | models/vox/monu9.vox | ❔ | ❔ | - | 17 | | billboard.png | [@emegeme](https://github.com/emegeme) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - | 18 | | cubicmap.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - | 19 | | cubicmap_atlas.png | [@emegeme](https://github.com/emegeme) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - | 20 | | heightmap.png | [@raysan5](https://github.com/raysan5) | [CC0](https://creativecommons.org/publicdomain/zero/1.0/) | - | 21 | | dresden_square_1k.hdr | [HDRIHaven](https://hdrihaven.com/hdri/?h=dresden_square) | [CC0](https://hdrihaven.com/p/license.php) | - | 22 | | dresden_square_2k.hdr | [HDRIHaven](https://hdrihaven.com/hdri/?h=dresden_square) | [CC0](https://hdrihaven.com/p/license.php) | - | 23 | | skybox.png | ❔ | ❔ | - | -------------------------------------------------------------------------------- /mesh.h: -------------------------------------------------------------------------------- 1 | #ifndef PHP_RAYLIB_MESH_H 2 | #define PHP_RAYLIB_MESH_H 3 | 4 | #include "include/hashmap.h" 5 | 6 | extern zend_class_entry * php_raylib_mesh_ce; 7 | 8 | // External Free Objects - Prevent Circular Dependency 9 | 10 | extern void php_raylib_mesh_free_storage(zend_object * object); 11 | 12 | extern zend_object * php_raylib_mesh_new(zend_class_entry * ce); 13 | 14 | extern zend_object * php_raylib_mesh_new_ex(zend_class_entry *ce, zend_object *orig); 15 | 16 | extern zend_object_handlers php_raylib_mesh_object_handlers; 17 | 18 | typedef enum { 19 | RL_MESH_IS_POINTER, 20 | RL_MESH_IS_VALUE 21 | } RLMeshDataType; 22 | 23 | typedef union { 24 | Mesh *p; 25 | Mesh v; 26 | } MeshUnion; 27 | 28 | struct RL_Mesh { 29 | unsigned int id; 30 | char *guid; 31 | MeshUnion data; 32 | RLMeshDataType type; 33 | unsigned refCount; 34 | unsigned char deleted; 35 | }; 36 | 37 | static struct RL_Mesh **RL_Mesh_Object_List; 38 | static hashmap *RL_Mesh_Object_Map; 39 | 40 | char* RL_Mesh_Hash_Id(char *str, size_t size); 41 | struct RL_Mesh* RL_Mesh_Create(); 42 | void RL_Mesh_Delete(struct RL_Mesh* object, int index); 43 | void RL_Mesh_Free(struct RL_Mesh* object); 44 | 45 | typedef struct _php_raylib_mesh_object { 46 | struct RL_Mesh *mesh; 47 | HashTable *prop_handler; 48 | // Cannot support primitive data structure like float * (an array) as zval 49 | // zval vertices; 50 | // Cannot support primitive data structure like float * (an array) as zval 51 | // zval texcoords; 52 | // Cannot support primitive data structure like float * (an array) as zval 53 | // zval texcoords2; 54 | // Cannot support primitive data structure like float * (an array) as zval 55 | // zval normals; 56 | // Cannot support primitive data structure like float * (an array) as zval 57 | // zval tangents; 58 | // Cannot support primitive data structure like unsigned char * (an array) as zval 59 | // zval colors; 60 | // Cannot support primitive data structure like unsigned short * (an array) as zval 61 | // zval indices; 62 | // Cannot support primitive data structure like float * (an array) as zval 63 | // zval animvertices; 64 | // Cannot support primitive data structure like float * (an array) as zval 65 | // zval animnormals; 66 | // Cannot support primitive data structure like unsigned char * (an array) as zval 67 | // zval boneids; 68 | // Cannot support primitive data structure like float * (an array) as zval 69 | // zval boneweights; 70 | zend_object std; 71 | } php_raylib_mesh_object; 72 | 73 | static inline php_raylib_mesh_object *php_raylib_mesh_fetch_object(zend_object *obj) { 74 | return (php_raylib_mesh_object *)((char *)obj - XtOffsetOf(php_raylib_mesh_object, std)); 75 | } 76 | 77 | static inline Mesh *php_raylib_mesh_fetch_data(php_raylib_mesh_object *obj) { 78 | Mesh *my_mesh; 79 | if (obj->mesh->type == RL_MESH_IS_POINTER) { 80 | my_mesh = obj->mesh->data.p; 81 | } else { 82 | my_mesh = &obj->mesh->data.v; 83 | } 84 | 85 | return my_mesh; 86 | } 87 | 88 | #define Z_MESH_OBJ_P(zv) php_raylib_mesh_fetch_object(Z_OBJ_P(zv)); 89 | 90 | void php_raylib_mesh_startup(INIT_FUNC_ARGS); 91 | 92 | #endif //PHP_RAYLIB_MESH_H 93 | -------------------------------------------------------------------------------- /config.m4: -------------------------------------------------------------------------------- 1 | dnl $Id$ 2 | dnl config.m4 for extension raylib 3 | 4 | dnl Comments in this file start with the string 'dnl'. 5 | dnl Remove where necessary. This file will not work 6 | dnl without editing. 7 | 8 | dnl If your extension references something external, use with: 9 | 10 | PHP_ARG_WITH(raylib, for raylib support, 11 | Make sure that the comment is aligned: 12 | [ --with-raylib Include raylib support]) 13 | 14 | dnl Otherwise use enable: 15 | 16 | PHP_ARG_ENABLE(raylib, whether to enable raylib support, 17 | Make sure that the comment is aligned: 18 | [ --enable-raylib Enable raylib support]) 19 | 20 | if test "$PHP_RAYLIB" != "no"; then 21 | dnl Write more examples of tests here... 22 | 23 | # get library FOO build options from pkg-config output 24 | AC_PATH_PROG(PKG_CONFIG, pkg-config, no) 25 | AC_MSG_CHECKING(for libraylib) 26 | if test -x "$PKG_CONFIG" && $PKG_CONFIG --exists raylib; then 27 | if $PKG_CONFIG raylib --atleast-version 4.5.0; then 28 | LIBRAYLIB_CFLAGS=`$PKG_CONFIG raylib --cflags` 29 | LIBRAYLIB_LIBDIR=`$PKG_CONFIG raylib --libs` 30 | LIBRAYLIB_VERSON=`$PKG_CONFIG raylib --modversion` 31 | AC_MSG_RESULT(from pkgconfig: version $LIBRAYLIB_VERSON) 32 | else 33 | AC_MSG_ERROR(system libraylib is too old: version 4.5.0 required) 34 | fi 35 | else 36 | AC_MSG_ERROR(pkg-config not found) 37 | fi 38 | PHP_EVAL_LIBLINE($LIBRAYLIB_LIBDIR, RAYLIB_SHARED_LIBADD) 39 | PHP_EVAL_INCLINE($LIBRAYLIB_CFLAGS) 40 | 41 | dnl # --with-raylib -> check with-path 42 | SEARCH_PATH="/usr/local /usr /opt/homebrew/Cellar/raylib/4.5.0 ./cmake-build-debug/_deps/raylib-src/src" # you might want to change this 43 | SEARCH_FOR="/include/raylib.h" # you most likely want to change this 44 | if test -r $PHP_RAYLIB/$SEARCH_FOR; then # path given as parameter 45 | RAYLIB_DIR=$PHP_RAYLIB 46 | else # search default path list 47 | AC_MSG_CHECKING([for raylib files in default path]) 48 | for i in $SEARCH_PATH ; do 49 | if test -r $i/$SEARCH_FOR; then 50 | RAYLIB_DIR=$i 51 | AC_MSG_RESULT(found in $i) 52 | fi 53 | done 54 | fi 55 | 56 | if test -z "$RAYLIB_DIR"; then 57 | AC_MSG_RESULT([not found]) 58 | AC_MSG_ERROR([Please reinstall the raylib distribution]) 59 | fi 60 | 61 | dnl # --with-raylib -> add include path 62 | PHP_ADD_INCLUDE($RAYLIB_DIR/include) 63 | 64 | dnl # --with-raylib -> check for lib and symbol presence 65 | LIBNAME=raylib # you may want to change this 66 | LIBSYMBOL=SetMouseScale # you most likely want to change this 67 | 68 | PHP_CHECK_LIBRARY($LIBNAME,$LIBSYMBOL, 69 | [ 70 | PHP_ADD_LIBRARY_WITH_PATH($LIBNAME, $RAYLIB_DIR/$PHP_LIBDIR, RAYLIB_SHARED_LIBADD) 71 | AC_DEFINE(HAVE_RAYLIBLIB,1,[ ]) 72 | ],[ 73 | AC_MSG_ERROR([wrong raylib lib version or lib not found]) 74 | ],[ 75 | -L$RAYLIB_DIR/$PHP_LIBDIR -lm 76 | ]) 77 | 78 | PHP_SUBST(RAYLIB_SHARED_LIBADD) 79 | 80 | PHP_NEW_EXTENSION(raylib, raylib.c vector2.c vector3.c vector4.c matrix.c color.c rectangle.c image.c texture.c rendertexture.c npatchinfo.c glyphinfo.c font.c camera3d.c camera2d.c mesh.c shader.c materialmap.c material.c transform.c boneinfo.c model.c modelanimation.c ray.c raycollision.c boundingbox.c wave.c audiostream.c sound.c music.c vrdeviceinfo.c vrstereoconfig.c filepathlist.c include/hashmap.c, $ext_shared,) 81 | fi -------------------------------------------------------------------------------- /vrstereoconfig.h: -------------------------------------------------------------------------------- 1 | #ifndef PHP_RAYLIB_VRSTEREOCONFIG_H 2 | #define PHP_RAYLIB_VRSTEREOCONFIG_H 3 | 4 | #include "include/hashmap.h" 5 | #include "matrix.h" 6 | 7 | extern zend_class_entry * php_raylib_vrstereoconfig_ce; 8 | 9 | // External Free Objects - Prevent Circular Dependency 10 | //TODO: Support array/hash 11 | //extern void php_raylib_matrix_array_free_storage(zend_object *object); 12 | 13 | extern void php_raylib_vrstereoconfig_free_storage(zend_object * object); 14 | 15 | extern zend_object * php_raylib_vrstereoconfig_new(zend_class_entry * ce); 16 | 17 | extern zend_object * php_raylib_vrstereoconfig_new_ex(zend_class_entry *ce, zend_object *orig); 18 | 19 | extern zend_object_handlers php_raylib_vrstereoconfig_object_handlers; 20 | 21 | typedef enum { 22 | RL_VRSTEREOCONFIG_IS_POINTER, 23 | RL_VRSTEREOCONFIG_IS_VALUE 24 | } RLVrStereoConfigDataType; 25 | 26 | typedef union { 27 | VrStereoConfig *p; 28 | VrStereoConfig v; 29 | } VrStereoConfigUnion; 30 | 31 | struct RL_VrStereoConfig { 32 | unsigned int id; 33 | char *guid; 34 | VrStereoConfigUnion data; 35 | RLVrStereoConfigDataType type; 36 | unsigned refCount; 37 | unsigned char deleted; 38 | }; 39 | 40 | static struct RL_VrStereoConfig **RL_VrStereoConfig_Object_List; 41 | static hashmap *RL_VrStereoConfig_Object_Map; 42 | 43 | char* RL_VrStereoConfig_Hash_Id(char *str, size_t size); 44 | struct RL_VrStereoConfig* RL_VrStereoConfig_Create(); 45 | void RL_VrStereoConfig_Delete(struct RL_VrStereoConfig* object, int index); 46 | void RL_VrStereoConfig_Free(struct RL_VrStereoConfig* object); 47 | 48 | typedef struct _php_raylib_vrstereoconfig_object { 49 | struct RL_VrStereoConfig *vrstereoconfig; 50 | HashTable *prop_handler; 51 | zval projection; 52 | zval viewoffset; 53 | // Cannot support primitive data structure like float (an array) as zval 54 | // zval leftlenscenter; 55 | // Cannot support primitive data structure like float (an array) as zval 56 | // zval rightlenscenter; 57 | // Cannot support primitive data structure like float (an array) as zval 58 | // zval leftscreencenter; 59 | // Cannot support primitive data structure like float (an array) as zval 60 | // zval rightscreencenter; 61 | // Cannot support primitive data structure like float (an array) as zval 62 | // zval scale; 63 | // Cannot support primitive data structure like float (an array) as zval 64 | // zval scalein; 65 | zend_object std; 66 | } php_raylib_vrstereoconfig_object; 67 | 68 | static inline php_raylib_vrstereoconfig_object *php_raylib_vrstereoconfig_fetch_object(zend_object *obj) { 69 | return (php_raylib_vrstereoconfig_object *)((char *)obj - XtOffsetOf(php_raylib_vrstereoconfig_object, std)); 70 | } 71 | 72 | static inline VrStereoConfig *php_raylib_vrstereoconfig_fetch_data(php_raylib_vrstereoconfig_object *obj) { 73 | VrStereoConfig *my_vrstereoconfig; 74 | if (obj->vrstereoconfig->type == RL_VRSTEREOCONFIG_IS_POINTER) { 75 | my_vrstereoconfig = obj->vrstereoconfig->data.p; 76 | } else { 77 | my_vrstereoconfig = &obj->vrstereoconfig->data.v; 78 | } 79 | 80 | return my_vrstereoconfig; 81 | } 82 | 83 | #define Z_VRSTEREOCONFIG_OBJ_P(zv) php_raylib_vrstereoconfig_fetch_object(Z_OBJ_P(zv)); 84 | 85 | void php_raylib_vrstereoconfig_startup(INIT_FUNC_ARGS); 86 | 87 | #endif //PHP_RAYLIB_VRSTEREOCONFIG_H 88 | -------------------------------------------------------------------------------- /generate/src/Generate/Zend/ZParam.php: -------------------------------------------------------------------------------- 1 | tr = $tr; 19 | $this->name = $name; 20 | $this->type = $type; 21 | $this->isArray = $isArray; 22 | $this->isRef = $isRef; 23 | } 24 | 25 | #[Pure] public function build($spacer = ''): array 26 | { 27 | $input = []; 28 | 29 | if (Helper::isString($this->type)) { 30 | $input[] = sprintf("%sZ_PARAM_STR(%s)", $spacer, $this->name); 31 | } elseif (Helper::isInt($this->type)) { 32 | if ($this->isRef) { 33 | $input[] = sprintf("%sZ_PARAM_ZVAL(%s)", $spacer, $this->name); 34 | } elseif($this->isArray) { 35 | $input[] = sprintf("%sZ_PARAM_ARRAY(%s)", $spacer, $this->name); 36 | } else { 37 | $input[] = sprintf("%sZ_PARAM_LONG(%s)", $spacer, $this->name); 38 | } 39 | } elseif (Helper::isFloat($this->type)) { 40 | if ($this->isRef) { 41 | $input[] = sprintf("%sZ_PARAM_ZVAL(%s)", $spacer, $this->name); 42 | } elseif($this->isArray) { 43 | $input[] = sprintf("%sZ_PARAM_ARRAY(%s)", $spacer, $this->name); 44 | } else { 45 | $input[] = sprintf("%sZ_PARAM_DOUBLE(%s)", $spacer, $this->name); 46 | } 47 | } elseif (Helper::isBool($this->type)) { 48 | $input[] = sprintf("%sZ_PARAM_BOOL(%s)", $spacer, $this->name); 49 | } elseif (!Helper::isPrimitive($this->type)) { 50 | if ($this->isArray) { 51 | $input[] = sprintf("%sZ_PARAM_ARRAY(%s)", $spacer, $this->name); 52 | } else { 53 | $input[] = sprintf("%sZ_PARAM_ZVAL(%s)", $spacer, $this->name); 54 | } 55 | } 56 | 57 | return $input; 58 | } 59 | 60 | #[Pure] public function buildVariables($spacer = ''): array 61 | { 62 | $tr = $this->tr; 63 | $tr['[spacer]'] = $spacer; 64 | 65 | $input = []; 66 | 67 | if (Helper::isString($this->type)) { 68 | $input[] = strtr("[spacer]zend_string *[name];", $tr); 69 | } elseif (Helper::isInt($this->type)) { 70 | if ($this->isArray || $this->isRef) { 71 | $input[] = strtr("[spacer]zval *[name];", $tr); 72 | } else { 73 | $input[] = strtr("[spacer]zend_long [name];", $tr); 74 | } 75 | } elseif (Helper::isFloat($this->type)) { 76 | if ($this->isArray || $this->isRef) { 77 | $input[] = strtr("[spacer]zval *[name];", $tr); 78 | } else { 79 | $input[] = strtr("[spacer]double [name];", $tr); 80 | } 81 | } elseif (Helper::isBool($this->type)) { 82 | $input[] = strtr("[spacer]bool [name];", $tr); 83 | } elseif (!Helper::isPrimitive($this->type)) { 84 | $input[] = strtr("[spacer]zval *[name];", $tr); 85 | } 86 | 87 | return $input; 88 | } 89 | } -------------------------------------------------------------------------------- /generate/examples/models/models_geometric_shapes.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | * 3 | * raylib [models] example - Draw some basic geometric shapes (cube, sphere, cylinder...) 4 | * 5 | * This example has been created using raylib 1.0 (www.raylib.com) 6 | * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) 7 | * 8 | * Copyright (c) 2014 Ramon Santamaria (@raysan5) 9 | * 10 | ********************************************************************************************/ 11 | 12 | #include "raylib.h" 13 | 14 | int main(void) 15 | { 16 | // Initialization 17 | //-------------------------------------------------------------------------------------- 18 | const int screenWidth = 800; 19 | const int screenHeight = 450; 20 | 21 | InitWindow(screenWidth, screenHeight, "raylib [models] example - geometric shapes"); 22 | 23 | // Define the camera to look into our 3d world 24 | Camera camera = { 0 }; 25 | camera.position = (Vector3){ 0.0f, 10.0f, 10.0f }; 26 | camera.target = (Vector3){ 0.0f, 0.0f, 0.0f }; 27 | camera.up = (Vector3){ 0.0f, 1.0f, 0.0f }; 28 | camera.fovy = 45.0f; 29 | camera.projection = CAMERA_PERSPECTIVE; 30 | 31 | SetTargetFPS(60); // Set our game to run at 60 frames-per-second 32 | //-------------------------------------------------------------------------------------- 33 | 34 | // Main game loop 35 | while (!WindowShouldClose()) // Detect window close button or ESC key 36 | { 37 | // Update 38 | //---------------------------------------------------------------------------------- 39 | // TODO: Update your variables here 40 | //---------------------------------------------------------------------------------- 41 | 42 | // Draw 43 | //---------------------------------------------------------------------------------- 44 | BeginDrawing(); 45 | 46 | ClearBackground(RAYWHITE); 47 | 48 | BeginMode3D(camera); 49 | 50 | DrawCube((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, RED); 51 | DrawCubeWires((Vector3){-4.0f, 0.0f, 2.0f}, 2.0f, 5.0f, 2.0f, GOLD); 52 | DrawCubeWires((Vector3){-4.0f, 0.0f, -2.0f}, 3.0f, 6.0f, 2.0f, MAROON); 53 | 54 | DrawSphere((Vector3){-1.0f, 0.0f, -2.0f}, 1.0f, GREEN); 55 | DrawSphereWires((Vector3){1.0f, 0.0f, 2.0f}, 2.0f, 16, 16, LIME); 56 | 57 | DrawCylinder((Vector3){4.0f, 0.0f, -2.0f}, 1.0f, 2.0f, 3.0f, 4, SKYBLUE); 58 | DrawCylinderWires((Vector3){4.0f, 0.0f, -2.0f}, 1.0f, 2.0f, 3.0f, 4, DARKBLUE); 59 | DrawCylinderWires((Vector3){4.5f, -1.0f, 2.0f}, 1.0f, 1.0f, 2.0f, 6, BROWN); 60 | 61 | DrawCylinder((Vector3){1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, GOLD); 62 | DrawCylinderWires((Vector3){1.0f, 0.0f, -4.0f}, 0.0f, 1.5f, 3.0f, 8, PINK); 63 | 64 | DrawGrid(10, 1.0f); // Draw a grid 65 | 66 | EndMode3D(); 67 | 68 | DrawFPS(10, 10); 69 | 70 | EndDrawing(); 71 | //---------------------------------------------------------------------------------- 72 | } 73 | 74 | // De-Initialization 75 | //-------------------------------------------------------------------------------------- 76 | CloseWindow(); // Close window and OpenGL context 77 | //-------------------------------------------------------------------------------------- 78 | 79 | return 0; 80 | } -------------------------------------------------------------------------------- /generate/examples/textures/textures_background_scrolling.php: -------------------------------------------------------------------------------- 1 | width*2) $scrollingBack = 0; 41 | if ($scrollingMid <= -$midground->width*2) $scrollingMid = 0; 42 | if ($scrollingFore <= -$foreground->width*2) $scrollingFore = 0; 43 | //---------------------------------------------------------------------------------- 44 | 45 | // Draw 46 | //---------------------------------------------------------------------------------- 47 | BeginDrawing(); 48 | 49 | ClearBackground(GetColor(0x052c46ff)); 50 | 51 | // Draw background image twice 52 | // NOTE: Texture is scaled twice its size 53 | DrawTextureEx($background, new Vector2($scrollingBack, 20), 0.0, 2.0, $white); 54 | DrawTextureEx($background, new Vector2($background->width*2 + $scrollingBack, 20), 0.0, 2.0, $white); 55 | 56 | // Draw midground image twice 57 | DrawTextureEx($midground, new Vector2($scrollingMid, 20), 0.0, 2.0, $white); 58 | DrawTextureEx($midground, new Vector2($midground->width*2 + $scrollingMid, 20), 0.0, 2.0, $white); 59 | 60 | // Draw foreground image twice 61 | DrawTextureEx($foreground, new Vector2($scrollingFore, 70), 0.0, 2.0, $white); 62 | DrawTextureEx($foreground, new Vector2($foreground->width*2 + $scrollingFore, 70), 0.0, 2.0, $white); 63 | 64 | DrawText("BACKGROUND SCROLLING & PARALLAX", 10, 10, 20, $red); 65 | DrawText("(c) Cyberpunk Street Environment by Luis Zuno (@ansimuz)", $screenWidth - 330, $screenHeight - 20, 10, $ray_white); 66 | 67 | EndDrawing(); 68 | //---------------------------------------------------------------------------------- 69 | } 70 | 71 | // De-Initialization 72 | //-------------------------------------------------------------------------------------- 73 | UnloadTexture($background); // Unload background texture 74 | UnloadTexture($midground); // Unload midground texture 75 | UnloadTexture($foreground); // Unload foreground texture 76 | 77 | CloseWindow(); // Close window and OpenGL context 78 | //-------------------------------------------------------------------------------------- 79 | -------------------------------------------------------------------------------- /generate/src/Generate/ObjectStartup.php: -------------------------------------------------------------------------------- 1 | nameLower . '_startup(INIT_FUNC_ARGS)'; 16 | $input[] = '{'; 17 | $input[] = ' zend_class_entry ce;'; 18 | $input[] = ''; 19 | $input[] = ' memcpy(&php_raylib_' . $struct->nameLower . '_object_handlers, zend_get_std_object_handlers(), sizeof(zend_object_handlers));'; 20 | $input[] = ' php_raylib_' . $struct->nameLower . '_object_handlers.offset = XtOffsetOf(php_raylib_' . $struct->nameLower . '_object, std);'; 21 | $input[] = ' php_raylib_' . $struct->nameLower . '_object_handlers.free_obj = &php_raylib_' . $struct->nameLower . '_free_storage;'; 22 | $input[] = ' php_raylib_' . $struct->nameLower . '_object_handlers.clone_obj = php_raylib_' . $struct->nameLower . '_clone;'; 23 | $input[] = ''; 24 | $input[] = ' // Props'; 25 | $input[] = ' php_raylib_' . $struct->nameLower . '_object_handlers.get_property_ptr_ptr = php_raylib_' . $struct->nameLower . '_get_property_ptr_ptr;'; 26 | $input[] = ' php_raylib_' . $struct->nameLower . '_object_handlers.get_gc = php_raylib_' . $struct->nameLower . '_get_gc;'; 27 | $input[] = ' php_raylib_' . $struct->nameLower . '_object_handlers.get_properties = php_raylib_' . $struct->nameLower . '_get_properties;'; 28 | $input[] = ' php_raylib_' . $struct->nameLower . '_object_handlers.read_property = php_raylib_' . $struct->nameLower . '_read_property;'; 29 | $input[] = ' php_raylib_' . $struct->nameLower . '_object_handlers.write_property = php_raylib_' . $struct->nameLower . '_write_property;'; 30 | $input[] = ' php_raylib_' . $struct->nameLower . '_object_handlers.has_property = php_raylib_' . $struct->nameLower . '_has_property;'; 31 | $input[] = ''; 32 | $input[] = ' // Init'; 33 | $input[] = ' INIT_NS_CLASS_ENTRY(ce, "raylib", "' . $struct->name . '", php_raylib_' . $struct->nameLower . '_methods);'; 34 | $input[] = ' php_raylib_' . $struct->nameLower . '_ce = zend_register_internal_class(&ce);'; 35 | $input[] = ' php_raylib_' . $struct->nameLower . '_ce->create_object = php_raylib_' . $struct->nameLower . '_new;'; 36 | $input[] = ''; 37 | $input[] = ' // Props'; 38 | $input[] = ' zend_hash_init(&php_raylib_' . $struct->nameLower . '_prop_handlers, 0, NULL, php_raylib_' . $struct->nameLower . '_free_prop_handler, 1);'; 39 | 40 | foreach ($struct->fields as $field) { 41 | $params = []; 42 | foreach ($struct->fieldsByType() as $fieldType) { 43 | if ($field->typeName === $fieldType->typeName) { 44 | $params[] = 'php_raylib_' . $struct->nameLower . '_get_' . $field->nameLower; 45 | $params[] = 'php_raylib_' . $struct->nameLower . '_set_' . $field->nameLower; 46 | } else { 47 | $params[] = 'NULL'; 48 | $params[] = 'NULL'; 49 | } 50 | } 51 | 52 | $input[] = ' php_raylib_' . $struct->nameLower . '_register_prop_handler(&php_raylib_' . $struct->nameLower . '_prop_handlers, "' . $field->name . '", ' . implode(', ', $params) . ');'; 53 | } 54 | $input[] = '}'; 55 | $input[] = ''; 56 | 57 | return $input; 58 | } 59 | } 60 | -------------------------------------------------------------------------------- /generate/examples/models/models_heightmap.c: -------------------------------------------------------------------------------- 1 | /******************************************************************************************* 2 | * 3 | * raylib [models] example - Heightmap loading and drawing 4 | * 5 | * This example has been created using raylib 1.8 (www.raylib.com) 6 | * raylib is licensed under an unmodified zlib/libpng license (View raylib.h for details) 7 | * 8 | * Copyright (c) 2015 Ramon Santamaria (@raysan5) 9 | * 10 | ********************************************************************************************/ 11 | 12 | #include "raylib.h" 13 | 14 | int main(void) 15 | { 16 | // Initialization 17 | //-------------------------------------------------------------------------------------- 18 | const int screenWidth = 800; 19 | const int screenHeight = 450; 20 | 21 | InitWindow(screenWidth, screenHeight, "raylib [models] example - heightmap loading and drawing"); 22 | 23 | // Define our custom camera to look into our 3d world 24 | Camera camera = { { 18.0f, 18.0f, 18.0f }, { 0.0f, 0.0f, 0.0f }, { 0.0f, 1.0f, 0.0f }, 45.0f, 0 }; 25 | 26 | Image image = LoadImage("resources/heightmap.png"); // Load heightmap image (RAM) 27 | Texture2D texture = LoadTextureFromImage(image); // Convert image to texture (VRAM) 28 | 29 | Mesh mesh = GenMeshHeightmap(image, (Vector3){ 16, 8, 16 }); // Generate heightmap mesh (RAM and VRAM) 30 | Model model = LoadModelFromMesh(mesh); // Load model from generated mesh 31 | 32 | model.materials[0].maps[MATERIAL_MAP_DIFFUSE].texture = texture; // Set map diffuse texture 33 | Vector3 mapPosition = { -8.0f, 0.0f, -8.0f }; // Define model position 34 | 35 | UnloadImage(image); // Unload heightmap image from RAM, already uploaded to VRAM 36 | 37 | SetCameraMode(camera, CAMERA_ORBITAL); // Set an orbital camera mode 38 | 39 | SetTargetFPS(60); // Set our game to run at 60 frames-per-second 40 | //-------------------------------------------------------------------------------------- 41 | 42 | // Main game loop 43 | while (!WindowShouldClose()) // Detect window close button or ESC key 44 | { 45 | // Update 46 | //---------------------------------------------------------------------------------- 47 | UpdateCamera(&camera); // Update camera 48 | //---------------------------------------------------------------------------------- 49 | 50 | // Draw 51 | //---------------------------------------------------------------------------------- 52 | BeginDrawing(); 53 | 54 | ClearBackground(RAYWHITE); 55 | 56 | BeginMode3D(camera); 57 | 58 | DrawModel(model, mapPosition, 1.0f, RED); 59 | 60 | DrawGrid(20, 1.0f); 61 | 62 | EndMode3D(); 63 | 64 | DrawTexture(texture, screenWidth - texture.width - 20, 20, WHITE); 65 | DrawRectangleLines(screenWidth - texture.width - 20, 20, texture.width, texture.height, GREEN); 66 | 67 | DrawFPS(10, 10); 68 | 69 | EndDrawing(); 70 | //---------------------------------------------------------------------------------- 71 | } 72 | 73 | // De-Initialization 74 | //-------------------------------------------------------------------------------------- 75 | UnloadTexture(texture); // Unload texture 76 | UnloadModel(model); // Unload model 77 | 78 | CloseWindow(); // Close window and OpenGL context 79 | //-------------------------------------------------------------------------------------- 80 | 81 | return 0; 82 | } --------------------------------------------------------------------------------