Minimal Fennel setup for Raylib using the LuaJIT-based binding via raylib-lua.
- Compiled binaries from the raylib-lua project available on the
system's path:
raylua_s
for script-mode programsraylua_e
for embedding-mode programs
Run the example program as a script:
$ raylua_s main.lua
Compile the example program to an executable binary:
$ mkdir -p target
$ cp fennel.lua main.lua main.fnl target
$ raylua_e target
$ ./target_out
The raylib-lua project does most of the heavy-lifting to create
Lua programs using the Raylib game library. Embedding the Fennel compiler into
the Lua program is a thin, extra layer on top of the stack. With the release of
Fennel 1.2.1, you can add the following one-liner to extend
Lua's built-in require
function to also support Fennel. (See Fennel's API
documentation and this section from the Setup
Guide.)
-- main.lua
require("fennel").install().dofile("main.fnl")
The above line in the main.lua
file loads the example main.fnl
code:
;; main.fnl
(rl.SetConfigFlags rl.FLAG_VSYNC_HINT)
(rl.InitWindow 800 450 "raylib [core] example - basic window")
(while (not (rl.WindowShouldClose))
(rl.BeginDrawing)
(rl.ClearBackground rl.RAYWHITE)
(rl.DrawText "Congrats! You created your first window!" 190 200 20 rl.LIGHTGRAY)
(rl.EndDrawing))
(rl.CloseWindow)
Raylib-lua automatically binds the Raylib C APIs to the global
rl
table. You can learn the Raylib APIs from the Raylib cheatsheet.
I'd like to keep this project minimal like ~benthor
's repo -
absolutely-minimal-love2d-fennel. So I
almost consider this project done. However, I do want to start other projects
to explore the REPL support and how much I can push the interactive programming
workflow based on the current setup.
- Raylib
- alexjgriffith/min-love2d-fennel - I've learned a lot from this project template about Fennel and Love2d.
- ~benthor/absolutely-minimal-love2d-fennel for explaining in details the absolute minimal setup for a Fennel Love2d project.
- MattRoelle/minimal-raylib-lua-fennel for inspiring this experimental project.