Skip to content

0riginaln0/fnl-raylib

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Raylib 5.5 bindings for the Fennel programming language for the sake of interest.

Provides full coverage of:

Includes:

  • Built-in Raylib dynamic libraries for Windows and Linux (x64).
  • Lume library
  • 7 examples. Some of them are adaptations of official examples, the rest are custom ones.
  • Makefile for both Windows and Linux

Example

Bindings use kebab-case naming

(local rl (require :lib.raylib))
(local lume (require :lib.lume))

(print "epic")
(-> 4.5
    (lume.round)
    (print))

(rl.init-window 640 640 "Fennel & Raylib")
(rl.set-target-fps 60)
(local background (rl.Color 161 212 242 250))

(while (not (rl.window-should-close))
  (rl.begin-drawing)
  (rl.clear-background background)
  (rl.end-drawing))

(rl.close-window)
(print "That's all")

Requirements

You need to have Luajit and Fennel installed. The main bindings file which you want to import is raylib.fnl.

  • Luajit installation is very easy. Just follow the instructions Windows users read carefully the "Installing LuaJIT" section of the page: "Copy luajit.exe and lua51.dll (built in the src directory)..."
  • Likewise with the Fennel (I install it via the script fennel-1.5.1 version)
fennel.bat script to run Fennel on Windows
@echo off
luajit C:\Games\Fennel\fennel1.5.1 %*

How to start using it

Just git clone this repo, cd fnl-raylib and then

fennel main.fnl

or

make run

or

fennel examples/core/core-input-keys.fnl

or (after make build)

luajit main.lua

or

luajit examples/core/core-input-mouse.lua

you got it.

https://fennel-lang.org/see

https://github.com/raysan5/raylib/tree/master/examples

https://github.com/raysan5/raylib/blob/1f0325b52c87af4820b31957d8e40d7bc1f112bb/src/raylib.h#L183

How to build an executable

Prerequirements

  • gcc compiler
  • (if windows) LuaJIT installation into the C:\ path. (When you installed luajit, you should git clone their repo from the C:\ folder)

Both C compiler and LuaJIT installation path could be tweaked and replaced by yourself!

So how to build an executable?

Run

make release

or if you want to do it manually:

  1. Compile Fennel to Lua
make build
  1. Compile Lua to Bytecode
luajit -b main.lua main.luac
  1. Create a C Wrapper and comile it
  • Linux
gcc -o main main.c -lluajit-5.1
  • Windows:
gcc -o main main.c -I"C:\LuaJIT\src" -L"C:\LuaJIT\src" -l"luajit-5.1"
  1. Run your executable! Test how it works
./main
  1. Package a release

Copy main, main.luac files and lib folder into seperate directory (for example in release)

About

Raylib 5.5 bindings for Fennel

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages