├── examples ├── camelia.png ├── window.raku ├── draw-unicode-text.raku ├── load-image.raku ├── flying-butterfly.raku ├── 3d-camera.raku └── rotating-butterfly.raku ├── resources ├── fonts │ └── dejavu.png ├── raylib_allocations.c └── raylib_pointerized_wrapper.c ├── .gitignore ├── screenshots ├── 3dcamera-example.png ├── flying-butterfly.gif └── rotating-butterfly.gif ├── t ├── 04-eval-bindings.rakutest ├── 01-parse-raylib.rakutest ├── 02-extern.rakutest ├── 05-make-colors.rakutest ├── 03-generate-bindings.rakutest └── 00-use.rakutest ├── Makefile.in ├── META6.json ├── sparrow.yaml ├── lib └── Raylib │ ├── Generator.rakumod │ ├── Grammar.rakumod │ └── Actions.rakumod ├── configure.raku ├── README.md └── LICENSE /examples/camelia.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vushu/raylib-raku/HEAD/examples/camelia.png -------------------------------------------------------------------------------- /resources/fonts/dejavu.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vushu/raylib-raku/HEAD/resources/fonts/dejavu.png -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | lib/.precomp 2 | .precomp/ 3 | raylib-raku/ 4 | raylib-raku.iml 5 | .idea/ 6 | resources/libraries/ -------------------------------------------------------------------------------- /screenshots/3dcamera-example.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vushu/raylib-raku/HEAD/screenshots/3dcamera-example.png -------------------------------------------------------------------------------- /screenshots/flying-butterfly.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vushu/raylib-raku/HEAD/screenshots/flying-butterfly.gif -------------------------------------------------------------------------------- /screenshots/rotating-butterfly.gif: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/vushu/raylib-raku/HEAD/screenshots/rotating-butterfly.gif -------------------------------------------------------------------------------- /t/04-eval-bindings.rakutest: -------------------------------------------------------------------------------- 1 | use Test; 2 | 3 | use lib 'lib'; 4 | 5 | use Raylib::Bindings; 6 | 7 | use-ok "Raylib::Bindings"; 8 | 9 | done-testing; 10 | -------------------------------------------------------------------------------- /examples/window.raku: -------------------------------------------------------------------------------- 1 | use Raylib::Bindings; 2 | 3 | my $white = Color.init(245, 245, 245, 255); 4 | init-window(800, 450, "Raylib window in Raku!"); 5 | set-target-fps(60); 6 | while !window-should-close { 7 | begin-drawing; 8 | clear-background($white); 9 | 10 | draw-fps(10,10); 11 | end-drawing; 12 | } 13 | close-window; -------------------------------------------------------------------------------- /Makefile.in: -------------------------------------------------------------------------------- 1 | .PHONY: clean test 2 | CC = %CC% 3 | RAKU = %EXECUTABLE% 4 | CFLAGS =-shared $$(pkg-config --libs --cflags raylib) 5 | EXT = $(shell uname | awk '{if ($$1 == "Darwin") print "dylib"; else print "so";}') 6 | 7 | all: raylib-raku 8 | 9 | raylib-raku: 10 | $(CC) -g -fPIC resources/raylib_allocations.c resources/raylib_pointerized_wrapper.c $(CFLAGS) -o resources/libraries/libraylib.$(EXT) 11 | 12 | install: 13 | $(RAKU) configure.raku --install -------------------------------------------------------------------------------- /t/01-parse-raylib.rakutest: -------------------------------------------------------------------------------- 1 | use Test; 2 | 3 | use lib 'lib'; 4 | 5 | # use Raylib::Grammar; 6 | 7 | # my $parser = RaylibGrammar.new; 8 | 9 | # my $raylib-header = slurp "generator/raylib.h"; 10 | 11 | # my $match = $parser.parse($raylib-header); 12 | 13 | # download the h file 14 | #wget https://raw.githubusercontent.com/raysan5/raylib/master/src/raylib.h . 15 | #And run this test below 16 | 17 | #if $match { 18 | #ok True, "---- Successfully parsed raylib.h ----"; 19 | #} else { 20 | #ok False, "Failed to parse ralib.h"; 21 | #} 22 | ok True; 23 | 24 | 25 | done-testing; 26 | -------------------------------------------------------------------------------- /examples/draw-unicode-text.raku: -------------------------------------------------------------------------------- 1 | use Raylib::Bindings; 2 | 3 | my $black = init-black; 4 | my $red = init-red; 5 | 6 | my Str $text = "Αα Νν Ξξ Οο Ππ Ρρ Σσς Ττ Υυ "; # Important that the unicode is part of the font or else it won't show. 7 | my int32 $count = 0; 8 | init-window(800, 450, "Draw Unicode"); 9 | my Str $file = "resources/fonts/dejavu.fnt"; # You can use .ttf or .fnt, but it seems like .fnt are better supported by Raylib. 10 | my Font $font = load-font($file); 11 | 12 | set-target-fps(60); 13 | 14 | my $position = Vector2.init(130e0, 210e0); 15 | while !window-should-close { 16 | begin-drawing; 17 | clear-background($black); 18 | draw-text-ex($font, $text, $position, 38e0, 2e0, $red); 19 | end-drawing; 20 | } 21 | 22 | close-window; 23 | -------------------------------------------------------------------------------- /examples/load-image.raku: -------------------------------------------------------------------------------- 1 | use Raylib::Bindings; 2 | 3 | constant $screen-width = 800; 4 | constant $screen-height = 450; 5 | 6 | my $white = Color.init(245, 245, 245, 255); 7 | 8 | my $string = "examples/camelia.png"; 9 | 10 | init-window($screen-width, $screen-height, $string); 11 | 12 | # Loading image ------ 13 | my $camelia = load-image($string); 14 | my $texture = load-texture-from-image($camelia); 15 | unload-image($camelia); 16 | 17 | my $img-pos = Vector2.init($screen-width/2e0, ($screen-height/2e0) - $texture.height/2 - 20e0); 18 | 19 | set-target-fps(60); 20 | while !window-should-close { 21 | begin-drawing; 22 | clear-background($white); 23 | 24 | draw-texture-v($texture, $img-pos, $white); 25 | 26 | draw-fps(10,10); 27 | end-drawing; 28 | } 29 | unload-texture($texture); 30 | close-window; -------------------------------------------------------------------------------- /t/02-extern.rakutest: -------------------------------------------------------------------------------- 1 | use Test; 2 | 3 | use lib 'lib'; 4 | 5 | use Raylib::Grammar; 6 | 7 | plan 1; 8 | my $parser = RaylibGrammar.new; 9 | 10 | my $code = q:to/END/; 11 | #define RAYLIB_VERSION "4.6-dev" 12 | 13 | // Some compilers (mostly macos clang) default to C++98, 14 | // where aggregate initialization can't be used 15 | // So, give a more clear error stating how to fix this 16 | #if !defined(_MSC_VER) && (defined(__cplusplus) && __cplusplus < 201103L) 17 | #error "C++11 or later is required. Add -std=c++11" 18 | #endif 19 | 20 | 21 | #ifndef Test 22 | extern "C" { 23 | #endif 24 | #if defined(__cplusplus) 25 | } 26 | #endif 27 | 28 | RLAPI const char *TextFormat(const char *text, ...); // Text formatting with variables (sprintf() style) 29 | END 30 | 31 | 32 | ok $parser.parse($code), 'Parsing extern rule '; 33 | done-testing; 34 | -------------------------------------------------------------------------------- /examples/flying-butterfly.raku: -------------------------------------------------------------------------------- 1 | use Raylib::Bindings; 2 | 3 | constant $screen-width = 1024; 4 | constant $screen-height = 450; 5 | my $white = init-white; 6 | my $background = init-skyblue; 7 | init-window($screen-width, $screen-height, "raylib-raku"); 8 | 9 | my $string = "examples/camelia.png"; 10 | my $camelia = load-image($string); 11 | my $texture = load-texture-from-image($camelia); 12 | unload-image($camelia); 13 | 14 | my $img-pos = Vector2.init(185e0, ($screen-height/2e0) - $texture.height/2 - 10); 15 | 16 | set-target-fps(60); 17 | while !window-should-close { 18 | $img-pos.y += sin(get-time * 10) * 5; 19 | $img-pos.x += (sin(get-time * 1.5) + cos(get-time * 1.5)) * 6; 20 | 21 | begin-drawing; 22 | clear-background($background); 23 | 24 | draw-texture-v($texture, $img-pos, $white); 25 | 26 | end-drawing; 27 | } 28 | unload-texture($texture); 29 | close-window; -------------------------------------------------------------------------------- /t/05-make-colors.rakutest: -------------------------------------------------------------------------------- 1 | use v6.d; 2 | use Test; 3 | 4 | use lib 'lib'; 5 | 6 | use Raylib::Grammar; 7 | use Raylib::Actions; 8 | 9 | my $code = q:to/END/; 10 | #define LIGHTGRAY CLITERAL(Color){ 200, 200, 200, 255 } // Light Gray 11 | #define GRAY CLITERAL(Color){ 130, 130, 130, 255 } // Gray 12 | #define DARKGRAY CLITERAL(Color){ 80, 80, 80, 255 } // Dark Gray 13 | #define YELLOW CLITERAL(Color){ 253, 249, 0, 255 } // Yellow 14 | #define GOLD CLITERAL(Color){ 255, 203, 0, 255 } // Gold 15 | #define ORANGE CLITERAL(Color){ 255, 161, 0, 255 } // Orange 16 | #define PINK CLITERAL(Color){ 255, 109, 194, 255 } // Pink 17 | #define RED CLITERAL(Color){ 230, 41, 55, 255 } // Red 18 | END 19 | my $parser = RaylibGrammar.new; 20 | my $actions = RaylibActions.new; 21 | 22 | $parser.parse($code, actions => $actions); 23 | 24 | ok True; 25 | done-testing; 26 | -------------------------------------------------------------------------------- /examples/3d-camera.raku: -------------------------------------------------------------------------------- 1 | use Raylib::Bindings; 2 | 3 | #COLORS 4 | my $white = Color.init(245, 245, 245, 255); 5 | my $red = Color.init(230, 41, 55, 255); 6 | my $dark-gray = Color.init(80, 80, 80, 255); 7 | my $maroon = Color.init(190, 33, 55, 255); 8 | 9 | #Camera 10 | my $position = Vector3.init(0e0, 10e0, 10e0); 11 | my $target = Vector3.init(0e0, 0e0, 0e0); 12 | my $up = Vector3.init(0e0, 1e0, 0e0); 13 | my $fovy = 45e0; 14 | my $projection = CameraProjection::CAMERA_PERSPECTIVE; 15 | my $cube-position = Vector3.init(0e0, 0e0, 0e0); 16 | my $camera = Camera3D.init($position, $target, $up, $fovy, $projection); 17 | 18 | 19 | init-window(800, 450, "raylib-raku"); 20 | set-target-fps(60); 21 | while (!window-should-close) { 22 | begin-drawing; 23 | clear-background($white); 24 | begin-mode3d($camera); 25 | draw-cube($cube-position, 2e0, 2e0, 2e0, $red); 26 | draw-cube-wires($cube-position, 2e0, 2e0, 2e0, $maroon); 27 | draw-grid(10, 1e0); 28 | end-mode3d; 29 | 30 | draw-text("Welcome to the third dimension!", 10, 40, 20, $dark-gray); 31 | draw-fps(10,10); 32 | end-drawing; 33 | } 34 | close-window; -------------------------------------------------------------------------------- /META6.json: -------------------------------------------------------------------------------- 1 | { 2 | "auth": "zef:vushu", 3 | "authors": [ 4 | "Dan Vu (vushu)" 5 | ], 6 | "build-depends": [], 7 | "depends": { 8 | "build": { 9 | "requires": [ 10 | "Distribution::Builder::MakeFromJSON", 11 | { 12 | "from": "bin", 13 | "name": "raku" 14 | } 15 | ] 16 | }, 17 | "runtime": { 18 | "requires": [ 19 | { 20 | "from": "bin", 21 | "name": "raku" 22 | } 23 | ] 24 | } 25 | }, 26 | "description": "Raylib bindings for raku, using grammar to parse raylib.h and auto generate the bindings", 27 | "license": "Artistic-2.0", 28 | "name": "Raylib::Bindings", 29 | "provides": { 30 | "Raylib::Bindings": "lib/Raylib/Bindings.rakumod" 31 | }, 32 | "resources": [ 33 | "libraries/raylib" 34 | ], 35 | "test-depends": [], 36 | "version": "0.0.18", 37 | "source-url": "https://github.com/vushu/raylib-raku.git", 38 | "builder": "Distribution::Builder::MakeFromJSON", 39 | "build": { 40 | "makefile-variables": { 41 | "rakuopts": { 42 | "run": [ 43 | "raku", 44 | "configure.raku" 45 | ] 46 | } 47 | } 48 | } 49 | } -------------------------------------------------------------------------------- /examples/rotating-butterfly.raku: -------------------------------------------------------------------------------- 1 | use Raylib::Bindings; 2 | 3 | constant $screen-width = 1024; 4 | constant $screen-height = 450; 5 | my $white = Color.init(245, 245, 245, 255); 6 | init-window($screen-width, $screen-height, "raylib-raku"); 7 | 8 | # LOADING Texture 9 | my $string = "examples/camelia.png"; 10 | my Texture2D $camelia = load-texture($string); 11 | 12 | my $frame-width = $camelia.width.Num; 13 | my $frame-height = $camelia.height.Num; 14 | 15 | my $source-rec = Rectangle.init(0e0, 0e0, $frame-width, $frame-height); 16 | my $dest-rec = Rectangle.init($screen-width/2.0e0, $screen-height/2.0e0, $frame-width * 2e0, $frame-height * 2e0); 17 | my $origin = Vector2.init($frame-width, $frame-height); 18 | my $gray = Color.init(130, 130, 130, 255); 19 | 20 | my $rotation = 0; 21 | 22 | set-target-fps(60); 23 | while !window-should-close { 24 | $rotation++; 25 | begin-drawing; 26 | clear-background($white); 27 | draw-texture-pro($camelia, $source-rec, $dest-rec, $origin, $rotation.Num, $white); 28 | draw-line($dest-rec.x.Int, 0, $dest-rec.x.Int, $screen-height, $gray); 29 | draw-line(0, $dest-rec.y.Int, $screen-width, $dest-rec.y.Int, $gray); 30 | draw-texture-pro($camelia, $source-rec, $dest-rec, $origin, $rotation.Num, $white); 31 | 32 | draw-fps(10,10); 33 | end-drawing; 34 | } 35 | 36 | unload-texture($camelia); 37 | close-window; -------------------------------------------------------------------------------- /sparrow.yaml: -------------------------------------------------------------------------------- 1 | image: 2 | - melezhik/sparrow:alpine_arm 3 | #- melezhik/sparrow:debian_arm 4 | - melezhik/sparrow:ubuntu_arm 5 | 6 | tasks: 7 | - 8 | name: main 9 | default: true 10 | language: Bash 11 | code: | 12 | set -e 13 | cd source/ 14 | zef install . 15 | zef test . 16 | depends: 17 | - 18 | name: system_deps 19 | - 20 | name: system_deps 21 | language: Bash 22 | code: | 23 | set -e 24 | if test $os = "alpine"; then 25 | sudo apk add --repository=http://dl-cdn.alpinelinux.org/alpine/edge/testing/ raylib-dev 26 | elif test $os = "debian"; then 27 | echo "debian install is not yet supported" 28 | elif test $os = "ubuntu"; then 29 | sudo apt-get update -y 1>/dev/null 30 | sudo apt install build-essential -y 1>/dev/null 31 | sudo apt install libasound2-dev libx11-dev libxrandr-dev \ 32 | libxi-dev libgl1-mesa-dev libglu1-mesa-dev libxcursor-dev \ 33 | libxinerama-dev -y 1>/dev/null 34 | mkdir -p .dist && cd .dist 35 | git clone https://github.com/raysan5/raylib.git 36 | cd raylib/src 37 | make PLATFORM=PLATFORM_DESKTOP # To make the static version. 38 | make PLATFORM=PLATFORM_DESKTOP RAYLIB_LIBTYPE=SHARED # To make the dynamic shared version. 39 | sudo make install 40 | fi 41 | -------------------------------------------------------------------------------- /lib/Raylib/Generator.rakumod: -------------------------------------------------------------------------------- 1 | use Raylib::Grammar; 2 | use Raylib::Actions; 3 | 4 | constant generation-message = "# This Raku module is generated from raylib.h"; 5 | 6 | sub generate-bindings($raylib-h-file, $output-dir) is export { 7 | say "Generating raylib bindings..."; 8 | my $parser = RaylibGrammar.new; 9 | my $actions = RaylibActions.new; 10 | $actions.library-name = "LIBRAYLIB"; 11 | my $raylib = slurp $raylib-h-file; 12 | my $parsed = $parser.parse($raylib, actions => $actions); 13 | 14 | my $file = open "lib/Raylib/Bindings.rakumod", :w; 15 | $file.say(generation-message); 16 | $file.say("unit module Raylib::Bindings:ver<0.0.18>:auth;"); 17 | $file.say("use NativeCall;"); 18 | $file.say("constant LIBRAYLIB = %\?RESOURCES;"); 19 | for $actions.bindings -> $binding { 20 | $file.say($binding); 21 | } 22 | 23 | $file.say("####### Predefined colors ########"); 24 | for $actions.predifined-colors -> $binding { 25 | $file.say($binding); 26 | } 27 | 28 | $file.say("####### Pointerized functions ########"); 29 | for $actions.pointerized_bindings -> $binding { 30 | $file.say($binding); 31 | } 32 | 33 | $file.say("####### Allocation functions ########"); 34 | for $actions.alloc_bindings -> $binding { 35 | $file.say($binding); 36 | } 37 | 38 | $file.close; 39 | 40 | my $wrapper_file = open "$output-dir/raylib_pointerized_wrapper.c", :w; 41 | $wrapper_file.say("// This file is generated by raylib-raku"); 42 | $wrapper_file.say("#include "); 43 | $wrapper_file.say("#include "); 44 | 45 | for $actions.c_pointerize_bindings -> $binding { 46 | $wrapper_file.say($binding); 47 | } 48 | $wrapper_file.close; 49 | 50 | my $alloc_file = open "$output-dir/raylib_allocations.c", :w; 51 | $alloc_file.say("// This file is generated by raylib-raku"); 52 | $alloc_file.say("#include "); 53 | $alloc_file.say("#include "); 54 | $alloc_file.say("#include "); 55 | 56 | for $actions.c_alloc_funtions -> $binding { 57 | $alloc_file.say($binding); 58 | } 59 | $alloc_file.close; 60 | say "Done generating raylib bindings!"; 61 | } 62 | 63 | 64 | 65 | sub MAIN { 66 | generate-bindings($*CWD); 67 | } -------------------------------------------------------------------------------- /configure.raku: -------------------------------------------------------------------------------- 1 | #!usr/bin/env raku 2 | use lib 'lib'; 3 | use Raylib::Generator; 4 | 5 | my @search-paths = ['/usr/include', '/usr/local/include']; 6 | 7 | sub check-if-installed { 8 | my $library_name = 'raylib'; 9 | my $exitcode = shell("pkg-config --exists $library_name").exitcode; 10 | my $failed = $exitcode == 1; 11 | die "raylib is isn't installed, please install it" if $failed; 12 | 13 | } 14 | 15 | sub get-header-from-pkg-config($library_name) { 16 | my $proc = shell("pkg-config --cflags $library_name", :out); 17 | my $res = $proc.out.slurp: :close; 18 | $res = $res.trim; 19 | if !$res { 20 | for @search-paths -> $path { 21 | say "Searching for raylib.h in $path"; 22 | $res = use-find-raylib-header($path); 23 | return $res if $res.chars > 0; 24 | } 25 | die "----- Failed to locate raylib.h! abort installation. -----"; 26 | } 27 | else { 28 | my $raylib-h-file = $res.substr(2); 29 | $raylib-h-file ~= "/$library_name.h"; 30 | return $raylib-h-file; 31 | } 32 | } 33 | 34 | sub use-find-raylib-header($path) { 35 | my $proc = shell("find $path -name 'raylib.h'", :out); 36 | my $res = $proc.out.slurp: :close; 37 | $res = $res.trim; 38 | return $res; 39 | } 40 | 41 | sub configure{ 42 | my $raylib-h-file = "/usr/local/include/raylib.h"; 43 | my $library_name = 'raylib'; 44 | if $*DISTRO.name ~~ /window/ { 45 | die "Windows is unsupported for now"; 46 | } 47 | elsif $*DISTRO.name ~~ /macos/ { 48 | say "OS is MACOS"; 49 | check-if-installed; 50 | $raylib-h-file = get-header-from-pkg-config($library_name); 51 | } 52 | else { 53 | say "OS is Linux"; 54 | check-if-installed; 55 | $raylib-h-file = get-header-from-pkg-config($library_name); 56 | 57 | } 58 | say "Header file found in: ", $raylib-h-file; 59 | my $srcdir = $*CWD; 60 | my $output-dir="$srcdir/resources"; 61 | mkdir($output-dir); 62 | generate-bindings($raylib-h-file, $output-dir); 63 | } 64 | 65 | sub install { 66 | say "Installing Raylib::Bindings"; 67 | my $repo = %*ENV 68 | ?? CompUnit::RepositoryRegistry.repository-for-name(%*ENV) 69 | !! ( 70 | CompUnit::RepositoryRegistry.repository-for-name('site'), 71 | |$*REPO.repo-chain.grep(CompUnit::Repository::Installable) 72 | ).first(*.can-install) 73 | or die "Cannot find a repository to install to"; 74 | say "Installing into $repo"; 75 | my $dist = Distribution::Path.new($*CWD); 76 | 77 | # workaround for missing proper handling of libraries in Distribution::Path 78 | my $libraylib; 79 | $dist.meta = ( 80 | |$dist.meta.grep(* ne $libraylib.Str), 81 | {'resources/libraries/libraylib' => $libraylib}, 82 | ); 83 | 84 | $repo.install($dist); 85 | say "Installed successfully."; 86 | } 87 | 88 | 89 | sub MAIN(:$install is copy) { 90 | configure if !$install; 91 | install if $install; 92 | } -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | ## raylib-raku (Raylib::Bindings) 2 | [![SparrowCI](https://ci.sparrowhub.io/project/git-vushu-raylib-raku/badge?foo=bar)](https://ci.sparrowhub.io) 3 | 4 | Autogenerated raylib-raku bindings, powered by raku grammar and 5 | actions. 6 | ### Preface 7 | To make Raku play together with Raylib, many of Raylib's functions has to be wrapped into a function, 8 | to support pass as pointer meaning we are `"pointerizing"` the functions. This is done automatically when generating the bindings. 9 | The bindings are also converted to `kebab-case` to fit Raku code style. 10 | 11 | #### On installation: 12 | - `Generator.rakumod` is fed `raylib.h` which gets parsed and translated via grammar and actions to Raku and C code. 13 | - `Bindings.rakumod` will be generated and placed into lib/Raylib 14 | - The pointerization and allocation C code gets compiled to be used by Raylib::Bindings. 15 | 16 | Raylib::Bindings comes with support for malloc-ing Raylib structs, 17 | 18 | Example the code below will allocate Color as a pointer. 19 | `my $white = Color.init(245, 245, 245, 255);` 20 | 21 | Almost all struct/class in Raylib::Bindings are equipped with an `init` function, 22 | which mallocs. 23 | Manually calling `free` isn't necessary, since every struct/class are also equipped with a `free` on destroy mechanism and gets handled by the GC. 24 | Here is the `DESTROY` method of `Color` 25 | ``` 26 | submethod DESTROY { 27 | free-Color(self); 28 | } 29 | ``` 30 | --- 31 | ### Prerequisite 32 | *install raylib from:* 33 | ``` 34 | https://github.com/raysan5/raylib 35 | ``` 36 | --- 37 | ### Install 38 | ``` 39 | zef install Raylib::Bindings 40 | ``` 41 | ### Install from repository 42 | ``` 43 | git clone git@github.com:vushu/raylib-raku.git 44 | cd raylib-raku 45 | zef install . 46 | ``` 47 | --- 48 | ### Examples 49 | ``` 50 | raku examples/window.raku 51 | raku examples/flying-butterfly.raku 52 | raku examples/rotating-butterfly.raku 53 | raku examples/3d-camera.raku 54 | ``` 55 | 56 | ### Mutable strings 57 | To parse mutable string use CArray[uint8] important to encode it as `utf-8` 58 | Example: 59 | ``` 60 | # .encode takes care of UTF-8 encoding. If $array is used 61 | # as a string by the native function, don't forget to append the 62 | # NULL byte that terminates a C string: ---------v 63 | my $array = CArray[uint8].new("Foo".encode.list, 0); 64 | ``` 65 | 66 | ### Termification of functions 67 | functions that doesn't require parameters are generated as sub term meaning 68 | you don't call with parentheses (https://docs.raku.org/language/syntax#term_term:%3C%3E) 69 | eg. 70 | 71 | ``` 72 | get-fps; 73 | get-frame-time; 74 | get-time; 75 | begin-draw; 76 | end-draw; 77 | etc ... 78 | ``` 79 | 80 | #### More examples at 81 | https://www.raylib.com/examples.html 82 | 83 | #### Cheatsheet 84 | https://www.raylib.com/cheatsheet/cheatsheet.html 85 | #### Wiki 86 | https://github.com/raysan5/raylib/wiki 87 | 88 | --- 89 | ### Screenshots 90 | 91 | ![Flying Camelia](screenshots/flying-butterfly.gif) 92 | 93 | ![Rotating Camelia](screenshots/rotating-butterfly.gif) 94 | 95 | ![2d camera](screenshots/3dcamera-example.png) 96 | 97 | --- 98 | 99 | #### Missing: 100 | - code comments needs to be included. 101 | - support for windows. 102 | 103 | ### Problem on some callbacks 104 | example for `set-audio-stream-callback`: 105 | the following happens: 106 | ``` 107 | MoarVM panic: native callback ran on thread (some-thread-id) unknown to MoarVM 108 | ``` 109 | 110 | Solution yet to be found. 111 | 112 | ***help is appreciated!*** 113 | -------------------------------------------------------------------------------- /lib/Raylib/Grammar.rakumod: -------------------------------------------------------------------------------- 1 | grammar RaylibGrammar { 2 | token TOP { 3 | [ ]* 4 | } 5 | 6 | rule defined-content { 7 | | 8 | | 9 | | 10 | | 11 | | 12 | | 13 | | 14 | } 15 | 16 | rule macro-block { 17 | | 18 | | 19 | | 20 | | 21 | | 22 | | 23 | } 24 | 25 | rule typedef-ignored { 26 | 'typedef' 'enum' 'bool' 'bool' ';' 27 | } 28 | 29 | rule extern { 30 | 'extern' '{' 31 | } 32 | 33 | token closing-bracket { 34 | '}' 35 | } 36 | 37 | rule if-macro-block { 38 | '#if' \N* \n? * '#endif' 39 | } 40 | 41 | rule ifndef-block { 42 | '#ifndef' * '#endif' 43 | } 44 | rule error-macro-line { 45 | '#error' \N* \n? 46 | } 47 | rule else-macro-line { 48 | '#else' \n? 49 | } 50 | 51 | rule elif-macro-line { 52 | '#elif' \N* \n? 53 | } 54 | 55 | rule include { 56 | '#include' '<' ~ '>' [ '.h' | ] 57 | } 58 | 59 | rule if-defined { 60 | '#if' \N* \n? 61 | } 62 | 63 | rule elif-defined { 64 | '#elif' '!'? 'defined' '(' .* ')' * 65 | } 66 | 67 | token elif { 68 | '#elif' 69 | } 70 | 71 | token endif { 72 | '#endif' 73 | } 74 | 75 | rule statement { 76 | | 77 | | 78 | | 79 | } 80 | 81 | rule block { 82 | '{' ~ '}' * 83 | } 84 | 85 | token typedef { 86 | | 87 | | 88 | | 89 | | 90 | | 91 | | 92 | } 93 | 94 | rule typedef-alias { 95 | 'typedef' ';' 96 | } 97 | 98 | rule typedef-callback { 99 | 'typedef' ? ? * '(' ~ ')' [* ] '(' ~ ')' ? ';' 100 | } 101 | rule typedef-struct { 102 | 'typedef' 'struct' ? ';' 103 | } 104 | rule typedef-struct-forward { 105 | 'typedef' 'struct' ';' 106 | } 107 | 108 | rule typedef-enum { 109 | 'typedef' 'enum' ? ';' 110 | } 111 | 112 | rule function { 113 | ? * '(' ~ ')' ? ';' 114 | } 115 | 116 | rule function-call { 117 | '(' ~ ')' 118 | } 119 | 120 | rule macro-identifier { 121 | | '__' 122 | | '__''__' 123 | | 124 | } 125 | 126 | 127 | rule macro-arguments { 128 | [',' ]* 129 | } 130 | 131 | rule macro-function { 132 | ['(' ~ ')' ?]? 133 | } 134 | 135 | rule parameters { 136 | | '...' 137 | | ? ? * ? [',' ]* 138 | } 139 | 140 | 141 | token identifier { 142 | [<:alpha> | '_'] \w* 143 | } 144 | 145 | token api-decl { 146 | 147 | } 148 | 149 | rule array-identifier { 150 | '[' ~ ']' 151 | } 152 | 153 | token index { 154 | 155 | } 156 | 157 | rule var-decl { 158 | * * [ | ] [',' [ | ]]* ';' 159 | } 160 | 161 | rule enum-var-decl { 162 | ['=' ]? ','? 163 | } 164 | 165 | token number { 166 | \d+ ['.' \d+? 'f']? 167 | } 168 | 169 | token hex-number { 170 | '0x' 171 | } 172 | 173 | token hex-digits { 174 | [ + ] 175 | } 176 | 177 | rule define-decl { 178 | '#define' [ | | | *]? ? 179 | } 180 | 181 | rule division { 182 | '/' 183 | } 184 | 185 | rule group { 186 | '(' ~ ')' [ | ] 187 | } 188 | 189 | token type { 190 | | 'struct' 191 | | 'enum' 192 | | 'void' 193 | | 'bool' 194 | | 'int' 195 | | 'float' 196 | | 'double' 197 | | 'char' 198 | | 'short' 199 | | 'va_list' 200 | | 201 | } 202 | 203 | token boolean { 204 | 'true' | '!'? 'false' 205 | } 206 | 207 | token value { 208 | | 209 | | 210 | | 211 | | 212 | | 213 | | 214 | | 215 | } 216 | 217 | rule string { 218 | '"' \N* '"' 219 | } 220 | 221 | token modifier { 222 | | 223 | | 224 | } 225 | 226 | token const { 227 | 'const' 228 | } 229 | 230 | token unsigned { 231 | 'unsigned' 232 | } 233 | 234 | 235 | token pointer { 236 | '*' 237 | } 238 | 239 | rule comment { 240 | | 241 | | 242 | 243 | } 244 | 245 | rule one-line-comment { 246 | '//' \N* \n? 247 | } 248 | 249 | rule block-comment { 250 | '/*' .*? '*/' 251 | } 252 | 253 | } 254 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | The Artistic License 2.0 2 | 3 | Copyright (c) 2000-2006, The Perl Foundation. 4 | 5 | Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. 6 | 7 | Preamble 8 | 9 | This license establishes the terms under which a given free software Package may be copied, modified, distributed, and/or redistributed. The intent is that the Copyright Holder maintains some artistic control over the development of that Package while still keeping the Package available as open source and free software. 10 | 11 | You are always permitted to make arrangements wholly outside of this license directly with the Copyright Holder of a given Package. If the terms of this license do not permit the full use that you propose to make of the Package, you should contact the Copyright Holder and seek a different licensing arrangement. 12 | 13 | Definitions 14 | 15 | "Copyright Holder" means the individual(s) or organization(s) named in the copyright notice for the entire Package. 16 | 17 | "Contributor" means any party that has contributed code or other material to the Package, in accordance with the Copyright Holder's procedures. 18 | 19 | "You" and "your" means any person who would like to copy, distribute, or modify the Package. 20 | 21 | "Package" means the collection of files distributed by the Copyright Holder, and derivatives of that collection and/or of those files. A given Package may consist of either the Standard Version, or a Modified Version. 22 | 23 | "Distribute" means providing a copy of the Package or making it accessible to anyone else, or in the case of a company or organization, to others outside of your company or organization. 24 | 25 | "Distributor Fee" means any fee that you charge for Distributing this Package or providing support for this Package to another party. It does not mean licensing fees. 26 | 27 | "Standard Version" refers to the Package if it has not been modified, or has been modified only in ways explicitly requested by the Copyright Holder. 28 | 29 | "Modified Version" means the Package, if it has been changed, and such changes were not explicitly requested by the Copyright Holder. 30 | 31 | "Original License" means this Artistic License as Distributed with the Standard Version of the Package, in its current version or as it may be modified by The Perl Foundation in the future. 32 | 33 | "Source" form means the source code, documentation source, and configuration files for the Package. 34 | 35 | "Compiled" form means the compiled bytecode, object code, binary, or any other form resulting from mechanical transformation or translation of the Source form. 36 | 37 | Permission for Use and Modification Without Distribution 38 | 39 | (1) You are permitted to use the Standard Version and create and use Modified Versions for any purpose without restriction, provided that you do not Distribute the Modified Version. 40 | 41 | Permissions for Redistribution of the Standard Version 42 | 43 | (2) You may Distribute verbatim copies of the Source form of the Standard Version of this Package in any medium without restriction, either gratis or for a Distributor Fee, provided that you duplicate all of the original copyright notices and associated disclaimers. At your discretion, such verbatim copies may or may not include a Compiled form of the Package. 44 | 45 | (3) You may apply any bug fixes, portability changes, and other modifications made available from the Copyright Holder. The resulting Package will still be considered the Standard Version, and as such will be subject to the Original License. 46 | 47 | Distribution of Modified Versions of the Package as Source 48 | 49 | (4) You may Distribute your Modified Version as Source (either gratis or for a Distributor Fee, and with or without a Compiled form of the Modified Version) provided that you clearly document how it differs from the Standard Version, including, but not limited to, documenting any non-standard features, executables, or modules, and provided that you do at least ONE of the following: 50 | 51 | (a) make the Modified Version available to the Copyright Holder of the Standard Version, under the Original License, so that the Copyright Holder may include your modifications in the Standard Version. 52 | (b) ensure that installation of your Modified Version does not prevent the user installing or running the Standard Version. In addition, the Modified Version must bear a name that is different from the name of the Standard Version. 53 | (c) allow anyone who receives a copy of the Modified Version to make the Source form of the Modified Version available to others under 54 | 55 | (i) the Original License or 56 | (ii) a license that permits the licensee to freely copy, modify and redistribute the Modified Version using the same licensing terms that apply to the copy that the licensee received, and requires that the Source form of the Modified Version, and of any works derived from it, be made freely available in that license fees are prohibited but Distributor Fees are allowed. 57 | 58 | Distribution of Compiled Forms of the Standard Version or Modified Versions without the Source 59 | 60 | (5) You may Distribute Compiled forms of the Standard Version without the Source, provided that you include complete instructions on how to get the Source of the Standard Version. Such instructions must be valid at the time of your distribution. If these instructions, at any time while you are carrying out such distribution, become invalid, you must provide new instructions on demand or cease further distribution. If you provide valid instructions or cease distribution within thirty days after you become aware that the instructions are invalid, then you do not forfeit any of your rights under this license. 61 | 62 | (6) You may Distribute a Modified Version in Compiled form without the Source, provided that you comply with Section 4 with respect to the Source of the Modified Version. 63 | 64 | Aggregating or Linking the Package 65 | 66 | (7) You may aggregate the Package (either the Standard Version or Modified Version) with other packages and Distribute the resulting aggregation provided that you do not charge a licensing fee for the Package. Distributor Fees are permitted, and licensing fees for other components in the aggregation are permitted. The terms of this license apply to the use and Distribution of the Standard or Modified Versions as included in the aggregation. 67 | 68 | (8) You are permitted to link Modified and Standard Versions with other works, to embed the Package in a larger work of your own, or to build stand-alone binary or bytecode versions of applications that include the Package, and Distribute the result without restriction, provided the result does not expose a direct interface to the Package. 69 | 70 | Items That are Not Considered Part of a Modified Version 71 | 72 | (9) Works (including, but not limited to, modules and scripts) that merely extend or make use of the Package, do not, by themselves, cause the Package to be a Modified Version. In addition, such works are not considered parts of the Package itself, and are not subject to the terms of this license. 73 | 74 | General Provisions 75 | 76 | (10) Any use, modification, and distribution of the Standard or Modified Versions is governed by this Artistic License. By using, modifying or distributing the Package, you accept this license. Do not use, modify, or distribute the Package, if you do not accept this license. 77 | 78 | (11) If your Modified Version has been derived from a Modified Version made by someone other than you, you are nevertheless required to ensure that your Modified Version complies with the requirements of this license. 79 | 80 | (12) This license does not grant you the right to use any trademark, service mark, tradename, or logo of the Copyright Holder. 81 | 82 | (13) This license includes the non-exclusive, worldwide, free-of-charge patent license to make, have made, use, offer to sell, sell, import and otherwise transfer the Package with respect to any patent claims licensable by the Copyright Holder that are necessarily infringed by the Package. If you institute patent litigation (including a cross-claim or counterclaim) against any party alleging that the Package constitutes direct or contributory patent infringement, then this Artistic License to you shall terminate on the date that such litigation is filed. 83 | 84 | (14) Disclaimer of Warranty: 85 | THE PACKAGE IS PROVIDED BY THE COPYRIGHT HOLDER AND CONTRIBUTORS "AS IS" AND WITHOUT ANY EXPRESS OR IMPLIED WARRANTIES. THE IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE, OR NON-INFRINGEMENT ARE DISCLAIMED TO THE EXTENT PERMITTED BY YOUR LOCAL LAW. UNLESS REQUIRED BY LAW, NO COPYRIGHT HOLDER OR CONTRIBUTOR WILL BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, OR CONSEQUENTIAL DAMAGES ARISING IN ANY WAY OUT OF THE USE OF THE PACKAGE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. -------------------------------------------------------------------------------- /t/03-generate-bindings.rakutest: -------------------------------------------------------------------------------- 1 | use Test; 2 | 3 | use lib 'lib'; 4 | 5 | use Raylib::Grammar; 6 | use Raylib::Actions; 7 | 8 | my $code = q:to/END/; 9 | // Vector2, 2 components 10 | typedef struct Vector2 { 11 | float x; // Vector x component 12 | float y; // Vector y component 13 | } Vector2; 14 | 15 | // Vector3, 3 components 16 | typedef struct Vector3 { 17 | float x; // Vector x component 18 | float y; // Vector y component 19 | float z; // Vector z component 20 | } Vector3; 21 | 22 | // Vector4, 4 components 23 | typedef struct Vector4 { 24 | float x; // Vector x component 25 | float y; // Vector y component 26 | float z; // Vector z component 27 | float w; // Vector w component 28 | } Vector4; 29 | 30 | // Quaternion, 4 components (Vector4 alias) 31 | typedef Vector4 Quaternion; 32 | 33 | // Matrix, 4x4 components, column major, OpenGL style, right-handed 34 | typedef struct Matrix { 35 | float m0, m4, m8, m12; // Matrix first row (4 components) 36 | float m1, m5, m9, m13; // Matrix second row (4 components) 37 | float m2, m6, m10, m14; // Matrix third row (4 components) 38 | float m3, m7, m11, m15; // Matrix fourth row (4 components) 39 | } Matrix; 40 | 41 | // Color, 4 components, R8G8B8A8 (32bit) 42 | typedef struct Color { 43 | unsigned char r; // Color red value 44 | unsigned char g; // Color green value 45 | unsigned char b; // Color blue value 46 | unsigned char a; // Color alpha value 47 | } Color; 48 | 49 | // Rectangle, 4 components 50 | typedef struct Rectangle { 51 | float x; // Rectangle top-left corner position x 52 | float y; // Rectangle top-left corner position y 53 | float width; // Rectangle width 54 | float height; // Rectangle height 55 | } Rectangle; 56 | 57 | typedef struct rAudioBuffer rAudioBuffer; 58 | typedef struct rAudioProcessor rAudioProcessor; 59 | 60 | // AudioStream, custom audio stream 61 | typedef struct AudioStream { 62 | rAudioBuffer *buffer; // Pointer to internal data used by the audio system 63 | rAudioProcessor *processor; // Pointer to internal data processor, useful for audio effects 64 | 65 | unsigned int sampleRate; // Frequency (samples per second) 66 | unsigned int sampleSize; // Bit depth (bits per sample): 8, 16, 32 (24 not supported) 67 | unsigned int channels; // Number of channels (1-mono, 2-stereo, ...) 68 | } AudioStream; 69 | 70 | typedef void (*AudioCallback)(void *bufferData, unsigned int frames); 71 | typedef void (*TraceLogCallback)(int logLevel, const char *text, va_list args); // Logging: Redirect trace log messages 72 | typedef unsigned char *(*LoadFileDataCallback)(const char *fileName, unsigned int *bytesRead); // FileIO: Load binary data 73 | typedef bool (*SaveFileDataCallback)(const char *fileName, void *data, unsigned int bytesToWrite); // FileIO: Save binary data 74 | typedef char *(*LoadFileTextCallback)(const char *fileName); // FileIO: Load text data 75 | typedef bool (*SaveFileTextCallback)(const char *fileName, char *text); // FileIO: Save text data 76 | 77 | 78 | // Window-related functions 79 | RLAPI void InitWindow(int width, int height, const char *title); // Initialize window and OpenGL context 80 | RLAPI bool WindowShouldClose(void); // Check if KEY_ESCAPE pressed or Close icon pressed 81 | RLAPI void CloseWindow(void); // Close window and unload OpenGL context 82 | RLAPI bool IsWindowReady(void); // Check if window has been initialized successfully 83 | RLAPI bool IsWindowFullscreen(void); // Check if window is currently fullscreen 84 | RLAPI bool IsWindowHidden(void); // Check if window is currently hidden (only PLATFORM_DESKTOP) 85 | RLAPI bool IsWindowMinimized(void); // Check if window is currently minimized (only PLATFORM_DESKTOP) 86 | RLAPI bool IsWindowMaximized(void); // Check if window is currently maximized (only PLATFORM_DESKTOP) 87 | RLAPI bool IsWindowFocused(void); // Check if window is currently focused (only PLATFORM_DESKTOP) 88 | RLAPI bool IsWindowResized(void); // Check if window has been resized last frame 89 | RLAPI bool IsWindowState(unsigned int flag); // Check if one specific window flag is enabled 90 | RLAPI void SetWindowState(unsigned int flags); // Set window configuration state using flags (only PLATFORM_DESKTOP) 91 | RLAPI void ClearWindowState(unsigned int flags); // Clear window configuration state flags 92 | RLAPI void ToggleFullscreen(void); // Toggle window state: fullscreen/windowed (only PLATFORM_DESKTOP) 93 | RLAPI void ToggleBorderlessWindowed(void); // Toggle window state: borderless windowed (only PLATFORM_DESKTOP) 94 | RLAPI void MaximizeWindow(void); // Set window state: maximized, if resizable (only PLATFORM_DESKTOP) 95 | RLAPI void MinimizeWindow(void); // Set window state: minimized, if resizable (only PLATFORM_DESKTOP) 96 | RLAPI void RestoreWindow(void); // Set window state: not minimized/maximized (only PLATFORM_DESKTOP) 97 | RLAPI void SetWindowIcon(Image image); // Set icon for window (single image, RGBA 32bit, only PLATFORM_DESKTOP) 98 | RLAPI void SetWindowIcons(Image *images, int count); // Set icon for window (multiple images, RGBA 32bit, only PLATFORM_DESKTOP) 99 | RLAPI void SetWindowTitle(const char *title); // Set title for window (only PLATFORM_DESKTOP and PLATFORM_WEB) 100 | RLAPI void SetWindowPosition(int x, int y); // Set window position on screen (only PLATFORM_DESKTOP) 101 | RLAPI void SetWindowMonitor(int monitor); // Set monitor for the current window 102 | RLAPI void SetWindowMinSize(int width, int height); // Set window minimum dimensions (for FLAG_WINDOW_RESIZABLE) 103 | RLAPI void SetWindowSize(int width, int height); // Set window dimensions 104 | RLAPI void SetWindowOpacity(float opacity); // Set window opacity [0.0f..1.0f] (only PLATFORM_DESKTOP) 105 | RLAPI void SetWindowFocused(void); // Set window focused (only PLATFORM_DESKTOP) 106 | RLAPI void *GetWindowHandle(void); // Get native window handle 107 | RLAPI int GetScreenWidth(void); // Get current screen width 108 | RLAPI int GetScreenHeight(void); // Get current screen height 109 | RLAPI int GetRenderWidth(void); // Get current render width (it considers HiDPI) 110 | RLAPI int GetRenderHeight(void); // Get current render height (it considers HiDPI) 111 | RLAPI int GetMonitorCount(void); // Get number of connected monitors 112 | RLAPI int GetCurrentMonitor(void); // Get current connected monitor 113 | RLAPI Vector2 GetMonitorPosition(int monitor); // Get specified monitor position 114 | RLAPI int GetMonitorWidth(int monitor); // Get specified monitor width (current video mode used by monitor) 115 | RLAPI int GetMonitorHeight(int monitor); // Get specified monitor height (current video mode used by monitor) 116 | RLAPI int GetMonitorPhysicalWidth(int monitor); // Get specified monitor physical width in millimetres 117 | RLAPI int GetMonitorPhysicalHeight(int monitor); // Get specified monitor physical height in millimetres 118 | RLAPI int GetMonitorRefreshRate(int monitor); // Get specified monitor refresh rate 119 | RLAPI Vector2 GetWindowPosition(void); // Get window position XY on monitor 120 | RLAPI Vector2 GetWindowScaleDPI(void); // Get window scale DPI factor 121 | RLAPI const char *GetMonitorName(int monitor); // Get the human-readable, UTF-8 encoded name of the specified monitor 122 | RLAPI void SetClipboardText(const char *text); // Set clipboard text content 123 | RLAPI const char *GetClipboardText(void); // Get clipboard text content 124 | RLAPI void EnableEventWaiting(void); // Enable waiting for events on EndDrawing(), no automatic event polling 125 | RLAPI void DisableEventWaiting(void); // Disable waiting for events on EndDrawing(), automatic events polling 126 | RLAPI void SetAudioStreamCallback(AudioStream stream, AudioCallback callback); // Audio thread callback to request new data 127 | RLAPI void SetTraceLogCallback(TraceLogCallback callback); // Set custom trace log 128 | RLAPI void SetLoadFileDataCallback(LoadFileDataCallback callback); // Set custom file binary data loader 129 | RLAPI void SetSaveFileDataCallback(SaveFileDataCallback callback); // Set custom file binary data saver 130 | RLAPI void SetLoadFileTextCallback(LoadFileTextCallback callback); // Set custom file text data loader 131 | RLAPI void SetSaveFileTextCallback(SaveFileTextCallback callback); // Set custom file text data saver 132 | 133 | 134 | END 135 | 136 | my $parser = RaylibGrammar.new; 137 | my $actions = RaylibActions.new; 138 | 139 | $parser.parse($code, actions => $actions); 140 | 141 | # my $code2 = q:to/END/; 142 | # typedef void (*TraceLogCallback)(int logLevel, const char *text, va_list args); // Logging: Redirect trace log messages 143 | # typedef char *(*LoadFileTextCallback)(const char *fileName); // FileIO: Load text data 144 | # typedef bool (*SaveFileTextCallback)(const char *fileName, char *text, int ffff, const char* hello); // FileIO: Save text data 145 | # RLAPI void SetAudioStreamCallback(AudioStream stream, AudioCallback callback); // Audio thread callback to request new data 146 | # END 147 | 148 | # my $parsed = $parser.parse($code2, actions => $actions); 149 | 150 | # # say "use NativeCall;"; 151 | say "constant LIBRAYLIB = '/usr/local/lib/libraylib.so';"; 152 | for $actions.bindings -> $binding { 153 | say $binding; 154 | } 155 | for $actions.pointerized_bindings -> $binding { 156 | say $binding; 157 | } 158 | for $actions.c_pointerize_bindings -> $binding { 159 | say $binding; 160 | } 161 | 162 | ok True; 163 | done-testing; 164 | -------------------------------------------------------------------------------- /t/00-use.rakutest: -------------------------------------------------------------------------------- 1 | use Test; 2 | 3 | use lib 'lib'; 4 | 5 | use Raylib::Grammar; 6 | plan 16; 7 | 8 | my $parser = RaylibGrammar.new; 9 | 10 | my $code = q:to/END/; 11 | typedef struct VrStereoConfig { 12 | Matrix projection[2]; // VR projection matrices (per eye) 13 | Matrix viewOffset[2]; // VR view offset matrices (per eye) 14 | float leftLensCenter[2]; // VR left lens center 15 | float rightLensCenter[2]; // VR right lens center 16 | float leftScreenCenter[2]; // VR left screen center 17 | float rightScreenCenter[2]; // VR right screen center 18 | float scale[2]; // VR distortion scale 19 | float scaleIn[2]; // VR distortion scale in 20 | } VrStereoConfig; 21 | 22 | typedef struct RayCollision { 23 | bool hit; // Did the ray hit something? 24 | float distance; // Distance to the nearest hit 25 | Vector3 point; // Point of the nearest hit 26 | Vector3 normal; // Surface normal of hit 27 | } RayCollision; 28 | 29 | typedef struct Matrix { 30 | float m0, m4, m8, m12; // Matrix first row (4 components) 31 | float m1, m5, m9, m13; // Matrix second row (4 components) 32 | float m2, m6, m10, m14; // Matrix third row (4 components) 33 | float m3, m7, m11, m15; // Matrix fourth row (4 components) 34 | } Matrix; 35 | 36 | typedef struct Mesh { 37 | int vertexCount; // Number of vertices stored in arrays 38 | int triangleCount; // Number of triangles stored (indexed or not) 39 | 40 | // Vertex attributes data 41 | float *vertices; // Vertex position (XYZ - 3 components per vertex) (shader-location = 0) 42 | float *texcoords; // Vertex texture coordinates (UV - 2 components per vertex) (shader-location = 1) 43 | float *texcoords2; // Vertex texture second coordinates (UV - 2 components per vertex) (shader-location = 5) 44 | float *normals; // Vertex normals (XYZ - 3 components per vertex) (shader-location = 2) 45 | float *tangents; // Vertex tangents (XYZW - 4 components per vertex) (shader-location = 4) 46 | unsigned char *colors; // Vertex colors (RGBA - 4 components per vertex) (shader-location = 3) 47 | unsigned short *indices; // Vertex indices (in case vertex data comes indexed) 48 | 49 | float *animVertices; // Animated vertex positions (after bones transformations) 50 | float *animNormals; // Animated normals (after bones transformations) 51 | unsigned char *boneIds; // Vertex bone ids, max 255 bone ids, up to 4 bones influence by vertex (skinning) 52 | float *boneWeights; // Vertex bone weight, up to 4 bones influence by vertex (skinning) 53 | 54 | unsigned int vaoId; // OpenGL Vertex Array Object id 55 | unsigned int *vboId; // OpenGL Vertex Buffer Objects id (default vertex data) 56 | } Mesh; 57 | 58 | END 59 | 60 | ok $parser.parse($code), 'Parsing typedef-struct'; 61 | 62 | $code = q:to/END/; 63 | //Some comment 64 | RLAPI Music LoadMusicStream(const char *fileName); // Load music stream from file 65 | RLAPI Music LoadMusicStreamFromMemory(const char *fileType, const unsigned char *data, int dataSize); // Load music stream from data 66 | RLAPI bool WindowShouldClose(void); // Check if KEY_ESCAPE pressed or Close icon pressed 67 | RLAPI void CloseWindow(void); // Close window and unload OpenGL context 68 | RLAPI bool IsWindowReady(void); // Check if window has been initialized successfully 69 | END 70 | 71 | ok $parser.parse($code), 'Parsing function rule'; 72 | 73 | $code = q:to/END/; 74 | /******** 75 | Hello world 76 | *********/ 77 | // one-line-comment 78 | END 79 | 80 | ok $parser.parse($code), 'Parsing comment rule'; 81 | 82 | 83 | $code = q:to/END/; 84 | //sfdsadfa 85 | typedef enum { 86 | TEXTURE_FILTER_POINT = 0, 87 | TEXTURE_FILTER_BILINEAR, 88 | TEXTURE_FILTER_TRILINEAR, 89 | TEXTURE_FILTER_ANISOTROPIC_4X, 90 | TEXTURE_FILTER_ANISOTROPIC_8X, 91 | TEXTURE_FILTER_ANISOTROPIC_16X, 92 | } TextureFilter; 93 | 94 | typedef enum { 95 | FLAG_VSYNC_HINT = 0x00000040, // Set to try enabling V-Sync on GPU 96 | FLAG_FULLSCREEN_MODE = 0x00000002, // Set to run program in fullscreen 97 | FLAG_WINDOW_RESIZABLE = 0x00000004, // Set to allow resizable window 98 | FLAG_WINDOW_UNDECORATED = 0x00000008, // Set to disable window decoration (frame and buttons) 99 | FLAG_WINDOW_HIDDEN = 0x00000080, // Set to hide window 100 | FLAG_WINDOW_MINIMIZED = 0x00000200, // Set to minimize window (iconify) 101 | FLAG_WINDOW_MAXIMIZED = 0x00000400, // Set to maximize window (expanded to monitor) 102 | FLAG_WINDOW_UNFOCUSED = 0x00000800, // Set to window non focused 103 | FLAG_WINDOW_TOPMOST = 0x00001000, // Set to window always on top 104 | FLAG_WINDOW_ALWAYS_RUN = 0x00000100, // Set to allow windows running while minimized 105 | FLAG_WINDOW_TRANSPARENT = 0x00000010, // Set to allow transparent framebuffer 106 | FLAG_WINDOW_HIGHDPI = 0x00002000, // Set to support HighDPI 107 | FLAG_WINDOW_MOUSE_PASSTHROUGH = 0x00004000, // Set to support mouse passthrough, only supported when FLAG_WINDOW_UNDECORATED 108 | FLAG_BORDERLESS_WINDOWED_MODE = 0x00008000, // Set to run program in borderless windowed mode 109 | FLAG_MSAA_4X_HINT = 0x00000020, // Set to try enabling MSAA 4X 110 | FLAG_INTERLACED_HINT = 0x00010000 // Set to try enabling interlaced video format (for V3D) 111 | } ConfigFlags; 112 | END 113 | 114 | ok $parser.parse($code), 'Parsing typedef enum rule'; 115 | 116 | 117 | $code = q:to/END/; 118 | // Callbacks to hook some internal functions 119 | // WARNING: These callbacks are intended for advance users 120 | typedef void (*TraceLogCallback)(int logLevel, const char *text, va_list args); // Logging: Redirect trace log messages 121 | typedef unsigned char *(*LoadFileDataCallback)(const char *fileName, unsigned int *bytesRead); // FileIO: Load binary data 122 | typedef bool (*SaveFileDataCallback)(const char *fileName, void *data, unsigned int bytesToWrite); // FileIO: Save binary data 123 | typedef char *(*LoadFileTextCallback)(const char *fileName); // FileIO: Load text data 124 | typedef bool (*SaveFileTextCallback)(const char *fileName, char *text); // FileIO: Save text data 125 | typedef void (*AudioCallback)(void *bufferData, unsigned int frames); 126 | END 127 | 128 | ok $parser.parse($code), 'Parsing typedef-callback rule'; 129 | 130 | 131 | $code = q:to/END/; 132 | #ifndef RAYLIB_H 133 | #define RAYLIB_H 134 | #define RAYLIB_VERSION_MAJOR 4 135 | #define RAYLIB_VERSION_MINOR 6 136 | #define RAYLIB_VERSION_PATCH 0 137 | #define RAYLIB_VERSION "4.6-dev" 138 | 139 | #define RL_COLOR_TYPE 140 | #define RL_COLOR_TYPE 141 | #define RL_RECTANGLE_TYPE 142 | #define RL_VECTOR2_TYPE 143 | #define RL_VECTOR3_TYPE 144 | #define RL_VECTOR4_TYPE 145 | #define RL_QUATERNION_TYPE 146 | #define RL_MATRIX_TYPE 147 | 148 | #define WHITE CLITERAL(Color){ 255, 255, 255, 255 } // White 149 | #define BLACK CLITERAL(Color){ 0, 0, 0, 255 } // Black 150 | #define BLANK CLITERAL(Color){ 0, 0, 0, 0 } // Blank (Transparent) 151 | #define MAGENTA CLITERAL(Color){ 255, 0, 255, 255 } // Magenta 152 | #define RAYWHITE CLITERAL(Color){ 245, 245, 245, 255 } // My own White (raylib logo) 153 | #ifndef RAD2DEG 154 | #define RAD2DEG (180.0f/PI) 155 | #endif 156 | #endif //RAYLIB_H 157 | 158 | END 159 | 160 | ok $parser.parse($code), 'Parsing define macro rule'; 161 | 162 | $code = q:to/END/; 163 | #ifndef RAD2DEG 164 | #define RAD2DEG (180.0f/PI) 165 | #endif 166 | END 167 | 168 | ok $parser.parse($code), 'Parsing define macro with group'; 169 | 170 | $code = q:to/END/; 171 | #if defined(_WIN32) 172 | #endif 173 | 174 | #define RLAPI __declspec(dllexport) // We are building the library as a Win32 shared library (.dll) 175 | 176 | END 177 | ok $parser.parse($code), 'Parsing ignore rule'; 178 | 179 | $code = q:to/END/; 180 | #include 181 | END 182 | ok $parser.parse($code), 'Parsing ignore include rule'; 183 | 184 | $code = q:to/END/; 185 | #ifndef EPSILON 186 | #define EPSILON 0.000001f 187 | #endif 188 | 189 | END 190 | ok $parser.parse($code), 'Parsing ifndef-block rule'; 191 | 192 | $code = q:to/END/; 193 | // Function specifiers definition 194 | #if defined(RAYMATH_IMPLEMENTATION) 195 | #if defined(_WIN32) && defined(BUILD_LIBTYPE_SHARED) 196 | #define RMAPI __declspec(dllexport) extern inline // We are building raylib as a Win32 shared library (.dll). 197 | #elif defined(_WIN32) && defined(USE_LIBTYPE_SHARED) 198 | #define RMAPI __declspec(dllimport) // We are using raylib as a Win32 shared library (.dll) 199 | #else 200 | #define RMAPI extern inline // Provide external definition 201 | #endif 202 | #elif defined(RAYMATH_STATIC_INLINE) 203 | #define RMAPI static inline // Functions may be inlined, no external out-of-line definition 204 | #else 205 | #if defined(__TINYC__) 206 | #define RMAPI static inline // plain inline not supported by tinycc (See issue #435) 207 | #else 208 | #define RMAPI inline // Functions may be inlined or external definition used 209 | #endif 210 | #endif 211 | 212 | 213 | // Function specifiers in case library is build/used as a shared library (Windows) 214 | // NOTE: Microsoft specifiers to tell compiler that symbols are imported/exported from a .dll 215 | #if defined(_WIN32) 216 | #if defined(BUILD_LIBTYPE_SHARED) 217 | #if defined(__TINYC__) 218 | #define __declspec(x) __attribute__((x)) 219 | #endif 220 | #define RLAPI __declspec(dllexport) // We are building the library as a Win32 shared library (.dll) 221 | #elif defined(USE_LIBTYPE_SHARED) 222 | #define RLAPI __declspec(dllimport) // We are using the library as a Win32 shared library (.dll) 223 | #endif 224 | #endif 225 | 226 | 227 | END 228 | ok $parser.parse($code), 'Parsing ifndef-block rule'; 229 | 230 | $code = q:to/END/; 231 | #define RL_MALLOC(sz) malloc(sz) 232 | #define __declspec(x) __attribute__((x)) 233 | #define RL_REALLOC(ptr,sz) 234 | 235 | END 236 | ok $parser.parse($code), 'Parsing define rule 2'; 237 | $code = q:to/END/; 238 | #ifndef RL_MALLOC 239 | #define RL_REALLOC(ptr,sz) 240 | #endif 241 | #ifndef RL_CALLOC 242 | #endif 243 | #ifndef RL_REALLOC 244 | #define RL_REALLOC(ptr,sz) realloc(ptr,sz) 245 | #endif 246 | #ifndef RL_FREE 247 | #define RL_FREE(ptr) free(ptr) 248 | #endif 249 | 250 | #ifndef RLAPI 251 | #define RLAPI // Functions defined as 'extern' by default (implicit specifiers) 252 | #endif 253 | 254 | #if defined(__cplusplus) 255 | #define CLITERAL(type) type 256 | #else 257 | #define CLITERAL(type) (type) 258 | #endif 259 | END 260 | $code = q:to/END/; 261 | typedef enum bool { false = 0, true = !false } bool; 262 | END 263 | 264 | ok $parser.parse($code), 'Parsing define rule 4'; 265 | 266 | $code = q:to/END/; 267 | #ifndef PI 268 | #define PI 3.14159265358979323846f 269 | #endif 270 | #ifndef DEG2RAD 271 | #define DEG2RAD (PI/180.0f) 272 | #endif 273 | #ifndef RAD2DEG 274 | #define RAD2DEG (180.0f/PI) 275 | #endif 276 | 277 | // Allow custom memory allocators 278 | // NOTE: Require recompiling raylib sources 279 | #ifndef RL_MALLOC 280 | #define RL_MALLOC(sz) malloc(sz) 281 | #endif 282 | #ifndef RL_CALLOC 283 | #define RL_CALLOC(n,sz) calloc(n,sz) 284 | #endif 285 | #ifndef RL_REALLOC 286 | #define RL_REALLOC(ptr,sz) realloc(ptr,sz) 287 | #endif 288 | #ifndef RL_FREE 289 | #define RL_FREE(ptr) free(ptr) 290 | #endif 291 | 292 | // NOTE: MSVC C++ compiler does not support compound literals (C99 feature) 293 | // Plain structures in C++ (without constructors) can be initialized with { } 294 | // This is called aggregate initialization (C++11 feature) 295 | #if defined(__cplusplus) 296 | #define CLITERAL(type) type 297 | #else 298 | #define CLITERAL(type) (type) 299 | #endif 300 | 301 | // Some compilers (mostly macos clang) default to C++98, 302 | // where aggregate initialization can't be used 303 | // So, give a more clear error stating how to fix this 304 | 305 | extern "C" { // Prevents name mangling of functions 306 | END 307 | 308 | ok $parser.parse($code), 'Parsing multiple rule '; 309 | 310 | $code = q:to/END/; 311 | #if defined(__cplusplus) 312 | extern "C" { // Prevents name mangling of functions 313 | #endif 314 | END 315 | 316 | ok $parser.parse($code), 'Parsing extern rule '; 317 | 318 | $code = q:to/END/; 319 | typedef Vector4 Quaternion; 320 | END 321 | 322 | ok $parser.parse($code), 'Parsing typedef-alias rule '; 323 | 324 | 325 | done-testing; 326 | -------------------------------------------------------------------------------- /resources/raylib_allocations.c: -------------------------------------------------------------------------------- 1 | // This file is generated by raylib-raku 2 | #include 3 | #include 4 | #include 5 | Vector2* malloc_Vector2(float x, float y) { 6 | Vector2* ptr = malloc(sizeof(Vector2)); 7 | ptr->x = x; 8 | ptr->y = y; 9 | return ptr; 10 | } 11 | void free_Vector2(Vector2* ptr){ 12 | free(ptr); 13 | } 14 | Vector3* malloc_Vector3(float x, float y, float z) { 15 | Vector3* ptr = malloc(sizeof(Vector3)); 16 | ptr->x = x; 17 | ptr->y = y; 18 | ptr->z = z; 19 | return ptr; 20 | } 21 | void free_Vector3(Vector3* ptr){ 22 | free(ptr); 23 | } 24 | Vector4* malloc_Vector4(float x, float y, float z, float w) { 25 | Vector4* ptr = malloc(sizeof(Vector4)); 26 | ptr->x = x; 27 | ptr->y = y; 28 | ptr->z = z; 29 | ptr->w = w; 30 | return ptr; 31 | } 32 | void free_Vector4(Vector4* ptr){ 33 | free(ptr); 34 | } 35 | Matrix* malloc_Matrix(float m0, float m4, float m8, float m12, float m1, float m5, float m9, float m13, float m2, float m6, float m10, float m14, float m3, float m7, float m11, float m15) { 36 | Matrix* ptr = malloc(sizeof(Matrix)); 37 | ptr->m0 = m0; 38 | ptr->m4 = m4; 39 | ptr->m8 = m8; 40 | ptr->m12 = m12; 41 | ptr->m1 = m1; 42 | ptr->m5 = m5; 43 | ptr->m9 = m9; 44 | ptr->m13 = m13; 45 | ptr->m2 = m2; 46 | ptr->m6 = m6; 47 | ptr->m10 = m10; 48 | ptr->m14 = m14; 49 | ptr->m3 = m3; 50 | ptr->m7 = m7; 51 | ptr->m11 = m11; 52 | ptr->m15 = m15; 53 | return ptr; 54 | } 55 | void free_Matrix(Matrix* ptr){ 56 | free(ptr); 57 | } 58 | Color* malloc_Color(unsigned char r,unsigned char g,unsigned char b,unsigned char a) { 59 | Color* ptr = malloc(sizeof(Color)); 60 | ptr->r = r; 61 | ptr->g = g; 62 | ptr->b = b; 63 | ptr->a = a; 64 | return ptr; 65 | } 66 | void free_Color(Color* ptr){ 67 | free(ptr); 68 | } 69 | Rectangle* malloc_Rectangle(float x, float y, float width, float height) { 70 | Rectangle* ptr = malloc(sizeof(Rectangle)); 71 | ptr->x = x; 72 | ptr->y = y; 73 | ptr->width = width; 74 | ptr->height = height; 75 | return ptr; 76 | } 77 | void free_Rectangle(Rectangle* ptr){ 78 | free(ptr); 79 | } 80 | Image* malloc_Image(void * data, int width, int height, int mipmaps, int format) { 81 | Image* ptr = malloc(sizeof(Image)); 82 | ptr->data = data; 83 | ptr->width = width; 84 | ptr->height = height; 85 | ptr->mipmaps = mipmaps; 86 | ptr->format = format; 87 | return ptr; 88 | } 89 | void free_Image(Image* ptr){ 90 | free(ptr); 91 | } 92 | Texture* malloc_Texture(unsigned int id, int width, int height, int mipmaps, int format) { 93 | Texture* ptr = malloc(sizeof(Texture)); 94 | ptr->id = id; 95 | ptr->width = width; 96 | ptr->height = height; 97 | ptr->mipmaps = mipmaps; 98 | ptr->format = format; 99 | return ptr; 100 | } 101 | void free_Texture(Texture* ptr){ 102 | free(ptr); 103 | } 104 | RenderTexture* malloc_RenderTexture(unsigned int id, Texture * texture, Texture * depth) { 105 | RenderTexture* ptr = malloc(sizeof(RenderTexture)); 106 | ptr->id = id; 107 | ptr->texture = *texture; 108 | ptr->depth = *depth; 109 | return ptr; 110 | } 111 | void free_RenderTexture(RenderTexture* ptr){ 112 | free(ptr); 113 | } 114 | NPatchInfo* malloc_NPatchInfo(Rectangle * source, int left, int top, int right, int bottom, int layout) { 115 | NPatchInfo* ptr = malloc(sizeof(NPatchInfo)); 116 | ptr->source = *source; 117 | ptr->left = left; 118 | ptr->top = top; 119 | ptr->right = right; 120 | ptr->bottom = bottom; 121 | ptr->layout = layout; 122 | return ptr; 123 | } 124 | void free_NPatchInfo(NPatchInfo* ptr){ 125 | free(ptr); 126 | } 127 | GlyphInfo* malloc_GlyphInfo(int value, int offsetX, int offsetY, int advanceX, Image * image) { 128 | GlyphInfo* ptr = malloc(sizeof(GlyphInfo)); 129 | ptr->value = value; 130 | ptr->offsetX = offsetX; 131 | ptr->offsetY = offsetY; 132 | ptr->advanceX = advanceX; 133 | ptr->image = *image; 134 | return ptr; 135 | } 136 | void free_GlyphInfo(GlyphInfo* ptr){ 137 | free(ptr); 138 | } 139 | Font* malloc_Font(int baseSize, int glyphCount, int glyphPadding, Texture2D * texture, Rectangle * recs, GlyphInfo * glyphs) { 140 | Font* ptr = malloc(sizeof(Font)); 141 | ptr->baseSize = baseSize; 142 | ptr->glyphCount = glyphCount; 143 | ptr->glyphPadding = glyphPadding; 144 | ptr->texture = *texture; 145 | ptr->recs = recs; 146 | ptr->glyphs = glyphs; 147 | return ptr; 148 | } 149 | void free_Font(Font* ptr){ 150 | free(ptr); 151 | } 152 | Camera3D* malloc_Camera3D(Vector3 * position, Vector3 * target, Vector3 * up, float fovy, int projection) { 153 | Camera3D* ptr = malloc(sizeof(Camera3D)); 154 | ptr->position = *position; 155 | ptr->target = *target; 156 | ptr->up = *up; 157 | ptr->fovy = fovy; 158 | ptr->projection = projection; 159 | return ptr; 160 | } 161 | void free_Camera3D(Camera3D* ptr){ 162 | free(ptr); 163 | } 164 | Camera2D* malloc_Camera2D(Vector2 * offset, Vector2 * target, float rotation, float zoom) { 165 | Camera2D* ptr = malloc(sizeof(Camera2D)); 166 | ptr->offset = *offset; 167 | ptr->target = *target; 168 | ptr->rotation = rotation; 169 | ptr->zoom = zoom; 170 | return ptr; 171 | } 172 | void free_Camera2D(Camera2D* ptr){ 173 | free(ptr); 174 | } 175 | Mesh* malloc_Mesh(int vertexCount, int triangleCount, float * vertices, float * texcoords, float * texcoords2, float * normals, float * tangents,unsigned char * colors,unsigned short * indices, float * animVertices, float * animNormals,unsigned char * boneIds, float * boneWeights, Matrix * boneMatrices, int boneCount,unsigned int vaoId,unsigned int * vboId) { 176 | Mesh* ptr = malloc(sizeof(Mesh)); 177 | ptr->vertexCount = vertexCount; 178 | ptr->triangleCount = triangleCount; 179 | ptr->vertices = vertices; 180 | ptr->texcoords = texcoords; 181 | ptr->texcoords2 = texcoords2; 182 | ptr->normals = normals; 183 | ptr->tangents = tangents; 184 | ptr->colors = colors; 185 | ptr->indices = indices; 186 | ptr->animVertices = animVertices; 187 | ptr->animNormals = animNormals; 188 | ptr->boneIds = boneIds; 189 | ptr->boneWeights = boneWeights; 190 | ptr->boneMatrices = boneMatrices; 191 | ptr->boneCount = boneCount; 192 | ptr->vaoId = vaoId; 193 | ptr->vboId = vboId; 194 | return ptr; 195 | } 196 | void free_Mesh(Mesh* ptr){ 197 | free(ptr); 198 | } 199 | Shader* malloc_Shader(unsigned int id, int * locs) { 200 | Shader* ptr = malloc(sizeof(Shader)); 201 | ptr->id = id; 202 | ptr->locs = locs; 203 | return ptr; 204 | } 205 | void free_Shader(Shader* ptr){ 206 | free(ptr); 207 | } 208 | MaterialMap* malloc_MaterialMap(Texture2D * texture, Color * color, float value) { 209 | MaterialMap* ptr = malloc(sizeof(MaterialMap)); 210 | ptr->texture = *texture; 211 | ptr->color = *color; 212 | ptr->value = value; 213 | return ptr; 214 | } 215 | void free_MaterialMap(MaterialMap* ptr){ 216 | free(ptr); 217 | } 218 | Material* malloc_Material(Shader * shader, MaterialMap * maps, float params[4]) { 219 | Material* ptr = malloc(sizeof(Material)); 220 | ptr->shader = *shader; 221 | ptr->maps = maps; 222 | memcpy(ptr->params, params, 4 * sizeof(float)); 223 | return ptr; 224 | } 225 | void free_Material(Material* ptr){ 226 | free(ptr); 227 | } 228 | Transform* malloc_Transform(Vector3 * translation, Quaternion * rotation, Vector3 * scale) { 229 | Transform* ptr = malloc(sizeof(Transform)); 230 | ptr->translation = *translation; 231 | ptr->rotation = *rotation; 232 | ptr->scale = *scale; 233 | return ptr; 234 | } 235 | void free_Transform(Transform* ptr){ 236 | free(ptr); 237 | } 238 | BoneInfo* malloc_BoneInfo(char name[32], int parent) { 239 | BoneInfo* ptr = malloc(sizeof(BoneInfo)); 240 | memcpy(ptr->name, name, 32 * sizeof(char)); 241 | ptr->parent = parent; 242 | return ptr; 243 | } 244 | void free_BoneInfo(BoneInfo* ptr){ 245 | free(ptr); 246 | } 247 | Model* malloc_Model(Matrix * transform, int meshCount, int materialCount, Mesh * meshes, Material * materials, int * meshMaterial, int boneCount, BoneInfo * bones, Transform * bindPose) { 248 | Model* ptr = malloc(sizeof(Model)); 249 | ptr->transform = *transform; 250 | ptr->meshCount = meshCount; 251 | ptr->materialCount = materialCount; 252 | ptr->meshes = meshes; 253 | ptr->materials = materials; 254 | ptr->meshMaterial = meshMaterial; 255 | ptr->boneCount = boneCount; 256 | ptr->bones = bones; 257 | ptr->bindPose = bindPose; 258 | return ptr; 259 | } 260 | void free_Model(Model* ptr){ 261 | free(ptr); 262 | } 263 | ModelAnimation* malloc_ModelAnimation(int boneCount, int frameCount, BoneInfo * bones, Transform ** framePoses, char name[32]) { 264 | ModelAnimation* ptr = malloc(sizeof(ModelAnimation)); 265 | ptr->boneCount = boneCount; 266 | ptr->frameCount = frameCount; 267 | ptr->bones = bones; 268 | ptr->framePoses = framePoses; 269 | memcpy(ptr->name, name, 32 * sizeof(char)); 270 | return ptr; 271 | } 272 | void free_ModelAnimation(ModelAnimation* ptr){ 273 | free(ptr); 274 | } 275 | Ray* malloc_Ray(Vector3 * position, Vector3 * direction) { 276 | Ray* ptr = malloc(sizeof(Ray)); 277 | ptr->position = *position; 278 | ptr->direction = *direction; 279 | return ptr; 280 | } 281 | void free_Ray(Ray* ptr){ 282 | free(ptr); 283 | } 284 | RayCollision* malloc_RayCollision(bool hit, float distance, Vector3 * point, Vector3 * normal) { 285 | RayCollision* ptr = malloc(sizeof(RayCollision)); 286 | ptr->hit = hit; 287 | ptr->distance = distance; 288 | ptr->point = *point; 289 | ptr->normal = *normal; 290 | return ptr; 291 | } 292 | void free_RayCollision(RayCollision* ptr){ 293 | free(ptr); 294 | } 295 | BoundingBox* malloc_BoundingBox(Vector3 * min, Vector3 * max) { 296 | BoundingBox* ptr = malloc(sizeof(BoundingBox)); 297 | ptr->min = *min; 298 | ptr->max = *max; 299 | return ptr; 300 | } 301 | void free_BoundingBox(BoundingBox* ptr){ 302 | free(ptr); 303 | } 304 | Wave* malloc_Wave(unsigned int frameCount,unsigned int sampleRate,unsigned int sampleSize,unsigned int channels, void * data) { 305 | Wave* ptr = malloc(sizeof(Wave)); 306 | ptr->frameCount = frameCount; 307 | ptr->sampleRate = sampleRate; 308 | ptr->sampleSize = sampleSize; 309 | ptr->channels = channels; 310 | ptr->data = data; 311 | return ptr; 312 | } 313 | void free_Wave(Wave* ptr){ 314 | free(ptr); 315 | } 316 | 317 | 318 | Sound* malloc_Sound(AudioStream * stream,unsigned int frameCount) { 319 | Sound* ptr = malloc(sizeof(Sound)); 320 | ptr->stream = *stream; 321 | ptr->frameCount = frameCount; 322 | return ptr; 323 | } 324 | void free_Sound(Sound* ptr){ 325 | free(ptr); 326 | } 327 | Music* malloc_Music(AudioStream * stream,unsigned int frameCount, bool looping, int ctxType, void * ctxData) { 328 | Music* ptr = malloc(sizeof(Music)); 329 | ptr->stream = *stream; 330 | ptr->frameCount = frameCount; 331 | ptr->looping = looping; 332 | ptr->ctxType = ctxType; 333 | ptr->ctxData = ctxData; 334 | return ptr; 335 | } 336 | void free_Music(Music* ptr){ 337 | free(ptr); 338 | } 339 | VrDeviceInfo* malloc_VrDeviceInfo(int hResolution, int vResolution, float hScreenSize, float vScreenSize, float eyeToScreenDistance, float lensSeparationDistance, float interpupillaryDistance, float lensDistortionValues[4], float chromaAbCorrection[4]) { 340 | VrDeviceInfo* ptr = malloc(sizeof(VrDeviceInfo)); 341 | ptr->hResolution = hResolution; 342 | ptr->vResolution = vResolution; 343 | ptr->hScreenSize = hScreenSize; 344 | ptr->vScreenSize = vScreenSize; 345 | ptr->eyeToScreenDistance = eyeToScreenDistance; 346 | ptr->lensSeparationDistance = lensSeparationDistance; 347 | ptr->interpupillaryDistance = interpupillaryDistance; 348 | memcpy(ptr->lensDistortionValues, lensDistortionValues, 4 * sizeof(float)); 349 | memcpy(ptr->chromaAbCorrection, chromaAbCorrection, 4 * sizeof(float)); 350 | return ptr; 351 | } 352 | void free_VrDeviceInfo(VrDeviceInfo* ptr){ 353 | free(ptr); 354 | } 355 | VrStereoConfig* malloc_VrStereoConfig(Matrix * projection[2], Matrix * viewOffset[2], float leftLensCenter[2], float rightLensCenter[2], float leftScreenCenter[2], float rightScreenCenter[2], float scale[2], float scaleIn[2]) { 356 | VrStereoConfig* ptr = malloc(sizeof(VrStereoConfig)); 357 | memcpy(ptr->projection, projection, 2 * sizeof(Matrix)); 358 | memcpy(ptr->viewOffset, viewOffset, 2 * sizeof(Matrix)); 359 | memcpy(ptr->leftLensCenter, leftLensCenter, 2 * sizeof(float)); 360 | memcpy(ptr->rightLensCenter, rightLensCenter, 2 * sizeof(float)); 361 | memcpy(ptr->leftScreenCenter, leftScreenCenter, 2 * sizeof(float)); 362 | memcpy(ptr->rightScreenCenter, rightScreenCenter, 2 * sizeof(float)); 363 | memcpy(ptr->scale, scale, 2 * sizeof(float)); 364 | memcpy(ptr->scaleIn, scaleIn, 2 * sizeof(float)); 365 | return ptr; 366 | } 367 | void free_VrStereoConfig(VrStereoConfig* ptr){ 368 | free(ptr); 369 | } 370 | FilePathList* malloc_FilePathList(unsigned int capacity,unsigned int count, char ** paths) { 371 | FilePathList* ptr = malloc(sizeof(FilePathList)); 372 | ptr->capacity = capacity; 373 | ptr->count = count; 374 | ptr->paths = paths; 375 | return ptr; 376 | } 377 | void free_FilePathList(FilePathList* ptr){ 378 | free(ptr); 379 | } 380 | AutomationEvent* malloc_AutomationEvent(unsigned int frame,unsigned int type, int params[4]) { 381 | AutomationEvent* ptr = malloc(sizeof(AutomationEvent)); 382 | ptr->frame = frame; 383 | ptr->type = type; 384 | memcpy(ptr->params, params, 4 * sizeof(int)); 385 | return ptr; 386 | } 387 | void free_AutomationEvent(AutomationEvent* ptr){ 388 | free(ptr); 389 | } 390 | AutomationEventList* malloc_AutomationEventList(unsigned int capacity,unsigned int count, AutomationEvent * events) { 391 | AutomationEventList* ptr = malloc(sizeof(AutomationEventList)); 392 | ptr->capacity = capacity; 393 | ptr->count = count; 394 | ptr->events = events; 395 | return ptr; 396 | } 397 | void free_AutomationEventList(AutomationEventList* ptr){ 398 | free(ptr); 399 | } 400 | -------------------------------------------------------------------------------- /lib/Raylib/Actions.rakumod: -------------------------------------------------------------------------------- 1 | class Pointerized { 2 | has Bool $.is-pointerized = False; 3 | has Str $.pointer-value = "*"; 4 | multi method new ($is-pointerized, $pointer-value) { 5 | self.bless(:$is-pointerized, :$pointer-value); 6 | } 7 | 8 | method Str() { 9 | return $.pointer-value; 10 | } 11 | 12 | } 13 | 14 | class RaylibActions { 15 | has Str $.library-name is rw; 16 | has Str @.bindings; 17 | has Str @.predifined-colors; 18 | has Str @.pointerized_bindings; 19 | has Str @.alloc_bindings; 20 | has Str @.c_pointerize_bindings; 21 | has Str @.c_pointerize_custom_binding; 22 | has Str @.c_alloc_funtions; 23 | has @.type-map = "int" => "int32", "float" => "num32", "double" => "num64", "short" => "int16", "char" => "Str", "bool" => "bool", "void" => "void", "va_list" => "Str"; 24 | has Bool $!is-value-type = False; 25 | has Int $!incrementer = 0; 26 | has %!callbacks; 27 | has @.ignore-alloc-structs = ["AudioStream"]; 28 | has @.ignored-functions = 29 | # "SetTraceLogCallback", 30 | # "SetLoadFileDataCallback", "SetSaveFileDataCallback", 31 | # "SetLoadFileTextCallback", "SetSaveFileTextCallback", 32 | # "SetAudioStreamCallback", 33 | # "AttachAudioMixedProcessor", 34 | # "DetachAudioMixedProcessor", "AttachAudioStreamProcessor", 35 | # "DetachAudioStreamProcessor"; 36 | 37 | 38 | method TOP ($/) { 39 | } 40 | 41 | method typedef-alias($/) { 42 | @.bindings.push("class $ is $($.made) is export is repr('CStruct') \{\}"); 43 | } 44 | 45 | method typedef-struct-forward($/){ 46 | @.bindings.push("class $ is export is repr('CStruct') \{ has int32 \$.dummy;\}"); 47 | } 48 | 49 | multi method typedef-callback($/ where $ eq 'void') { 50 | 51 | my $callback-func = "&{self.camelcase-to-kebab($.made)} ({$.made})"; 52 | %!callbacks{$.made} = $callback-func; 53 | } 54 | multi method typedef-callback($/) { 55 | my $callback-func = "&{self.camelcase-to-kebab($.made)} ({$.made} --> {$.made})"; 56 | %!callbacks{$.made} = $callback-func; 57 | } 58 | 59 | 60 | method define-decl($/) { 61 | my $m-func = $.tail; 62 | if $m-func && $m-func && $m-func eq 'Color' { 63 | my $color = "sub term:.head.lc)> is export \{ Color.init(" ~ $.tail.Str~');} # creating a new instance of Color'; 64 | @.predifined-colors.push($color); 65 | } 66 | } 67 | method typedef-struct($/) { 68 | my $struct-name = $[0]; 69 | my $struct = "class $($[0]) is export is repr('CStruct') is rw "; 70 | my $b = $.made; 71 | my @func-bundle = self.create-malloc-function($/); 72 | @.c_alloc_funtions.push(@func-bundle[0].join); 73 | my $raku-params = @func-bundle[1].join(','); 74 | # Extracting identifiers 75 | my $raku-identifiers = @func-bundle[1].map(-> $x {$x[1]}).join(','); 76 | my $malloc-func = ''; 77 | my $free-func = ''; 78 | my $gc-auto-free-func = ''; 79 | 80 | if $struct-name.Str !∈ @.ignore-alloc-structs { 81 | $malloc-func = " method init\($raku-params\) returns $struct-name \{\n malloc-$struct-name\($raku-identifiers\);\n }"; 82 | $free-func = " method free \{\n free-$struct-name\(self\);\n }"; 83 | $gc-auto-free-func = " submethod DESTROY \{\n free-$struct-name\(self\);\n }"; 84 | } 85 | 86 | @.bindings.push($struct ~ "\{\n " ~ $b ~ $malloc-func ~"\n"~ $gc-auto-free-func ~"\n\}"); 87 | @.c_alloc_funtions.push(self.create-free-function($/).join); 88 | } 89 | 90 | method typedef-enum($/) { 91 | my $enum-decl = "enum $ is export"; 92 | my $b = $.made; 93 | @.bindings.push("$enum-decl (\n $b);"); 94 | 95 | } 96 | 97 | method enum-var-decl($/) { 98 | if ($.elems > 1) 99 | { 100 | $!incrementer = +$[1] if $[1].Numeric; 101 | make " $($[0]) => $($[1]),\n"; 102 | } 103 | else { 104 | $!incrementer = $!incrementer + 1; 105 | make " $($[0]) => $!incrementer,\n"; 106 | } 107 | } 108 | 109 | method block($/) { 110 | $!incrementer = 0; 111 | my @block-data; 112 | for $ -> $state { 113 | if ($state) { 114 | my $member = $state.made; 115 | @block-data.push($member); 116 | } 117 | if ($state) { 118 | my $member = $state.made; 119 | @block-data.push($member); 120 | } 121 | } 122 | make @block-data.Str; 123 | } 124 | 125 | method var-decl($/) { 126 | my @aaa; 127 | for $ -> $ident { 128 | my $unsigned = $.map: *.made; 129 | if ($ && $ eq "void") { 130 | @aaa.push(" has Pointer[void] \$.$ident;\n"); 131 | } 132 | else { 133 | 134 | my $defined-type; 135 | if $unsigned eq 'u' && $ eq 'char' { 136 | $defined-type = 'uint8'; 137 | } 138 | else { 139 | $defined-type = $ eq 'char' ?? $.made !! "$unsigned$($.made)"; 140 | } 141 | # IF VALUE TYPE 142 | if !$ && $ 143 | { 144 | @aaa.push(" HAS $defined-type \$.$ident;\n"); 145 | } 146 | elsif $.elems eq 1 && $ 147 | { 148 | @aaa.push(" has Pointer[$defined-type] \$.$ident;\n"); 149 | } 150 | elsif $.elems eq 2 && $ 151 | { 152 | @aaa.push(" has Pointer \$.$ident;\n"); 153 | } 154 | elsif $ 155 | { 156 | @aaa.push(" has $defined-type \$.$ident is rw;\n"); 157 | } 158 | else 159 | { 160 | @aaa.push(" has $defined-type \$.$ident;\n"); 161 | } 162 | } 163 | } 164 | for $ -> $arr-ident { 165 | if $ eq 'char' { 166 | my $name = $arr-ident.made(); 167 | @aaa.push(" has uint8 @.$arr-ident is CArray;\n"); 168 | } 169 | else { 170 | @aaa.push(" has CArray[$($.made)] $($arr-ident.made) is rw;\n"); 171 | } 172 | } 173 | make @aaa.Str; 174 | } 175 | 176 | method array-identifier($/) { 177 | my $arr = "\$.$"; 178 | make $arr; 179 | } 180 | 181 | method modifier($/) { 182 | if $ { 183 | make 'u'; 184 | } 185 | else { 186 | make ''; 187 | } 188 | } 189 | 190 | method function($/) { 191 | if $.made !∈ @.ignored-functions { 192 | my $return-is-type-value-type = $ && !$; 193 | my $made-parameters = $.made; 194 | my $func = self.gen-function($, $, $, $.made, $return-is-type-value-type); 195 | if ($!is-value-type || $return-is-type-value-type) { # checking return type also 196 | $!is-value-type = False; 197 | @.pointerized_bindings.push($func); 198 | my @current-identifiers; 199 | my $pointerized-params = self.pointerize-parameters($, @current-identifiers); 200 | #creating call func for pointerize 201 | my $call-func = self.create-call-func(@current-identifiers, ~$); 202 | 203 | my $normal-type-return = "$" ~ ($ ?? "*" !! ''); 204 | my $pointerized-return = self.create-pointerized-return-type($/); 205 | my $return-type = $pointerized-return[0]; 206 | my $is-normal-return = !$pointerized-return[1]; 207 | my $wrapped_func_call; 208 | if ($is-normal-return) { 209 | if ($ eq 'void') { 210 | $wrapped_func_call = $return-type ~ ' '~ $~ '_pointerized(' ~ $pointerized-params ~ ")\{ $call-func \}"; 211 | } 212 | else { 213 | $wrapped_func_call = $return-type ~ ' '~ $~ '_pointerized(' ~ $pointerized-params ~ ")\{ return $call-func \}"; 214 | } 215 | @.c_pointerize_bindings.push($wrapped_func_call); 216 | } 217 | else { 218 | $wrapped_func_call = $return-type ~ ' '~ $~ '_pointerized(' ~ $pointerized-params ~ ")\{\n $return-type ptr = malloc\(sizeof\($\)\);\n $ ret = $call-func \n *ptr = ret; \n return ptr;\n\}"; 219 | @.c_pointerize_bindings.push($wrapped_func_call); 220 | } 221 | } 222 | else { 223 | @.bindings.push($func); 224 | } 225 | } 226 | } 227 | 228 | method create-free-function($struct) { 229 | my @free_function; 230 | if $struct[0].Str !∈ @.ignore-alloc-structs { 231 | @free_function.push("void free_$struct[0]\($struct[0]* ptr)\{\n"); 232 | @free_function.push(" free(ptr);\n"); 233 | @free_function.push("\}"); 234 | } 235 | return @free_function; 236 | 237 | } 238 | method create-malloc-function($struct) { 239 | my @parameters; 240 | my @raku-parameters; 241 | for $struct -> $x { 242 | if $x { 243 | for $x -> $ident { 244 | @parameters.push(($x, $x, $x, $ident)); 245 | if ($x eq 'unsigned' && $x eq 'char') { 246 | @raku-parameters.push(('uint8', "\$$ident")); 247 | } 248 | elsif $x && $x.elems > 1 { 249 | my $type = $x.made; 250 | @raku-parameters.push(("Pointer", "\$$ident")); 251 | } 252 | elsif $x && $x { 253 | my $type = $x.made; 254 | @raku-parameters.push(("Pointer[$type]", "\$$ident")); 255 | } 256 | else { 257 | @raku-parameters.push(($x.made, "\$$ident")); 258 | } 259 | } 260 | } 261 | 262 | if $x { 263 | if $x eq 'char' { 264 | @parameters.push(($x, $x, $x, $x)); 265 | @raku-parameters.push(($x.made, "\$$x[0]")); 266 | 267 | } 268 | else { 269 | @parameters.push(($x, $x, $x, $x)); 270 | @raku-parameters.push(('CArray[' ~ $x.made ~ ']', "\$$x[0]")); 271 | } 272 | } 273 | } 274 | 275 | my @pp = self.pointerize-parameter-list(@parameters); 276 | my $param-list = @pp.join(',').trim; 277 | # say @raku-parameters; 278 | my $raku-param-list = @raku-parameters.join(',').trim; 279 | 280 | # print "($param-list)"; 281 | my @malloc_function; 282 | my $struct-name = $struct.first.Str; 283 | if $struct-name !∈ @.ignore-alloc-structs { 284 | @.alloc_bindings.push("our sub malloc-$struct-name\($raku-param-list\) returns $struct-name is native($.library-name) is symbol('malloc_$struct-name') \{*\}"); 285 | @.alloc_bindings.push("our sub free-$struct-name\($struct-name \$ptr) is native($.library-name) is symbol('free_$struct-name') \{*\}"); 286 | @malloc_function.push($struct.first.Str ~ '* '~ "malloc_" ~ $struct.first.Str ~ "($param-list) \{\n"); 287 | @malloc_function.push(" $struct[0]* ptr = malloc(sizeof($struct[0]));\n"); 288 | for @pp -> $pv { 289 | my $identifier-name = $pv[3][0] ?? $pv[3][0] !! $pv[3]; 290 | # checking if it's an array 291 | if ($pv[3][0]) { 292 | #using memcpy 293 | @malloc_function.push(" memcpy(ptr->$identifier-name, $identifier-name, $pv[3][0] * sizeof($pv[1]));\n"); 294 | } 295 | elsif ($pv[1] && $pv[2].is-pointerized) { 296 | @malloc_function.push(" ptr->$identifier-name = $pv[2]$identifier-name;\n"); 297 | } 298 | else { 299 | @malloc_function.push(" ptr->$identifier-name = $identifier-name;\n"); 300 | } 301 | } 302 | @malloc_function.push(" return ptr;\n"); 303 | @malloc_function.push("\}"); 304 | } 305 | return @malloc_function, @raku-parameters; 306 | 307 | 308 | } 309 | 310 | method pointerize-parameter-list(@parameters) { 311 | my @pointerized-params; 312 | 313 | for @parameters -> $p { 314 | if $p[1] && !$p[2] { 315 | @pointerized-params.push(($p[0], $p[1], Pointerized.new(True, '*'), $p[3])); 316 | } 317 | else { 318 | my $pointer = $p[2].Str.subst(' ',''); 319 | @pointerized-params.push(($p[0], $p[1], Pointerized.new(False, $pointer), $p[3])); 320 | } 321 | } 322 | return @pointerized-params; 323 | 324 | } 325 | 326 | method create-pointerized-return-type($function) { 327 | if ($function && $function) { 328 | #already pointer no change is needed 329 | return ("$function$function", False); 330 | } 331 | elsif $function && !$function { 332 | #value type pointerized 333 | return ("$function" ~ "*", True); 334 | } 335 | return ("$function$function", False); 336 | 337 | } 338 | 339 | method create-call-func(@current-identifiers, $identifier) { 340 | my $call-func = $identifier ~ '('; 341 | for @current-identifiers.kv -> $idx, $ident { 342 | my $add-comma = $idx gt 0 ?? ', ' !! ''; 343 | # need to deref True of False? 344 | if ($ident[2]) { 345 | $call-func ~= ($add-comma ~ "*$ident[1]"); 346 | } 347 | else { 348 | $call-func ~= ($add-comma ~ "$ident[1]"); 349 | } 350 | } 351 | $call-func ~= ");"; 352 | return $call-func; 353 | 354 | } 355 | 356 | method pointerize-parameters($parameters, @current-identifiers) { 357 | if $parameters eq 'void' { 358 | return ""; 359 | } 360 | my $tail = ""; 361 | my $rest = $parameters ?? $parameters.map(-> $p {self.pointerize-parameters($p, @current-identifiers)}) !! ""; 362 | if $rest { 363 | $tail = ',' ~ ' ' ~ $rest; 364 | } 365 | 366 | 367 | if ($parameters && !$parameters) { 368 | #get pointerized to true since no pointer 369 | my $should-pointerize = True; 370 | my $star = "*"; 371 | if (%!callbacks{$parameters}:exists) { 372 | # We don't poiterize since this is a callback which is a pointer 373 | $should-pointerize = False; 374 | $star = ''; #erasing star 375 | } 376 | @current-identifiers.unshift((~$parameters, ~$parameters, $should-pointerize)); 377 | return "$($parameters)$star $parameters" ~ $tail; 378 | } 379 | elsif ($parameters && $parameters) { 380 | @current-identifiers.unshift((~$parameters, ~$parameters, False)); 381 | my $modifier = $ ?? $ !! ''; 382 | my $const = $ ?? 'const ' !! ''; 383 | return "$const$modifier $($parameters) $parameters $parameters" ~ $tail; 384 | } 385 | else { 386 | @current-identifiers.unshift((~$parameters, $parameters, False)); 387 | return "$($parameters) $parameters" ~ $tail; 388 | } 389 | } 390 | 391 | method get-return-type($return-type, $pointer) { 392 | my $raku-type = $return-type.made; 393 | my $is-identifier = False; 394 | if ($return-type) { 395 | $is-identifier = True; 396 | $raku-type = $return-type.made; 397 | } 398 | 399 | if ($raku-type ne 'void') { 400 | # no returns on void type 401 | return " returns $raku-type"; 402 | } 403 | return '' 404 | } 405 | 406 | method camelcase-to-kebab(Str $camel-case) { 407 | my $kebab = $camel-case.subst(/(<:Lu><:Lu>?<:Ll>|\d+D|<:Lu>+)/, { '-' ~ .Str.lc }, :g); 408 | $kebab.=subst(/\-\d+d/, {.substr(1).lc}); # fixing 2d and 3d since kebab casing numbers isn't allowed 409 | return $kebab.substr(1); 410 | 411 | } 412 | 413 | method gen-function($return-type, $pointer, $function-name, $parameters, $return-is-type-value-type) { 414 | my $pointerize = ($!is-value-type || $return-is-type-value-type) ?? '_pointerized' !! ''; 415 | my $params = $parameters; 416 | my $raku-type = self.get-return-type($return-type, $pointer); 417 | my $kebab-case-name = self.camelcase-to-kebab($function-name.Str); 418 | return $params 419 | ?? "our sub $kebab-case-name ($params)$raku-type is export is native($.library-name) is symbol('$function-name$pointerize')\{ * \}" 420 | !! "our sub term:<$kebab-case-name> ()$raku-type is export is native($.library-name) is symbol('$function-name$pointerize')\{ * \}"; 421 | } 422 | 423 | # void pointer 424 | multi method parameters($/ where $ && $ eq 'void') { 425 | make "Pointer[void] \$$, {$.map: *.made.join(',')}"; 426 | } 427 | 428 | multi method parameters($/ where $ && $ eq 'int') { 429 | make "int32 \$$ is rw, {$.map: *.made.join(',')}"; 430 | } 431 | 432 | multi method parameters($/ where $ && $ eq 'char' && !$) { 433 | make "CArray[uint8] \$$, {$.map: *.made.join(',')}"; 434 | } 435 | 436 | 437 | multi method parameters($/) { 438 | if (!$) { 439 | make ''; 440 | return; 441 | } 442 | my $unsigned = $ ?? 'u' !! ''; 443 | my $type = ~$.made; 444 | if $type eq 'void' { 445 | make ""; 446 | return; 447 | } 448 | my $rest = $ ?? $.map: *.made !! ""; 449 | my $tail = ""; 450 | if $rest { 451 | $tail = ',' ~ ' ' ~ $rest; 452 | } 453 | 454 | my $u = ''; 455 | if $ && $ ne 'char' { 456 | make "$unsigned$type \$$($ ?? "$ is rw" !! '')$tail"; 457 | } 458 | elsif $ && $ eq 'char' && $ { 459 | make "uint8 \$$($ ?? "$ is rw" !! '')$tail"; 460 | } 461 | else { 462 | # if defined %.value-typed-data{~$type} 463 | if $ 464 | { 465 | my $call-func = %!callbacks{$type}; 466 | if $call-func { 467 | make "$call-func$tail"; 468 | } 469 | else 470 | { 471 | $!is-value-type = True; 472 | make "$unsigned$type \$$($ ?? $ !! '')$tail"; 473 | } 474 | } 475 | else 476 | { 477 | make "$unsigned$type \$$($ ?? $ !! '')$tail"; 478 | } 479 | } 480 | } 481 | 482 | method type($/) { 483 | if ($) { 484 | make $.made; 485 | } 486 | else { 487 | make %.type-map{~$/}; 488 | } 489 | } 490 | 491 | method identifier($/) { 492 | make ~$/; 493 | } 494 | 495 | 496 | 497 | } 498 | -------------------------------------------------------------------------------- /resources/raylib_pointerized_wrapper.c: -------------------------------------------------------------------------------- 1 | // This file is generated by raylib-raku 2 | #include 3 | #include 4 | void SetWindowIcon_pointerized(Image* image){ SetWindowIcon(*image); } 5 | Vector2* GetMonitorPosition_pointerized(int monitor){ 6 | Vector2* ptr = malloc(sizeof(Vector2)); 7 | Vector2 ret = GetMonitorPosition(monitor); 8 | *ptr = ret; 9 | return ptr; 10 | } 11 | Vector2* GetWindowPosition_pointerized(){ 12 | Vector2* ptr = malloc(sizeof(Vector2)); 13 | Vector2 ret = GetWindowPosition(); 14 | *ptr = ret; 15 | return ptr; 16 | } 17 | Vector2* GetWindowScaleDPI_pointerized(){ 18 | Vector2* ptr = malloc(sizeof(Vector2)); 19 | Vector2 ret = GetWindowScaleDPI(); 20 | *ptr = ret; 21 | return ptr; 22 | } 23 | Image* GetClipboardImage_pointerized(){ 24 | Image* ptr = malloc(sizeof(Image)); 25 | Image ret = GetClipboardImage(); 26 | *ptr = ret; 27 | return ptr; 28 | } 29 | void ClearBackground_pointerized(Color* color){ ClearBackground(*color); } 30 | void BeginMode2D_pointerized(Camera2D* camera){ BeginMode2D(*camera); } 31 | void BeginMode3D_pointerized(Camera3D* camera){ BeginMode3D(*camera); } 32 | void BeginTextureMode_pointerized(RenderTexture2D* target){ BeginTextureMode(*target); } 33 | void BeginShaderMode_pointerized(Shader* shader){ BeginShaderMode(*shader); } 34 | void BeginVrStereoMode_pointerized(VrStereoConfig* config){ BeginVrStereoMode(*config); } 35 | VrStereoConfig* LoadVrStereoConfig_pointerized(VrDeviceInfo* device){ 36 | VrStereoConfig* ptr = malloc(sizeof(VrStereoConfig)); 37 | VrStereoConfig ret = LoadVrStereoConfig(*device); 38 | *ptr = ret; 39 | return ptr; 40 | } 41 | void UnloadVrStereoConfig_pointerized(VrStereoConfig* config){ UnloadVrStereoConfig(*config); } 42 | Shader* LoadShader_pointerized( char * vsFileName, char * fsFileName){ 43 | Shader* ptr = malloc(sizeof(Shader)); 44 | Shader ret = LoadShader(vsFileName, fsFileName); 45 | *ptr = ret; 46 | return ptr; 47 | } 48 | Shader* LoadShaderFromMemory_pointerized( char * vsCode, char * fsCode){ 49 | Shader* ptr = malloc(sizeof(Shader)); 50 | Shader ret = LoadShaderFromMemory(vsCode, fsCode); 51 | *ptr = ret; 52 | return ptr; 53 | } 54 | bool IsShaderValid_pointerized(Shader* shader){ return IsShaderValid(*shader); } 55 | int GetShaderLocation_pointerized(Shader* shader, char * uniformName){ return GetShaderLocation(*shader, uniformName); } 56 | int GetShaderLocationAttrib_pointerized(Shader* shader, char * attribName){ return GetShaderLocationAttrib(*shader, attribName); } 57 | void SetShaderValue_pointerized(Shader* shader, int locIndex, void * value, int uniformType){ SetShaderValue(*shader, locIndex, value, uniformType); } 58 | void SetShaderValueV_pointerized(Shader* shader, int locIndex, void * value, int uniformType, int count){ SetShaderValueV(*shader, locIndex, value, uniformType, count); } 59 | void SetShaderValueMatrix_pointerized(Shader* shader, int locIndex, Matrix* mat){ SetShaderValueMatrix(*shader, locIndex, *mat); } 60 | void SetShaderValueTexture_pointerized(Shader* shader, int locIndex, Texture2D* texture){ SetShaderValueTexture(*shader, locIndex, *texture); } 61 | void UnloadShader_pointerized(Shader* shader){ UnloadShader(*shader); } 62 | Ray* GetScreenToWorldRay_pointerized(Vector2* position, Camera* camera){ 63 | Ray* ptr = malloc(sizeof(Ray)); 64 | Ray ret = GetScreenToWorldRay(*position, *camera); 65 | *ptr = ret; 66 | return ptr; 67 | } 68 | Ray* GetScreenToWorldRayEx_pointerized(Vector2* position, Camera* camera, int width, int height){ 69 | Ray* ptr = malloc(sizeof(Ray)); 70 | Ray ret = GetScreenToWorldRayEx(*position, *camera, width, height); 71 | *ptr = ret; 72 | return ptr; 73 | } 74 | Vector2* GetWorldToScreen_pointerized(Vector3* position, Camera* camera){ 75 | Vector2* ptr = malloc(sizeof(Vector2)); 76 | Vector2 ret = GetWorldToScreen(*position, *camera); 77 | *ptr = ret; 78 | return ptr; 79 | } 80 | Vector2* GetWorldToScreenEx_pointerized(Vector3* position, Camera* camera, int width, int height){ 81 | Vector2* ptr = malloc(sizeof(Vector2)); 82 | Vector2 ret = GetWorldToScreenEx(*position, *camera, width, height); 83 | *ptr = ret; 84 | return ptr; 85 | } 86 | Vector2* GetWorldToScreen2D_pointerized(Vector2* position, Camera2D* camera){ 87 | Vector2* ptr = malloc(sizeof(Vector2)); 88 | Vector2 ret = GetWorldToScreen2D(*position, *camera); 89 | *ptr = ret; 90 | return ptr; 91 | } 92 | Vector2* GetScreenToWorld2D_pointerized(Vector2* position, Camera2D* camera){ 93 | Vector2* ptr = malloc(sizeof(Vector2)); 94 | Vector2 ret = GetScreenToWorld2D(*position, *camera); 95 | *ptr = ret; 96 | return ptr; 97 | } 98 | Matrix* GetCameraMatrix_pointerized(Camera* camera){ 99 | Matrix* ptr = malloc(sizeof(Matrix)); 100 | Matrix ret = GetCameraMatrix(*camera); 101 | *ptr = ret; 102 | return ptr; 103 | } 104 | Matrix* GetCameraMatrix2D_pointerized(Camera2D* camera){ 105 | Matrix* ptr = malloc(sizeof(Matrix)); 106 | Matrix ret = GetCameraMatrix2D(*camera); 107 | *ptr = ret; 108 | return ptr; 109 | } 110 | FilePathList* LoadDirectoryFiles_pointerized( char * dirPath){ 111 | FilePathList* ptr = malloc(sizeof(FilePathList)); 112 | FilePathList ret = LoadDirectoryFiles(dirPath); 113 | *ptr = ret; 114 | return ptr; 115 | } 116 | FilePathList* LoadDirectoryFilesEx_pointerized( char * basePath, char * filter, bool scanSubdirs){ 117 | FilePathList* ptr = malloc(sizeof(FilePathList)); 118 | FilePathList ret = LoadDirectoryFilesEx(basePath, filter, scanSubdirs); 119 | *ptr = ret; 120 | return ptr; 121 | } 122 | void UnloadDirectoryFiles_pointerized(FilePathList* files){ UnloadDirectoryFiles(*files); } 123 | FilePathList* LoadDroppedFiles_pointerized(){ 124 | FilePathList* ptr = malloc(sizeof(FilePathList)); 125 | FilePathList ret = LoadDroppedFiles(); 126 | *ptr = ret; 127 | return ptr; 128 | } 129 | void UnloadDroppedFiles_pointerized(FilePathList* files){ UnloadDroppedFiles(*files); } 130 | long* GetFileModTime_pointerized( char * fileName){ 131 | long* ptr = malloc(sizeof(long)); 132 | long ret = GetFileModTime(fileName); 133 | *ptr = ret; 134 | return ptr; 135 | } 136 | AutomationEventList* LoadAutomationEventList_pointerized( char * fileName){ 137 | AutomationEventList* ptr = malloc(sizeof(AutomationEventList)); 138 | AutomationEventList ret = LoadAutomationEventList(fileName); 139 | *ptr = ret; 140 | return ptr; 141 | } 142 | void UnloadAutomationEventList_pointerized(AutomationEventList* list){ UnloadAutomationEventList(*list); } 143 | bool ExportAutomationEventList_pointerized(AutomationEventList* list, char * fileName){ return ExportAutomationEventList(*list, fileName); } 144 | void PlayAutomationEvent_pointerized(AutomationEvent* event){ PlayAutomationEvent(*event); } 145 | Vector2* GetMousePosition_pointerized(){ 146 | Vector2* ptr = malloc(sizeof(Vector2)); 147 | Vector2 ret = GetMousePosition(); 148 | *ptr = ret; 149 | return ptr; 150 | } 151 | Vector2* GetMouseDelta_pointerized(){ 152 | Vector2* ptr = malloc(sizeof(Vector2)); 153 | Vector2 ret = GetMouseDelta(); 154 | *ptr = ret; 155 | return ptr; 156 | } 157 | Vector2* GetMouseWheelMoveV_pointerized(){ 158 | Vector2* ptr = malloc(sizeof(Vector2)); 159 | Vector2 ret = GetMouseWheelMoveV(); 160 | *ptr = ret; 161 | return ptr; 162 | } 163 | Vector2* GetTouchPosition_pointerized(int index){ 164 | Vector2* ptr = malloc(sizeof(Vector2)); 165 | Vector2 ret = GetTouchPosition(index); 166 | *ptr = ret; 167 | return ptr; 168 | } 169 | Vector2* GetGestureDragVector_pointerized(){ 170 | Vector2* ptr = malloc(sizeof(Vector2)); 171 | Vector2 ret = GetGestureDragVector(); 172 | *ptr = ret; 173 | return ptr; 174 | } 175 | Vector2* GetGesturePinchVector_pointerized(){ 176 | Vector2* ptr = malloc(sizeof(Vector2)); 177 | Vector2 ret = GetGesturePinchVector(); 178 | *ptr = ret; 179 | return ptr; 180 | } 181 | void UpdateCameraPro_pointerized( Camera * camera, Vector3* movement, Vector3* rotation, float zoom){ UpdateCameraPro(camera, *movement, *rotation, zoom); } 182 | void SetShapesTexture_pointerized(Texture2D* texture, Rectangle* source){ SetShapesTexture(*texture, *source); } 183 | Texture2D* GetShapesTexture_pointerized(){ 184 | Texture2D* ptr = malloc(sizeof(Texture2D)); 185 | Texture2D ret = GetShapesTexture(); 186 | *ptr = ret; 187 | return ptr; 188 | } 189 | Rectangle* GetShapesTextureRectangle_pointerized(){ 190 | Rectangle* ptr = malloc(sizeof(Rectangle)); 191 | Rectangle ret = GetShapesTextureRectangle(); 192 | *ptr = ret; 193 | return ptr; 194 | } 195 | void DrawPixel_pointerized(int posX, int posY, Color* color){ DrawPixel(posX, posY, *color); } 196 | void DrawPixelV_pointerized(Vector2* position, Color* color){ DrawPixelV(*position, *color); } 197 | void DrawLine_pointerized(int startPosX, int startPosY, int endPosX, int endPosY, Color* color){ DrawLine(startPosX, startPosY, endPosX, endPosY, *color); } 198 | void DrawLineV_pointerized(Vector2* startPos, Vector2* endPos, Color* color){ DrawLineV(*startPos, *endPos, *color); } 199 | void DrawLineEx_pointerized(Vector2* startPos, Vector2* endPos, float thick, Color* color){ DrawLineEx(*startPos, *endPos, thick, *color); } 200 | void DrawLineStrip_pointerized( Vector2 * points, int pointCount, Color* color){ DrawLineStrip(points, pointCount, *color); } 201 | void DrawLineBezier_pointerized(Vector2* startPos, Vector2* endPos, float thick, Color* color){ DrawLineBezier(*startPos, *endPos, thick, *color); } 202 | void DrawCircle_pointerized(int centerX, int centerY, float radius, Color* color){ DrawCircle(centerX, centerY, radius, *color); } 203 | void DrawCircleSector_pointerized(Vector2* center, float radius, float startAngle, float endAngle, int segments, Color* color){ DrawCircleSector(*center, radius, startAngle, endAngle, segments, *color); } 204 | void DrawCircleSectorLines_pointerized(Vector2* center, float radius, float startAngle, float endAngle, int segments, Color* color){ DrawCircleSectorLines(*center, radius, startAngle, endAngle, segments, *color); } 205 | void DrawCircleGradient_pointerized(int centerX, int centerY, float radius, Color* inner, Color* outer){ DrawCircleGradient(centerX, centerY, radius, *inner, *outer); } 206 | void DrawCircleV_pointerized(Vector2* center, float radius, Color* color){ DrawCircleV(*center, radius, *color); } 207 | void DrawCircleLines_pointerized(int centerX, int centerY, float radius, Color* color){ DrawCircleLines(centerX, centerY, radius, *color); } 208 | void DrawCircleLinesV_pointerized(Vector2* center, float radius, Color* color){ DrawCircleLinesV(*center, radius, *color); } 209 | void DrawEllipse_pointerized(int centerX, int centerY, float radiusH, float radiusV, Color* color){ DrawEllipse(centerX, centerY, radiusH, radiusV, *color); } 210 | void DrawEllipseLines_pointerized(int centerX, int centerY, float radiusH, float radiusV, Color* color){ DrawEllipseLines(centerX, centerY, radiusH, radiusV, *color); } 211 | void DrawRing_pointerized(Vector2* center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color* color){ DrawRing(*center, innerRadius, outerRadius, startAngle, endAngle, segments, *color); } 212 | void DrawRingLines_pointerized(Vector2* center, float innerRadius, float outerRadius, float startAngle, float endAngle, int segments, Color* color){ DrawRingLines(*center, innerRadius, outerRadius, startAngle, endAngle, segments, *color); } 213 | void DrawRectangle_pointerized(int posX, int posY, int width, int height, Color* color){ DrawRectangle(posX, posY, width, height, *color); } 214 | void DrawRectangleV_pointerized(Vector2* position, Vector2* size, Color* color){ DrawRectangleV(*position, *size, *color); } 215 | void DrawRectangleRec_pointerized(Rectangle* rec, Color* color){ DrawRectangleRec(*rec, *color); } 216 | void DrawRectanglePro_pointerized(Rectangle* rec, Vector2* origin, float rotation, Color* color){ DrawRectanglePro(*rec, *origin, rotation, *color); } 217 | void DrawRectangleGradientV_pointerized(int posX, int posY, int width, int height, Color* top, Color* bottom){ DrawRectangleGradientV(posX, posY, width, height, *top, *bottom); } 218 | void DrawRectangleGradientH_pointerized(int posX, int posY, int width, int height, Color* left, Color* right){ DrawRectangleGradientH(posX, posY, width, height, *left, *right); } 219 | void DrawRectangleGradientEx_pointerized(Rectangle* rec, Color* topLeft, Color* bottomLeft, Color* topRight, Color* bottomRight){ DrawRectangleGradientEx(*rec, *topLeft, *bottomLeft, *topRight, *bottomRight); } 220 | void DrawRectangleLines_pointerized(int posX, int posY, int width, int height, Color* color){ DrawRectangleLines(posX, posY, width, height, *color); } 221 | void DrawRectangleLinesEx_pointerized(Rectangle* rec, float lineThick, Color* color){ DrawRectangleLinesEx(*rec, lineThick, *color); } 222 | void DrawRectangleRounded_pointerized(Rectangle* rec, float roundness, int segments, Color* color){ DrawRectangleRounded(*rec, roundness, segments, *color); } 223 | void DrawRectangleRoundedLines_pointerized(Rectangle* rec, float roundness, int segments, Color* color){ DrawRectangleRoundedLines(*rec, roundness, segments, *color); } 224 | void DrawRectangleRoundedLinesEx_pointerized(Rectangle* rec, float roundness, int segments, float lineThick, Color* color){ DrawRectangleRoundedLinesEx(*rec, roundness, segments, lineThick, *color); } 225 | void DrawTriangle_pointerized(Vector2* v1, Vector2* v2, Vector2* v3, Color* color){ DrawTriangle(*v1, *v2, *v3, *color); } 226 | void DrawTriangleLines_pointerized(Vector2* v1, Vector2* v2, Vector2* v3, Color* color){ DrawTriangleLines(*v1, *v2, *v3, *color); } 227 | void DrawTriangleFan_pointerized( Vector2 * points, int pointCount, Color* color){ DrawTriangleFan(points, pointCount, *color); } 228 | void DrawTriangleStrip_pointerized( Vector2 * points, int pointCount, Color* color){ DrawTriangleStrip(points, pointCount, *color); } 229 | void DrawPoly_pointerized(Vector2* center, int sides, float radius, float rotation, Color* color){ DrawPoly(*center, sides, radius, rotation, *color); } 230 | void DrawPolyLines_pointerized(Vector2* center, int sides, float radius, float rotation, Color* color){ DrawPolyLines(*center, sides, radius, rotation, *color); } 231 | void DrawPolyLinesEx_pointerized(Vector2* center, int sides, float radius, float rotation, float lineThick, Color* color){ DrawPolyLinesEx(*center, sides, radius, rotation, lineThick, *color); } 232 | void DrawSplineLinear_pointerized( Vector2 * points, int pointCount, float thick, Color* color){ DrawSplineLinear(points, pointCount, thick, *color); } 233 | void DrawSplineBasis_pointerized( Vector2 * points, int pointCount, float thick, Color* color){ DrawSplineBasis(points, pointCount, thick, *color); } 234 | void DrawSplineCatmullRom_pointerized( Vector2 * points, int pointCount, float thick, Color* color){ DrawSplineCatmullRom(points, pointCount, thick, *color); } 235 | void DrawSplineBezierQuadratic_pointerized( Vector2 * points, int pointCount, float thick, Color* color){ DrawSplineBezierQuadratic(points, pointCount, thick, *color); } 236 | void DrawSplineBezierCubic_pointerized( Vector2 * points, int pointCount, float thick, Color* color){ DrawSplineBezierCubic(points, pointCount, thick, *color); } 237 | void DrawSplineSegmentLinear_pointerized(Vector2* p1, Vector2* p2, float thick, Color* color){ DrawSplineSegmentLinear(*p1, *p2, thick, *color); } 238 | void DrawSplineSegmentBasis_pointerized(Vector2* p1, Vector2* p2, Vector2* p3, Vector2* p4, float thick, Color* color){ DrawSplineSegmentBasis(*p1, *p2, *p3, *p4, thick, *color); } 239 | void DrawSplineSegmentCatmullRom_pointerized(Vector2* p1, Vector2* p2, Vector2* p3, Vector2* p4, float thick, Color* color){ DrawSplineSegmentCatmullRom(*p1, *p2, *p3, *p4, thick, *color); } 240 | void DrawSplineSegmentBezierQuadratic_pointerized(Vector2* p1, Vector2* c2, Vector2* p3, float thick, Color* color){ DrawSplineSegmentBezierQuadratic(*p1, *c2, *p3, thick, *color); } 241 | void DrawSplineSegmentBezierCubic_pointerized(Vector2* p1, Vector2* c2, Vector2* c3, Vector2* p4, float thick, Color* color){ DrawSplineSegmentBezierCubic(*p1, *c2, *c3, *p4, thick, *color); } 242 | Vector2* GetSplinePointLinear_pointerized(Vector2* startPos, Vector2* endPos, float t){ 243 | Vector2* ptr = malloc(sizeof(Vector2)); 244 | Vector2 ret = GetSplinePointLinear(*startPos, *endPos, t); 245 | *ptr = ret; 246 | return ptr; 247 | } 248 | Vector2* GetSplinePointBasis_pointerized(Vector2* p1, Vector2* p2, Vector2* p3, Vector2* p4, float t){ 249 | Vector2* ptr = malloc(sizeof(Vector2)); 250 | Vector2 ret = GetSplinePointBasis(*p1, *p2, *p3, *p4, t); 251 | *ptr = ret; 252 | return ptr; 253 | } 254 | Vector2* GetSplinePointCatmullRom_pointerized(Vector2* p1, Vector2* p2, Vector2* p3, Vector2* p4, float t){ 255 | Vector2* ptr = malloc(sizeof(Vector2)); 256 | Vector2 ret = GetSplinePointCatmullRom(*p1, *p2, *p3, *p4, t); 257 | *ptr = ret; 258 | return ptr; 259 | } 260 | Vector2* GetSplinePointBezierQuad_pointerized(Vector2* p1, Vector2* c2, Vector2* p3, float t){ 261 | Vector2* ptr = malloc(sizeof(Vector2)); 262 | Vector2 ret = GetSplinePointBezierQuad(*p1, *c2, *p3, t); 263 | *ptr = ret; 264 | return ptr; 265 | } 266 | Vector2* GetSplinePointBezierCubic_pointerized(Vector2* p1, Vector2* c2, Vector2* c3, Vector2* p4, float t){ 267 | Vector2* ptr = malloc(sizeof(Vector2)); 268 | Vector2 ret = GetSplinePointBezierCubic(*p1, *c2, *c3, *p4, t); 269 | *ptr = ret; 270 | return ptr; 271 | } 272 | bool CheckCollisionRecs_pointerized(Rectangle* rec1, Rectangle* rec2){ return CheckCollisionRecs(*rec1, *rec2); } 273 | bool CheckCollisionCircles_pointerized(Vector2* center1, float radius1, Vector2* center2, float radius2){ return CheckCollisionCircles(*center1, radius1, *center2, radius2); } 274 | bool CheckCollisionCircleRec_pointerized(Vector2* center, float radius, Rectangle* rec){ return CheckCollisionCircleRec(*center, radius, *rec); } 275 | bool CheckCollisionCircleLine_pointerized(Vector2* center, float radius, Vector2* p1, Vector2* p2){ return CheckCollisionCircleLine(*center, radius, *p1, *p2); } 276 | bool CheckCollisionPointRec_pointerized(Vector2* point, Rectangle* rec){ return CheckCollisionPointRec(*point, *rec); } 277 | bool CheckCollisionPointCircle_pointerized(Vector2* point, Vector2* center, float radius){ return CheckCollisionPointCircle(*point, *center, radius); } 278 | bool CheckCollisionPointTriangle_pointerized(Vector2* point, Vector2* p1, Vector2* p2, Vector2* p3){ return CheckCollisionPointTriangle(*point, *p1, *p2, *p3); } 279 | bool CheckCollisionPointLine_pointerized(Vector2* point, Vector2* p1, Vector2* p2, int threshold){ return CheckCollisionPointLine(*point, *p1, *p2, threshold); } 280 | bool CheckCollisionPointPoly_pointerized(Vector2* point, Vector2 * points, int pointCount){ return CheckCollisionPointPoly(*point, points, pointCount); } 281 | bool CheckCollisionLines_pointerized(Vector2* startPos1, Vector2* endPos1, Vector2* startPos2, Vector2* endPos2, Vector2 * collisionPoint){ return CheckCollisionLines(*startPos1, *endPos1, *startPos2, *endPos2, collisionPoint); } 282 | Rectangle* GetCollisionRec_pointerized(Rectangle* rec1, Rectangle* rec2){ 283 | Rectangle* ptr = malloc(sizeof(Rectangle)); 284 | Rectangle ret = GetCollisionRec(*rec1, *rec2); 285 | *ptr = ret; 286 | return ptr; 287 | } 288 | Image* LoadImage_pointerized( char * fileName){ 289 | Image* ptr = malloc(sizeof(Image)); 290 | Image ret = LoadImage(fileName); 291 | *ptr = ret; 292 | return ptr; 293 | } 294 | Image* LoadImageRaw_pointerized( char * fileName, int width, int height, int format, int headerSize){ 295 | Image* ptr = malloc(sizeof(Image)); 296 | Image ret = LoadImageRaw(fileName, width, height, format, headerSize); 297 | *ptr = ret; 298 | return ptr; 299 | } 300 | Image* LoadImageAnim_pointerized( char * fileName, int * frames){ 301 | Image* ptr = malloc(sizeof(Image)); 302 | Image ret = LoadImageAnim(fileName, frames); 303 | *ptr = ret; 304 | return ptr; 305 | } 306 | Image* LoadImageAnimFromMemory_pointerized( char * fileType, char * fileData, int dataSize, int * frames){ 307 | Image* ptr = malloc(sizeof(Image)); 308 | Image ret = LoadImageAnimFromMemory(fileType, fileData, dataSize, frames); 309 | *ptr = ret; 310 | return ptr; 311 | } 312 | Image* LoadImageFromMemory_pointerized( char * fileType, char * fileData, int dataSize){ 313 | Image* ptr = malloc(sizeof(Image)); 314 | Image ret = LoadImageFromMemory(fileType, fileData, dataSize); 315 | *ptr = ret; 316 | return ptr; 317 | } 318 | Image* LoadImageFromTexture_pointerized(Texture2D* texture){ 319 | Image* ptr = malloc(sizeof(Image)); 320 | Image ret = LoadImageFromTexture(*texture); 321 | *ptr = ret; 322 | return ptr; 323 | } 324 | Image* LoadImageFromScreen_pointerized(){ 325 | Image* ptr = malloc(sizeof(Image)); 326 | Image ret = LoadImageFromScreen(); 327 | *ptr = ret; 328 | return ptr; 329 | } 330 | bool IsImageValid_pointerized(Image* image){ return IsImageValid(*image); } 331 | void UnloadImage_pointerized(Image* image){ UnloadImage(*image); } 332 | bool ExportImage_pointerized(Image* image, char * fileName){ return ExportImage(*image, fileName); } 333 | char* ExportImageToMemory_pointerized(Image* image, char * fileType, int * fileSize){ return ExportImageToMemory(*image, fileType, fileSize); } 334 | bool ExportImageAsCode_pointerized(Image* image, char * fileName){ return ExportImageAsCode(*image, fileName); } 335 | Image* GenImageColor_pointerized(int width, int height, Color* color){ 336 | Image* ptr = malloc(sizeof(Image)); 337 | Image ret = GenImageColor(width, height, *color); 338 | *ptr = ret; 339 | return ptr; 340 | } 341 | Image* GenImageGradientLinear_pointerized(int width, int height, int direction, Color* start, Color* end){ 342 | Image* ptr = malloc(sizeof(Image)); 343 | Image ret = GenImageGradientLinear(width, height, direction, *start, *end); 344 | *ptr = ret; 345 | return ptr; 346 | } 347 | Image* GenImageGradientRadial_pointerized(int width, int height, float density, Color* inner, Color* outer){ 348 | Image* ptr = malloc(sizeof(Image)); 349 | Image ret = GenImageGradientRadial(width, height, density, *inner, *outer); 350 | *ptr = ret; 351 | return ptr; 352 | } 353 | Image* GenImageGradientSquare_pointerized(int width, int height, float density, Color* inner, Color* outer){ 354 | Image* ptr = malloc(sizeof(Image)); 355 | Image ret = GenImageGradientSquare(width, height, density, *inner, *outer); 356 | *ptr = ret; 357 | return ptr; 358 | } 359 | Image* GenImageChecked_pointerized(int width, int height, int checksX, int checksY, Color* col1, Color* col2){ 360 | Image* ptr = malloc(sizeof(Image)); 361 | Image ret = GenImageChecked(width, height, checksX, checksY, *col1, *col2); 362 | *ptr = ret; 363 | return ptr; 364 | } 365 | Image* GenImageWhiteNoise_pointerized(int width, int height, float factor){ 366 | Image* ptr = malloc(sizeof(Image)); 367 | Image ret = GenImageWhiteNoise(width, height, factor); 368 | *ptr = ret; 369 | return ptr; 370 | } 371 | Image* GenImagePerlinNoise_pointerized(int width, int height, int offsetX, int offsetY, float scale){ 372 | Image* ptr = malloc(sizeof(Image)); 373 | Image ret = GenImagePerlinNoise(width, height, offsetX, offsetY, scale); 374 | *ptr = ret; 375 | return ptr; 376 | } 377 | Image* GenImageCellular_pointerized(int width, int height, int tileSize){ 378 | Image* ptr = malloc(sizeof(Image)); 379 | Image ret = GenImageCellular(width, height, tileSize); 380 | *ptr = ret; 381 | return ptr; 382 | } 383 | Image* GenImageText_pointerized(int width, int height, char * text){ 384 | Image* ptr = malloc(sizeof(Image)); 385 | Image ret = GenImageText(width, height, text); 386 | *ptr = ret; 387 | return ptr; 388 | } 389 | Image* ImageCopy_pointerized(Image* image){ 390 | Image* ptr = malloc(sizeof(Image)); 391 | Image ret = ImageCopy(*image); 392 | *ptr = ret; 393 | return ptr; 394 | } 395 | Image* ImageFromImage_pointerized(Image* image, Rectangle* rec){ 396 | Image* ptr = malloc(sizeof(Image)); 397 | Image ret = ImageFromImage(*image, *rec); 398 | *ptr = ret; 399 | return ptr; 400 | } 401 | Image* ImageFromChannel_pointerized(Image* image, int selectedChannel){ 402 | Image* ptr = malloc(sizeof(Image)); 403 | Image ret = ImageFromChannel(*image, selectedChannel); 404 | *ptr = ret; 405 | return ptr; 406 | } 407 | Image* ImageText_pointerized( char * text, int fontSize, Color* color){ 408 | Image* ptr = malloc(sizeof(Image)); 409 | Image ret = ImageText(text, fontSize, *color); 410 | *ptr = ret; 411 | return ptr; 412 | } 413 | Image* ImageTextEx_pointerized(Font* font, char * text, float fontSize, float spacing, Color* tint){ 414 | Image* ptr = malloc(sizeof(Image)); 415 | Image ret = ImageTextEx(*font, text, fontSize, spacing, *tint); 416 | *ptr = ret; 417 | return ptr; 418 | } 419 | void ImageToPOT_pointerized( Image * image, Color* fill){ ImageToPOT(image, *fill); } 420 | void ImageCrop_pointerized( Image * image, Rectangle* crop){ ImageCrop(image, *crop); } 421 | void ImageAlphaClear_pointerized( Image * image, Color* color, float threshold){ ImageAlphaClear(image, *color, threshold); } 422 | void ImageAlphaMask_pointerized( Image * image, Image* alphaMask){ ImageAlphaMask(image, *alphaMask); } 423 | void ImageResizeCanvas_pointerized( Image * image, int newWidth, int newHeight, int offsetX, int offsetY, Color* fill){ ImageResizeCanvas(image, newWidth, newHeight, offsetX, offsetY, *fill); } 424 | void ImageColorTint_pointerized( Image * image, Color* color){ ImageColorTint(image, *color); } 425 | void ImageColorReplace_pointerized( Image * image, Color* color, Color* replace){ ImageColorReplace(image, *color, *replace); } 426 | Color* LoadImageColors_pointerized(Image* image){ return LoadImageColors(*image); } 427 | Color* LoadImagePalette_pointerized(Image* image, int maxPaletteSize, int * colorCount){ return LoadImagePalette(*image, maxPaletteSize, colorCount); } 428 | Rectangle* GetImageAlphaBorder_pointerized(Image* image, float threshold){ 429 | Rectangle* ptr = malloc(sizeof(Rectangle)); 430 | Rectangle ret = GetImageAlphaBorder(*image, threshold); 431 | *ptr = ret; 432 | return ptr; 433 | } 434 | Color* GetImageColor_pointerized(Image* image, int x, int y){ 435 | Color* ptr = malloc(sizeof(Color)); 436 | Color ret = GetImageColor(*image, x, y); 437 | *ptr = ret; 438 | return ptr; 439 | } 440 | void ImageClearBackground_pointerized( Image * dst, Color* color){ ImageClearBackground(dst, *color); } 441 | void ImageDrawPixel_pointerized( Image * dst, int posX, int posY, Color* color){ ImageDrawPixel(dst, posX, posY, *color); } 442 | void ImageDrawPixelV_pointerized( Image * dst, Vector2* position, Color* color){ ImageDrawPixelV(dst, *position, *color); } 443 | void ImageDrawLine_pointerized( Image * dst, int startPosX, int startPosY, int endPosX, int endPosY, Color* color){ ImageDrawLine(dst, startPosX, startPosY, endPosX, endPosY, *color); } 444 | void ImageDrawLineV_pointerized( Image * dst, Vector2* start, Vector2* end, Color* color){ ImageDrawLineV(dst, *start, *end, *color); } 445 | void ImageDrawLineEx_pointerized( Image * dst, Vector2* start, Vector2* end, int thick, Color* color){ ImageDrawLineEx(dst, *start, *end, thick, *color); } 446 | void ImageDrawCircle_pointerized( Image * dst, int centerX, int centerY, int radius, Color* color){ ImageDrawCircle(dst, centerX, centerY, radius, *color); } 447 | void ImageDrawCircleV_pointerized( Image * dst, Vector2* center, int radius, Color* color){ ImageDrawCircleV(dst, *center, radius, *color); } 448 | void ImageDrawCircleLines_pointerized( Image * dst, int centerX, int centerY, int radius, Color* color){ ImageDrawCircleLines(dst, centerX, centerY, radius, *color); } 449 | void ImageDrawCircleLinesV_pointerized( Image * dst, Vector2* center, int radius, Color* color){ ImageDrawCircleLinesV(dst, *center, radius, *color); } 450 | void ImageDrawRectangle_pointerized( Image * dst, int posX, int posY, int width, int height, Color* color){ ImageDrawRectangle(dst, posX, posY, width, height, *color); } 451 | void ImageDrawRectangleV_pointerized( Image * dst, Vector2* position, Vector2* size, Color* color){ ImageDrawRectangleV(dst, *position, *size, *color); } 452 | void ImageDrawRectangleRec_pointerized( Image * dst, Rectangle* rec, Color* color){ ImageDrawRectangleRec(dst, *rec, *color); } 453 | void ImageDrawRectangleLines_pointerized( Image * dst, Rectangle* rec, int thick, Color* color){ ImageDrawRectangleLines(dst, *rec, thick, *color); } 454 | void ImageDrawTriangle_pointerized( Image * dst, Vector2* v1, Vector2* v2, Vector2* v3, Color* color){ ImageDrawTriangle(dst, *v1, *v2, *v3, *color); } 455 | void ImageDrawTriangleEx_pointerized( Image * dst, Vector2* v1, Vector2* v2, Vector2* v3, Color* c1, Color* c2, Color* c3){ ImageDrawTriangleEx(dst, *v1, *v2, *v3, *c1, *c2, *c3); } 456 | void ImageDrawTriangleLines_pointerized( Image * dst, Vector2* v1, Vector2* v2, Vector2* v3, Color* color){ ImageDrawTriangleLines(dst, *v1, *v2, *v3, *color); } 457 | void ImageDrawTriangleFan_pointerized( Image * dst, Vector2 * points, int pointCount, Color* color){ ImageDrawTriangleFan(dst, points, pointCount, *color); } 458 | void ImageDrawTriangleStrip_pointerized( Image * dst, Vector2 * points, int pointCount, Color* color){ ImageDrawTriangleStrip(dst, points, pointCount, *color); } 459 | void ImageDraw_pointerized( Image * dst, Image* src, Rectangle* srcRec, Rectangle* dstRec, Color* tint){ ImageDraw(dst, *src, *srcRec, *dstRec, *tint); } 460 | void ImageDrawText_pointerized( Image * dst, char * text, int posX, int posY, int fontSize, Color* color){ ImageDrawText(dst, text, posX, posY, fontSize, *color); } 461 | void ImageDrawTextEx_pointerized( Image * dst, Font* font, char * text, Vector2* position, float fontSize, float spacing, Color* tint){ ImageDrawTextEx(dst, *font, text, *position, fontSize, spacing, *tint); } 462 | Texture2D* LoadTexture_pointerized( char * fileName){ 463 | Texture2D* ptr = malloc(sizeof(Texture2D)); 464 | Texture2D ret = LoadTexture(fileName); 465 | *ptr = ret; 466 | return ptr; 467 | } 468 | Texture2D* LoadTextureFromImage_pointerized(Image* image){ 469 | Texture2D* ptr = malloc(sizeof(Texture2D)); 470 | Texture2D ret = LoadTextureFromImage(*image); 471 | *ptr = ret; 472 | return ptr; 473 | } 474 | TextureCubemap* LoadTextureCubemap_pointerized(Image* image, int layout){ 475 | TextureCubemap* ptr = malloc(sizeof(TextureCubemap)); 476 | TextureCubemap ret = LoadTextureCubemap(*image, layout); 477 | *ptr = ret; 478 | return ptr; 479 | } 480 | RenderTexture2D* LoadRenderTexture_pointerized(int width, int height){ 481 | RenderTexture2D* ptr = malloc(sizeof(RenderTexture2D)); 482 | RenderTexture2D ret = LoadRenderTexture(width, height); 483 | *ptr = ret; 484 | return ptr; 485 | } 486 | bool IsTextureValid_pointerized(Texture2D* texture){ return IsTextureValid(*texture); } 487 | void UnloadTexture_pointerized(Texture2D* texture){ UnloadTexture(*texture); } 488 | bool IsRenderTextureValid_pointerized(RenderTexture2D* target){ return IsRenderTextureValid(*target); } 489 | void UnloadRenderTexture_pointerized(RenderTexture2D* target){ UnloadRenderTexture(*target); } 490 | void UpdateTexture_pointerized(Texture2D* texture, void * pixels){ UpdateTexture(*texture, pixels); } 491 | void UpdateTextureRec_pointerized(Texture2D* texture, Rectangle* rec, void * pixels){ UpdateTextureRec(*texture, *rec, pixels); } 492 | void SetTextureFilter_pointerized(Texture2D* texture, int filter){ SetTextureFilter(*texture, filter); } 493 | void SetTextureWrap_pointerized(Texture2D* texture, int wrap){ SetTextureWrap(*texture, wrap); } 494 | void DrawTexture_pointerized(Texture2D* texture, int posX, int posY, Color* tint){ DrawTexture(*texture, posX, posY, *tint); } 495 | void DrawTextureV_pointerized(Texture2D* texture, Vector2* position, Color* tint){ DrawTextureV(*texture, *position, *tint); } 496 | void DrawTextureEx_pointerized(Texture2D* texture, Vector2* position, float rotation, float scale, Color* tint){ DrawTextureEx(*texture, *position, rotation, scale, *tint); } 497 | void DrawTextureRec_pointerized(Texture2D* texture, Rectangle* source, Vector2* position, Color* tint){ DrawTextureRec(*texture, *source, *position, *tint); } 498 | void DrawTexturePro_pointerized(Texture2D* texture, Rectangle* source, Rectangle* dest, Vector2* origin, float rotation, Color* tint){ DrawTexturePro(*texture, *source, *dest, *origin, rotation, *tint); } 499 | void DrawTextureNPatch_pointerized(Texture2D* texture, NPatchInfo* nPatchInfo, Rectangle* dest, Vector2* origin, float rotation, Color* tint){ DrawTextureNPatch(*texture, *nPatchInfo, *dest, *origin, rotation, *tint); } 500 | bool ColorIsEqual_pointerized(Color* col1, Color* col2){ return ColorIsEqual(*col1, *col2); } 501 | Color* Fade_pointerized(Color* color, float alpha){ 502 | Color* ptr = malloc(sizeof(Color)); 503 | Color ret = Fade(*color, alpha); 504 | *ptr = ret; 505 | return ptr; 506 | } 507 | int ColorToInt_pointerized(Color* color){ return ColorToInt(*color); } 508 | Vector4* ColorNormalize_pointerized(Color* color){ 509 | Vector4* ptr = malloc(sizeof(Vector4)); 510 | Vector4 ret = ColorNormalize(*color); 511 | *ptr = ret; 512 | return ptr; 513 | } 514 | Color* ColorFromNormalized_pointerized(Vector4* normalized){ 515 | Color* ptr = malloc(sizeof(Color)); 516 | Color ret = ColorFromNormalized(*normalized); 517 | *ptr = ret; 518 | return ptr; 519 | } 520 | Vector3* ColorToHSV_pointerized(Color* color){ 521 | Vector3* ptr = malloc(sizeof(Vector3)); 522 | Vector3 ret = ColorToHSV(*color); 523 | *ptr = ret; 524 | return ptr; 525 | } 526 | Color* ColorFromHSV_pointerized(float hue, float saturation, float value){ 527 | Color* ptr = malloc(sizeof(Color)); 528 | Color ret = ColorFromHSV(hue, saturation, value); 529 | *ptr = ret; 530 | return ptr; 531 | } 532 | Color* ColorTint_pointerized(Color* color, Color* tint){ 533 | Color* ptr = malloc(sizeof(Color)); 534 | Color ret = ColorTint(*color, *tint); 535 | *ptr = ret; 536 | return ptr; 537 | } 538 | Color* ColorBrightness_pointerized(Color* color, float factor){ 539 | Color* ptr = malloc(sizeof(Color)); 540 | Color ret = ColorBrightness(*color, factor); 541 | *ptr = ret; 542 | return ptr; 543 | } 544 | Color* ColorContrast_pointerized(Color* color, float contrast){ 545 | Color* ptr = malloc(sizeof(Color)); 546 | Color ret = ColorContrast(*color, contrast); 547 | *ptr = ret; 548 | return ptr; 549 | } 550 | Color* ColorAlpha_pointerized(Color* color, float alpha){ 551 | Color* ptr = malloc(sizeof(Color)); 552 | Color ret = ColorAlpha(*color, alpha); 553 | *ptr = ret; 554 | return ptr; 555 | } 556 | Color* ColorAlphaBlend_pointerized(Color* dst, Color* src, Color* tint){ 557 | Color* ptr = malloc(sizeof(Color)); 558 | Color ret = ColorAlphaBlend(*dst, *src, *tint); 559 | *ptr = ret; 560 | return ptr; 561 | } 562 | Color* ColorLerp_pointerized(Color* color1, Color* color2, float factor){ 563 | Color* ptr = malloc(sizeof(Color)); 564 | Color ret = ColorLerp(*color1, *color2, factor); 565 | *ptr = ret; 566 | return ptr; 567 | } 568 | Color* GetColor_pointerized(int hexValue){ 569 | Color* ptr = malloc(sizeof(Color)); 570 | Color ret = GetColor(hexValue); 571 | *ptr = ret; 572 | return ptr; 573 | } 574 | Color* GetPixelColor_pointerized( void * srcPtr, int format){ 575 | Color* ptr = malloc(sizeof(Color)); 576 | Color ret = GetPixelColor(srcPtr, format); 577 | *ptr = ret; 578 | return ptr; 579 | } 580 | void SetPixelColor_pointerized( void * dstPtr, Color* color, int format){ SetPixelColor(dstPtr, *color, format); } 581 | Font* GetFontDefault_pointerized(){ 582 | Font* ptr = malloc(sizeof(Font)); 583 | Font ret = GetFontDefault(); 584 | *ptr = ret; 585 | return ptr; 586 | } 587 | Font* LoadFont_pointerized( char * fileName){ 588 | Font* ptr = malloc(sizeof(Font)); 589 | Font ret = LoadFont(fileName); 590 | *ptr = ret; 591 | return ptr; 592 | } 593 | Font* LoadFontEx_pointerized( char * fileName, int fontSize, int * codepoints, int codepointCount){ 594 | Font* ptr = malloc(sizeof(Font)); 595 | Font ret = LoadFontEx(fileName, fontSize, codepoints, codepointCount); 596 | *ptr = ret; 597 | return ptr; 598 | } 599 | Font* LoadFontFromImage_pointerized(Image* image, Color* key, int firstChar){ 600 | Font* ptr = malloc(sizeof(Font)); 601 | Font ret = LoadFontFromImage(*image, *key, firstChar); 602 | *ptr = ret; 603 | return ptr; 604 | } 605 | Font* LoadFontFromMemory_pointerized( char * fileType, char * fileData, int dataSize, int fontSize, int * codepoints, int codepointCount){ 606 | Font* ptr = malloc(sizeof(Font)); 607 | Font ret = LoadFontFromMemory(fileType, fileData, dataSize, fontSize, codepoints, codepointCount); 608 | *ptr = ret; 609 | return ptr; 610 | } 611 | bool IsFontValid_pointerized(Font* font){ return IsFontValid(*font); } 612 | Image* GenImageFontAtlas_pointerized( GlyphInfo * glyphs, Rectangle * * glyphRecs, int glyphCount, int fontSize, int padding, int packMethod){ 613 | Image* ptr = malloc(sizeof(Image)); 614 | Image ret = GenImageFontAtlas(glyphs, glyphRecs, glyphCount, fontSize, padding, packMethod); 615 | *ptr = ret; 616 | return ptr; 617 | } 618 | void UnloadFont_pointerized(Font* font){ UnloadFont(*font); } 619 | bool ExportFontAsCode_pointerized(Font* font, char * fileName){ return ExportFontAsCode(*font, fileName); } 620 | void DrawText_pointerized( char * text, int posX, int posY, int fontSize, Color* color){ DrawText(text, posX, posY, fontSize, *color); } 621 | void DrawTextEx_pointerized(Font* font, char * text, Vector2* position, float fontSize, float spacing, Color* tint){ DrawTextEx(*font, text, *position, fontSize, spacing, *tint); } 622 | void DrawTextPro_pointerized(Font* font, char * text, Vector2* position, Vector2* origin, float rotation, float fontSize, float spacing, Color* tint){ DrawTextPro(*font, text, *position, *origin, rotation, fontSize, spacing, *tint); } 623 | void DrawTextCodepoint_pointerized(Font* font, int codepoint, Vector2* position, float fontSize, Color* tint){ DrawTextCodepoint(*font, codepoint, *position, fontSize, *tint); } 624 | void DrawTextCodepoints_pointerized(Font* font, int * codepoints, int codepointCount, Vector2* position, float fontSize, float spacing, Color* tint){ DrawTextCodepoints(*font, codepoints, codepointCount, *position, fontSize, spacing, *tint); } 625 | Vector2* MeasureTextEx_pointerized(Font* font, char * text, float fontSize, float spacing){ 626 | Vector2* ptr = malloc(sizeof(Vector2)); 627 | Vector2 ret = MeasureTextEx(*font, text, fontSize, spacing); 628 | *ptr = ret; 629 | return ptr; 630 | } 631 | int GetGlyphIndex_pointerized(Font* font, int codepoint){ return GetGlyphIndex(*font, codepoint); } 632 | GlyphInfo* GetGlyphInfo_pointerized(Font* font, int codepoint){ 633 | GlyphInfo* ptr = malloc(sizeof(GlyphInfo)); 634 | GlyphInfo ret = GetGlyphInfo(*font, codepoint); 635 | *ptr = ret; 636 | return ptr; 637 | } 638 | Rectangle* GetGlyphAtlasRec_pointerized(Font* font, int codepoint){ 639 | Rectangle* ptr = malloc(sizeof(Rectangle)); 640 | Rectangle ret = GetGlyphAtlasRec(*font, codepoint); 641 | *ptr = ret; 642 | return ptr; 643 | } 644 | void DrawLine3D_pointerized(Vector3* startPos, Vector3* endPos, Color* color){ DrawLine3D(*startPos, *endPos, *color); } 645 | void DrawPoint3D_pointerized(Vector3* position, Color* color){ DrawPoint3D(*position, *color); } 646 | void DrawCircle3D_pointerized(Vector3* center, float radius, Vector3* rotationAxis, float rotationAngle, Color* color){ DrawCircle3D(*center, radius, *rotationAxis, rotationAngle, *color); } 647 | void DrawTriangle3D_pointerized(Vector3* v1, Vector3* v2, Vector3* v3, Color* color){ DrawTriangle3D(*v1, *v2, *v3, *color); } 648 | void DrawTriangleStrip3D_pointerized( Vector3 * points, int pointCount, Color* color){ DrawTriangleStrip3D(points, pointCount, *color); } 649 | void DrawCube_pointerized(Vector3* position, float width, float height, float length, Color* color){ DrawCube(*position, width, height, length, *color); } 650 | void DrawCubeV_pointerized(Vector3* position, Vector3* size, Color* color){ DrawCubeV(*position, *size, *color); } 651 | void DrawCubeWires_pointerized(Vector3* position, float width, float height, float length, Color* color){ DrawCubeWires(*position, width, height, length, *color); } 652 | void DrawCubeWiresV_pointerized(Vector3* position, Vector3* size, Color* color){ DrawCubeWiresV(*position, *size, *color); } 653 | void DrawSphere_pointerized(Vector3* centerPos, float radius, Color* color){ DrawSphere(*centerPos, radius, *color); } 654 | void DrawSphereEx_pointerized(Vector3* centerPos, float radius, int rings, int slices, Color* color){ DrawSphereEx(*centerPos, radius, rings, slices, *color); } 655 | void DrawSphereWires_pointerized(Vector3* centerPos, float radius, int rings, int slices, Color* color){ DrawSphereWires(*centerPos, radius, rings, slices, *color); } 656 | void DrawCylinder_pointerized(Vector3* position, float radiusTop, float radiusBottom, float height, int slices, Color* color){ DrawCylinder(*position, radiusTop, radiusBottom, height, slices, *color); } 657 | void DrawCylinderEx_pointerized(Vector3* startPos, Vector3* endPos, float startRadius, float endRadius, int sides, Color* color){ DrawCylinderEx(*startPos, *endPos, startRadius, endRadius, sides, *color); } 658 | void DrawCylinderWires_pointerized(Vector3* position, float radiusTop, float radiusBottom, float height, int slices, Color* color){ DrawCylinderWires(*position, radiusTop, radiusBottom, height, slices, *color); } 659 | void DrawCylinderWiresEx_pointerized(Vector3* startPos, Vector3* endPos, float startRadius, float endRadius, int sides, Color* color){ DrawCylinderWiresEx(*startPos, *endPos, startRadius, endRadius, sides, *color); } 660 | void DrawCapsule_pointerized(Vector3* startPos, Vector3* endPos, float radius, int slices, int rings, Color* color){ DrawCapsule(*startPos, *endPos, radius, slices, rings, *color); } 661 | void DrawCapsuleWires_pointerized(Vector3* startPos, Vector3* endPos, float radius, int slices, int rings, Color* color){ DrawCapsuleWires(*startPos, *endPos, radius, slices, rings, *color); } 662 | void DrawPlane_pointerized(Vector3* centerPos, Vector2* size, Color* color){ DrawPlane(*centerPos, *size, *color); } 663 | void DrawRay_pointerized(Ray* ray, Color* color){ DrawRay(*ray, *color); } 664 | Model* LoadModel_pointerized( char * fileName){ 665 | Model* ptr = malloc(sizeof(Model)); 666 | Model ret = LoadModel(fileName); 667 | *ptr = ret; 668 | return ptr; 669 | } 670 | Model* LoadModelFromMesh_pointerized(Mesh* mesh){ 671 | Model* ptr = malloc(sizeof(Model)); 672 | Model ret = LoadModelFromMesh(*mesh); 673 | *ptr = ret; 674 | return ptr; 675 | } 676 | bool IsModelValid_pointerized(Model* model){ return IsModelValid(*model); } 677 | void UnloadModel_pointerized(Model* model){ UnloadModel(*model); } 678 | BoundingBox* GetModelBoundingBox_pointerized(Model* model){ 679 | BoundingBox* ptr = malloc(sizeof(BoundingBox)); 680 | BoundingBox ret = GetModelBoundingBox(*model); 681 | *ptr = ret; 682 | return ptr; 683 | } 684 | void DrawModel_pointerized(Model* model, Vector3* position, float scale, Color* tint){ DrawModel(*model, *position, scale, *tint); } 685 | void DrawModelEx_pointerized(Model* model, Vector3* position, Vector3* rotationAxis, float rotationAngle, Vector3* scale, Color* tint){ DrawModelEx(*model, *position, *rotationAxis, rotationAngle, *scale, *tint); } 686 | void DrawModelWires_pointerized(Model* model, Vector3* position, float scale, Color* tint){ DrawModelWires(*model, *position, scale, *tint); } 687 | void DrawModelWiresEx_pointerized(Model* model, Vector3* position, Vector3* rotationAxis, float rotationAngle, Vector3* scale, Color* tint){ DrawModelWiresEx(*model, *position, *rotationAxis, rotationAngle, *scale, *tint); } 688 | void DrawModelPoints_pointerized(Model* model, Vector3* position, float scale, Color* tint){ DrawModelPoints(*model, *position, scale, *tint); } 689 | void DrawModelPointsEx_pointerized(Model* model, Vector3* position, Vector3* rotationAxis, float rotationAngle, Vector3* scale, Color* tint){ DrawModelPointsEx(*model, *position, *rotationAxis, rotationAngle, *scale, *tint); } 690 | void DrawBoundingBox_pointerized(BoundingBox* box, Color* color){ DrawBoundingBox(*box, *color); } 691 | void DrawBillboard_pointerized(Camera* camera, Texture2D* texture, Vector3* position, float scale, Color* tint){ DrawBillboard(*camera, *texture, *position, scale, *tint); } 692 | void DrawBillboardRec_pointerized(Camera* camera, Texture2D* texture, Rectangle* source, Vector3* position, Vector2* size, Color* tint){ DrawBillboardRec(*camera, *texture, *source, *position, *size, *tint); } 693 | void DrawBillboardPro_pointerized(Camera* camera, Texture2D* texture, Rectangle* source, Vector3* position, Vector3* up, Vector2* size, Vector2* origin, float rotation, Color* tint){ DrawBillboardPro(*camera, *texture, *source, *position, *up, *size, *origin, rotation, *tint); } 694 | void UpdateMeshBuffer_pointerized(Mesh* mesh, int index, void * data, int dataSize, int offset){ UpdateMeshBuffer(*mesh, index, data, dataSize, offset); } 695 | void UnloadMesh_pointerized(Mesh* mesh){ UnloadMesh(*mesh); } 696 | void DrawMesh_pointerized(Mesh* mesh, Material* material, Matrix* transform){ DrawMesh(*mesh, *material, *transform); } 697 | void DrawMeshInstanced_pointerized(Mesh* mesh, Material* material, Matrix * transforms, int instances){ DrawMeshInstanced(*mesh, *material, transforms, instances); } 698 | BoundingBox* GetMeshBoundingBox_pointerized(Mesh* mesh){ 699 | BoundingBox* ptr = malloc(sizeof(BoundingBox)); 700 | BoundingBox ret = GetMeshBoundingBox(*mesh); 701 | *ptr = ret; 702 | return ptr; 703 | } 704 | bool ExportMesh_pointerized(Mesh* mesh, char * fileName){ return ExportMesh(*mesh, fileName); } 705 | bool ExportMeshAsCode_pointerized(Mesh* mesh, char * fileName){ return ExportMeshAsCode(*mesh, fileName); } 706 | Mesh* GenMeshPoly_pointerized(int sides, float radius){ 707 | Mesh* ptr = malloc(sizeof(Mesh)); 708 | Mesh ret = GenMeshPoly(sides, radius); 709 | *ptr = ret; 710 | return ptr; 711 | } 712 | Mesh* GenMeshPlane_pointerized(float width, float length, int resX, int resZ){ 713 | Mesh* ptr = malloc(sizeof(Mesh)); 714 | Mesh ret = GenMeshPlane(width, length, resX, resZ); 715 | *ptr = ret; 716 | return ptr; 717 | } 718 | Mesh* GenMeshCube_pointerized(float width, float height, float length){ 719 | Mesh* ptr = malloc(sizeof(Mesh)); 720 | Mesh ret = GenMeshCube(width, height, length); 721 | *ptr = ret; 722 | return ptr; 723 | } 724 | Mesh* GenMeshSphere_pointerized(float radius, int rings, int slices){ 725 | Mesh* ptr = malloc(sizeof(Mesh)); 726 | Mesh ret = GenMeshSphere(radius, rings, slices); 727 | *ptr = ret; 728 | return ptr; 729 | } 730 | Mesh* GenMeshHemiSphere_pointerized(float radius, int rings, int slices){ 731 | Mesh* ptr = malloc(sizeof(Mesh)); 732 | Mesh ret = GenMeshHemiSphere(radius, rings, slices); 733 | *ptr = ret; 734 | return ptr; 735 | } 736 | Mesh* GenMeshCylinder_pointerized(float radius, float height, int slices){ 737 | Mesh* ptr = malloc(sizeof(Mesh)); 738 | Mesh ret = GenMeshCylinder(radius, height, slices); 739 | *ptr = ret; 740 | return ptr; 741 | } 742 | Mesh* GenMeshCone_pointerized(float radius, float height, int slices){ 743 | Mesh* ptr = malloc(sizeof(Mesh)); 744 | Mesh ret = GenMeshCone(radius, height, slices); 745 | *ptr = ret; 746 | return ptr; 747 | } 748 | Mesh* GenMeshTorus_pointerized(float radius, float size, int radSeg, int sides){ 749 | Mesh* ptr = malloc(sizeof(Mesh)); 750 | Mesh ret = GenMeshTorus(radius, size, radSeg, sides); 751 | *ptr = ret; 752 | return ptr; 753 | } 754 | Mesh* GenMeshKnot_pointerized(float radius, float size, int radSeg, int sides){ 755 | Mesh* ptr = malloc(sizeof(Mesh)); 756 | Mesh ret = GenMeshKnot(radius, size, radSeg, sides); 757 | *ptr = ret; 758 | return ptr; 759 | } 760 | Mesh* GenMeshHeightmap_pointerized(Image* heightmap, Vector3* size){ 761 | Mesh* ptr = malloc(sizeof(Mesh)); 762 | Mesh ret = GenMeshHeightmap(*heightmap, *size); 763 | *ptr = ret; 764 | return ptr; 765 | } 766 | Mesh* GenMeshCubicmap_pointerized(Image* cubicmap, Vector3* cubeSize){ 767 | Mesh* ptr = malloc(sizeof(Mesh)); 768 | Mesh ret = GenMeshCubicmap(*cubicmap, *cubeSize); 769 | *ptr = ret; 770 | return ptr; 771 | } 772 | Material* LoadMaterialDefault_pointerized(){ 773 | Material* ptr = malloc(sizeof(Material)); 774 | Material ret = LoadMaterialDefault(); 775 | *ptr = ret; 776 | return ptr; 777 | } 778 | bool IsMaterialValid_pointerized(Material* material){ return IsMaterialValid(*material); } 779 | void UnloadMaterial_pointerized(Material* material){ UnloadMaterial(*material); } 780 | void SetMaterialTexture_pointerized( Material * material, int mapType, Texture2D* texture){ SetMaterialTexture(material, mapType, *texture); } 781 | void UpdateModelAnimation_pointerized(Model* model, ModelAnimation* anim, int frame){ UpdateModelAnimation(*model, *anim, frame); } 782 | void UpdateModelAnimationBones_pointerized(Model* model, ModelAnimation* anim, int frame){ UpdateModelAnimationBones(*model, *anim, frame); } 783 | void UnloadModelAnimation_pointerized(ModelAnimation* anim){ UnloadModelAnimation(*anim); } 784 | bool IsModelAnimationValid_pointerized(Model* model, ModelAnimation* anim){ return IsModelAnimationValid(*model, *anim); } 785 | bool CheckCollisionSpheres_pointerized(Vector3* center1, float radius1, Vector3* center2, float radius2){ return CheckCollisionSpheres(*center1, radius1, *center2, radius2); } 786 | bool CheckCollisionBoxes_pointerized(BoundingBox* box1, BoundingBox* box2){ return CheckCollisionBoxes(*box1, *box2); } 787 | bool CheckCollisionBoxSphere_pointerized(BoundingBox* box, Vector3* center, float radius){ return CheckCollisionBoxSphere(*box, *center, radius); } 788 | RayCollision* GetRayCollisionSphere_pointerized(Ray* ray, Vector3* center, float radius){ 789 | RayCollision* ptr = malloc(sizeof(RayCollision)); 790 | RayCollision ret = GetRayCollisionSphere(*ray, *center, radius); 791 | *ptr = ret; 792 | return ptr; 793 | } 794 | RayCollision* GetRayCollisionBox_pointerized(Ray* ray, BoundingBox* box){ 795 | RayCollision* ptr = malloc(sizeof(RayCollision)); 796 | RayCollision ret = GetRayCollisionBox(*ray, *box); 797 | *ptr = ret; 798 | return ptr; 799 | } 800 | RayCollision* GetRayCollisionMesh_pointerized(Ray* ray, Mesh* mesh, Matrix* transform){ 801 | RayCollision* ptr = malloc(sizeof(RayCollision)); 802 | RayCollision ret = GetRayCollisionMesh(*ray, *mesh, *transform); 803 | *ptr = ret; 804 | return ptr; 805 | } 806 | RayCollision* GetRayCollisionTriangle_pointerized(Ray* ray, Vector3* p1, Vector3* p2, Vector3* p3){ 807 | RayCollision* ptr = malloc(sizeof(RayCollision)); 808 | RayCollision ret = GetRayCollisionTriangle(*ray, *p1, *p2, *p3); 809 | *ptr = ret; 810 | return ptr; 811 | } 812 | RayCollision* GetRayCollisionQuad_pointerized(Ray* ray, Vector3* p1, Vector3* p2, Vector3* p3, Vector3* p4){ 813 | RayCollision* ptr = malloc(sizeof(RayCollision)); 814 | RayCollision ret = GetRayCollisionQuad(*ray, *p1, *p2, *p3, *p4); 815 | *ptr = ret; 816 | return ptr; 817 | } 818 | Wave* LoadWave_pointerized( char * fileName){ 819 | Wave* ptr = malloc(sizeof(Wave)); 820 | Wave ret = LoadWave(fileName); 821 | *ptr = ret; 822 | return ptr; 823 | } 824 | Wave* LoadWaveFromMemory_pointerized( char * fileType, char * fileData, int dataSize){ 825 | Wave* ptr = malloc(sizeof(Wave)); 826 | Wave ret = LoadWaveFromMemory(fileType, fileData, dataSize); 827 | *ptr = ret; 828 | return ptr; 829 | } 830 | bool IsWaveValid_pointerized(Wave* wave){ return IsWaveValid(*wave); } 831 | Sound* LoadSound_pointerized( char * fileName){ 832 | Sound* ptr = malloc(sizeof(Sound)); 833 | Sound ret = LoadSound(fileName); 834 | *ptr = ret; 835 | return ptr; 836 | } 837 | Sound* LoadSoundFromWave_pointerized(Wave* wave){ 838 | Sound* ptr = malloc(sizeof(Sound)); 839 | Sound ret = LoadSoundFromWave(*wave); 840 | *ptr = ret; 841 | return ptr; 842 | } 843 | Sound* LoadSoundAlias_pointerized(Sound* source){ 844 | Sound* ptr = malloc(sizeof(Sound)); 845 | Sound ret = LoadSoundAlias(*source); 846 | *ptr = ret; 847 | return ptr; 848 | } 849 | bool IsSoundValid_pointerized(Sound* sound){ return IsSoundValid(*sound); } 850 | void UpdateSound_pointerized(Sound* sound, void * data, int sampleCount){ UpdateSound(*sound, data, sampleCount); } 851 | void UnloadWave_pointerized(Wave* wave){ UnloadWave(*wave); } 852 | void UnloadSound_pointerized(Sound* sound){ UnloadSound(*sound); } 853 | void UnloadSoundAlias_pointerized(Sound* alias){ UnloadSoundAlias(*alias); } 854 | bool ExportWave_pointerized(Wave* wave, char * fileName){ return ExportWave(*wave, fileName); } 855 | bool ExportWaveAsCode_pointerized(Wave* wave, char * fileName){ return ExportWaveAsCode(*wave, fileName); } 856 | void PlaySound_pointerized(Sound* sound){ PlaySound(*sound); } 857 | void StopSound_pointerized(Sound* sound){ StopSound(*sound); } 858 | void PauseSound_pointerized(Sound* sound){ PauseSound(*sound); } 859 | void ResumeSound_pointerized(Sound* sound){ ResumeSound(*sound); } 860 | bool IsSoundPlaying_pointerized(Sound* sound){ return IsSoundPlaying(*sound); } 861 | void SetSoundVolume_pointerized(Sound* sound, float volume){ SetSoundVolume(*sound, volume); } 862 | void SetSoundPitch_pointerized(Sound* sound, float pitch){ SetSoundPitch(*sound, pitch); } 863 | void SetSoundPan_pointerized(Sound* sound, float pan){ SetSoundPan(*sound, pan); } 864 | Wave* WaveCopy_pointerized(Wave* wave){ 865 | Wave* ptr = malloc(sizeof(Wave)); 866 | Wave ret = WaveCopy(*wave); 867 | *ptr = ret; 868 | return ptr; 869 | } 870 | float* LoadWaveSamples_pointerized(Wave* wave){ return LoadWaveSamples(*wave); } 871 | Music* LoadMusicStream_pointerized( char * fileName){ 872 | Music* ptr = malloc(sizeof(Music)); 873 | Music ret = LoadMusicStream(fileName); 874 | *ptr = ret; 875 | return ptr; 876 | } 877 | Music* LoadMusicStreamFromMemory_pointerized( char * fileType, char * data, int dataSize){ 878 | Music* ptr = malloc(sizeof(Music)); 879 | Music ret = LoadMusicStreamFromMemory(fileType, data, dataSize); 880 | *ptr = ret; 881 | return ptr; 882 | } 883 | bool IsMusicValid_pointerized(Music* music){ return IsMusicValid(*music); } 884 | void UnloadMusicStream_pointerized(Music* music){ UnloadMusicStream(*music); } 885 | void PlayMusicStream_pointerized(Music* music){ PlayMusicStream(*music); } 886 | bool IsMusicStreamPlaying_pointerized(Music* music){ return IsMusicStreamPlaying(*music); } 887 | void UpdateMusicStream_pointerized(Music* music){ UpdateMusicStream(*music); } 888 | void StopMusicStream_pointerized(Music* music){ StopMusicStream(*music); } 889 | void PauseMusicStream_pointerized(Music* music){ PauseMusicStream(*music); } 890 | void ResumeMusicStream_pointerized(Music* music){ ResumeMusicStream(*music); } 891 | void SeekMusicStream_pointerized(Music* music, float position){ SeekMusicStream(*music, position); } 892 | void SetMusicVolume_pointerized(Music* music, float volume){ SetMusicVolume(*music, volume); } 893 | void SetMusicPitch_pointerized(Music* music, float pitch){ SetMusicPitch(*music, pitch); } 894 | void SetMusicPan_pointerized(Music* music, float pan){ SetMusicPan(*music, pan); } 895 | float GetMusicTimeLength_pointerized(Music* music){ return GetMusicTimeLength(*music); } 896 | float GetMusicTimePlayed_pointerized(Music* music){ return GetMusicTimePlayed(*music); } 897 | AudioStream* LoadAudioStream_pointerized(int sampleRate, int sampleSize, int channels){ 898 | AudioStream* ptr = malloc(sizeof(AudioStream)); 899 | AudioStream ret = LoadAudioStream(sampleRate, sampleSize, channels); 900 | *ptr = ret; 901 | return ptr; 902 | } 903 | bool IsAudioStreamValid_pointerized(AudioStream* stream){ return IsAudioStreamValid(*stream); } 904 | void UnloadAudioStream_pointerized(AudioStream* stream){ UnloadAudioStream(*stream); } 905 | void UpdateAudioStream_pointerized(AudioStream* stream, void * data, int frameCount){ UpdateAudioStream(*stream, data, frameCount); } 906 | bool IsAudioStreamProcessed_pointerized(AudioStream* stream){ return IsAudioStreamProcessed(*stream); } 907 | void PlayAudioStream_pointerized(AudioStream* stream){ PlayAudioStream(*stream); } 908 | void PauseAudioStream_pointerized(AudioStream* stream){ PauseAudioStream(*stream); } 909 | void ResumeAudioStream_pointerized(AudioStream* stream){ ResumeAudioStream(*stream); } 910 | bool IsAudioStreamPlaying_pointerized(AudioStream* stream){ return IsAudioStreamPlaying(*stream); } 911 | void StopAudioStream_pointerized(AudioStream* stream){ StopAudioStream(*stream); } 912 | void SetAudioStreamVolume_pointerized(AudioStream* stream, float volume){ SetAudioStreamVolume(*stream, volume); } 913 | void SetAudioStreamPitch_pointerized(AudioStream* stream, float pitch){ SetAudioStreamPitch(*stream, pitch); } 914 | void SetAudioStreamPan_pointerized(AudioStream* stream, float pan){ SetAudioStreamPan(*stream, pan); } 915 | void SetAudioStreamCallback_pointerized(AudioStream* stream, AudioCallback callback){ SetAudioStreamCallback(*stream, callback); } 916 | void AttachAudioStreamProcessor_pointerized(AudioStream* stream, AudioCallback processor){ AttachAudioStreamProcessor(*stream, processor); } 917 | void DetachAudioStreamProcessor_pointerized(AudioStream* stream, AudioCallback processor){ DetachAudioStreamProcessor(*stream, processor); } 918 | --------------------------------------------------------------------------------