WIP raylib bindings for owl lisp
api.md imported (and tweaked a bit) from janet-lang/jaylib, it is probably a bit outdated.
- raylib from @master - tested on f1007554a0a8145060797c0aa8169bdaf2c1c6b8
- GNU sed - BSD one may not work
- GNU make
Owl lisp supports C extensions via custom sys-prims - basically
syscalls, but to C functions, not the system. You define a
word prim_custom(int op, word a, word b, word c)
in a C file,
then call (sys-prim op a b c)
from the lisp side, and then compile
and link them together.
ol-rl
is the same thing as ol
, but with compiled-in support for
raylib sys-prim
s, so it will be then used to interpret and/or
compile Owl lisp programs that depend on raylib.
$ make all
# make install
- unix
$ ol-rl -o test.c test.scm
$ cc test.c -lraylib -lm -o test
$ ./test
- unix targetting windows
$ wget https://pub.krzysckh.org/ol-rl.exe
$ wget https://pub.krzysckh.org/libraylib5-winlegacy.a
$ wine ol-rl.exe -o test-w32.c test.scm
$ i686-w64-mingw32-gcc -static -o test.exe -I/usr/local/include test-w32.c -L. -l:libraylib5-winlegacy.a -lm -lopengl32 -lwinmm -lgdi32 -lws2_32
-
windows targetting windows (the easy way)
Pre-compiled
libraylib5-winlegacy.a
andol-rl.exe
are targetted at 32-bit systems. They will run just fine on 64-bit MS windows, but you should keep the 32-bitness in mind.- download x86 w64devkit from https://github.com/skeeto/w64devkit/releases/tag/v2.0.0
- launch
w64devkit.exe
and do the following:
$ wget https://pub.krzysckh.org/ol-rl.exe
$ wget https://pub.krzysckh.org/libraylib5-winlegacy.a
$ git clone https://github.com/raysan5/raylib
$ ol-rl.exe -o filename.c filename.scm
$ i686-w64-mingw32-gcc -static -o filename.exe -Iraylib/src filename.c -L. -lraylib5-winlegacy -lm -lopengl32 -lwinmm -lgdi32 -lws2_32
# if you don't want the console to appear when filename.exe is launched, append -mwindows to the last command
If you're on windows, you can download the pre-compiled ol-rl.exe
binary
here. If running it as a REPL, remember
to use --no-readline
.
- compile raylib targetting web, or use this pre-compiled binary
$ git clone https://github.com/raysan5/raylib
$ cd raylib/src
$ make clean all PLATFORM=PLATFORM_WEB
- compile your code for web
$ ol-rl -o test.c test.scm
$ emcc -DPLATFORM_WEB -I/usr/local/include test.c /path/to/libraylib-web.a -o test.html -s USE_GLFW=3 -s ERROR_ON_UNDEFINED_SYMBOLS=0 -s ALLOW_MEMORY_GROWTH=1 -s ASYNCIFY -s ASSERTIONS=0
- Remember, that everything that can be evaluated at compile-time, will probably be evaluated at compile time. This can be used to embed files, or as a footgun.
- Remember, that there is no mutable data. For "variables", that may change
depending on frames, scrap the
with-mainloop
macro, and define Your ownmainloop
function, that tail-recurses into itself, and sets the "variables" as arguments. - There is no type checking. You're on your own.
- The c code sucks, and i need to come up with some better api for writing extensions, but for now - it is what it is.
- You can treat the source code as the docs, because this is (for now) not good.
- Good luck.
- ol-rl
- works
- embed
(raylib)
- the lisp sources - intool-rl
- embed the raylib runtime (
ovm.c
+raylib.c
) intool-rl
- implement
api.md
fully - implement
raymath-api.md
fully