Skip to content

Minimal Fennel setup for Raylib using the LuaJIT-based binding

License

Notifications You must be signed in to change notification settings

dawranliou/minimal-raylib-fennel

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Minimal Fennel Setup for Raylib

Minimal Fennel setup for Raylib using the LuaJIT-based binding via raylib-lua.

Prerequisites

  1. Compiled binaries from the raylib-lua project available on the system's path:
    • raylua_s for script-mode programs
    • raylua_e for embedding-mode programs

Usage

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

Explanation

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.

Next

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.

Credits

About

Minimal Fennel setup for Raylib using the LuaJIT-based binding

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published