Raylib LuaJit bindings that are generated from the raylib-parser API docs
-
raylib.hcode-gen to lua usingraylib_api.lua -
rlgl.hcode-gen to lua usingrlgl_api.lua -
raygui.hcode-gen to lua usingraygui_api.lua -
raymath.hcode-gen to lua usingraymath_api.lua -
config.hcode-gen to lua usingconfig_api.lua -
physac.hffi bindings to lua usingphysac.lua
- Simple lua files (except for the compiled Raylib binaries/libraries/header)
- Works as an actual lib instead of a runner
- No build required in order to use this
- Really easy to update
- You need the LuaJIT and Raylib compiled binaries/libraries
- Building a binary to distribute is a chore
- Install Raylib globally. I used
brew install raylibon OSX, or - Download your Raylib release and toss everything from
lib/into the./raylibfolder - Create a file in the root with the following code:
-- save as main.lua -- run with `luajit main.lua` local rl = require('raylib') rl.SetConfigFlags(rl.FLAG_VSYNC_HINT) rl.InitWindow(800, 450, "raylib [core] example - basic window") while not rl.WindowShouldClose() do rl.BeginDrawing() rl.ClearBackground(rl.RAYWHITE) rl.DrawText("Congrats! You created your first window!", 190, 200, 20, rl.LIGHTGRAY) rl.EndDrawing() end rl.CloseWindow() - Run
luajit main.lua
You can build a standalone binary. You can see the details in example-build/build.sh
Examples are pulled from TSnake41/raylib-lua
Run luajit examples/core_basic_window.lua
You can use the Raylib parser to generate .lua files that document the API:
./raylib_parser -i ../src/config.h -f LUA -o config_api.lua ./raylib_parser -i ../src/raylib.h -f LUA -o raylib_api.lua ./raylib_parser -i ../src/raymath.h -f LUA -o raymath_api.lua ./raylib_parser -i ../src/rlgl.h -f LUA -o rlgl_api.lua # requires the raygui in the raylib source folder ./raylib_parser -i ../raygui/src/raygui.h -f LUA -o raygui_api.luaThis is a work in progress as well. It uses regular Lua 5.4 to generate the file. Make sure lpeg is installed. You can install it with luarocks install lpeg.
It is super rough right now but it does work and generates a init.lua file with comments and docblocks!
cd raylib/ luarocks install lpeg lua generate.luaCopy physac.h from victorfisac/Physac to raylib/physac.h.
Create a pyhsac.c in raylib/:
// raylib/physac.c #define PHYSAC_IMPLEMENTATION #define PHYSAC_STANDALONE // from: https://github.com/victorfisac/Physac #include "physac.h"Build the libphysac.dylib:
# Assuming physac.c and libraylib.dylib are accessible (from: https://github.com/victorfisac/Physac) # Use clang (the default C compiler on macOS) cd raylib clang -o ../libphysac.dylib physac.c -dynamiclib \ -I. -I/opt/homebrew/Cellar/raylib/5.5/include/ \ -L/opt/homebrew/Cellar/raylib/5.5/lib/ -lraylib \ -lpthreadThank you to these projects that acted as a reference for this implementation