WIP raylib bindings for owl lisp
api.md imported (and tweaked a bit) from janet-lang/jaylib, it is probably a bit outdated.
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-rlol-rl is the same thing as ol, but with
compiled-in support for raylib sys-prims, so it will be
then used to interpret and/or compile Owl lisp programs that depend on
raylib.
$ make all
# make install$ ol-rl -o test.c test.scm
$ cc test.c -lraylib -lm -o test
$ ./test$ 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_32windows targetting windows (the easy way)
Pre-compiled libraylib5-winlegacy.a and
ol-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.
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 commandIf 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.
$ git clone https://github.com/raysan5/raylib
$ cd raylib/src
$ make clean all PLATFORM=PLATFORM_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=0with-mainloop macro,
and define Your own mainloop function, that tail-recurses
into itself, and sets the "variables" as arguments.ol-rl
(raylib) - the lisp sources - into
ol-rlovm.c + raylib.c)
into ol-rl
implement api.md fully
implement raymath-api.md fully
##false Exported values:
drawwith-windowwith-mainloopvec(vec2 a b)(vec3 a b c)(vec4 a b c d)make-vectorrecrectanglerect(exports (raylib window))(exports (raylib io))(exports (raylib draw))(exports (raylib util))(exports (raylib audio))(exports (raylib const))(exports (raylib raymath))(exports (raylib image))##false Exported values:
(maybe-bytevectorize lst)(prim n . vs)##false Exported values:
(init-window width height title)(window-should-close?)(close-window)(window-ready?)(window-minimized?)(window-resized?)(window-state? flag)(set-window-state! flags)(clear-window-state! flags)(toggle-fullscreen!)(set-window-icon! image)(set-window-title! title)(set-window-position! x y)(set-window-monitor! monitor)(set-window-min-size! w h)(set-window-size! w h)(window-handle)(window-width)(window-height)(window-size)(monitor-count)(monitor-width monitor)(monitor-height monitor)(monitor-size monitor)(monitor-physical-width monitor)(monitor-physical-height monitor)(monitor-name monitor)(clipboard)(set-clipboard! text)(show-cursor!)(hide-cursor!)(cursor-hidden?)(enable-cursor!)(disable-cursor!)(cursor-on-screen?)(clear-background color)(begin-drawing)(end-drawing)(make-camera2d offset target rot zoom)(begin-mode2d cam)(end-mode2d)(set-target-fps! fps)(fps)(frame-time)(time)(color-normalize c)(color->hsv c)color->number(fade c alpha)(make-color r g b a)color(set-config-flags! f)(set-tracelog-level! l)(take-screenshot! path)(dropped-files)(open-url url)(begin-camera2d-mode offset target rotation zoom)(end-camera2d-mode)(window-fullscreen?)(window-hidden?)(window-maximized?)(window-focused?)(toggle-borderless-windowed)(window-maximize)(window-minimize)(window-restore)(set-window-icons! icons)(set-window-max-size! w h)(set-window-opacity! flt)(set-window-focused!)(render-width)(render-height)(render-size)(current-monitor)(monitor-position n)(monitor-refresh-rate n)(window-position)(window-scale-dpi)(enable-event-waiting!)(disable-event-waiting!)(begin-scissor-mode x y w h)(end-scissor-mode)(swap-screen-buffer)(poll-input-events)(wait-time t)(set-random-seed! s)(random-value min max)(random-sequence N min max)(set-mouse-cursor! c)with-camera2dwith-scissors##false Exported values:
(collision-rects? rec1 rec2)(collision-circles? c1 rad1 c2 rad2)(collision-circle-rect? center rad rect)(collision-rects rec1 rec2)(collision-point-rect? pt rect)(collision-point-circle? pt center rad)collision-point-triangle?(truncate-precision n . max-precision)##false Exported values:
(clamp val min max)(lerp start end amount)(normalize value start end)(remap value istart iend ostart oend)(wrap val min max)(vec2zero)(vec2one)(vec2+ v1 v2)(vec2+val v add)(vec2- v1 v2)(vec2-val v sub)(vec2length v)(vec2lensqr v)(vec2dotprod v1 v2)(vec2dist v1 v2)(vec2distsqr v1 v2)(vec2angle v1 v2)(vec2lineangle v1 v2)(vec2scale v scale)(vec2* v1 v2)(vec2negate v)(vec2/ v1 v2)(vec2normalize v)(vec2lerp v1 v2 amount)(vec2reflect v normal)(vec2min v1 v2)(vec2max v1 v2)(vec2rotate v angle)(vec2move-towards v target max-dist)(vec2invert v)(vec2clamp v min max)(vec2clampvalue v min max)(vec2eq? p q)(vec2refract v n r)##false Exported values:
colorslightgraygraydarkgrayyellowgoldorangepinkredmaroongreenlimedarkgreenskybluebluedarkbluepurplevioletdarkpurplebeigebrowndarkbrownwhiteblackblankmagentaraywhitewindow-flagsflag-vsync-hintflag-fullscreen-modeflag-window-resizableflag-window-undecoratedflag-window-hiddenflag-window-minimizedflag-window-maximizedflag-window-unfocusedflag-window-topmostflag-window-always-runflag-window-transparentflag-window-highdpiflag-window-mouse-passthroughflag-borderless-windowed-modeflag-msaa-4x-hintflag-interlaced-hintlog-alllog-tracelog-debuglog-infolog-warninglog-errorlog-fatallog-nonekey-nullkey-apostrophekey-commakey-minuskey-periodkey-slashkey-zerokey-onekey-twokey-threekey-fourkey-fivekey-sixkey-sevenkey-eightkey-ninekey-semicolonkey-equalkey-akey-bkey-ckey-dkey-ekey-fkey-gkey-hkey-ikey-jkey-kkey-lkey-mkey-nkey-okey-pkey-qkey-rkey-skey-tkey-ukey-vkey-wkey-xkey-ykey-zkey-left-bracketkey-backslashkey-right-bracketkey-gravekey-spacekey-escapekey-enterkey-tabkey-backspacekey-insertkey-deletekey-rightkey-leftkey-downkey-upkey-page-upkey-page-downkey-homekey-endkey-caps-lockkey-scroll-lockkey-num-lockkey-print-screenkey-pausekey-f1key-f2key-f3key-f4key-f5key-f6key-f7key-f8key-f9key-f10key-f11key-f12key-left-shiftkey-left-controlkey-left-altkey-left-superkey-right-shiftkey-right-controlkey-right-altkey-right-superkey-kb-menukey-kp-0key-kp-1key-kp-2key-kp-3key-kp-4key-kp-5key-kp-6key-kp-7key-kp-8key-kp-9key-kp-decimalkey-kp-dividekey-kp-multiplykey-kp-subtractkey-kp-addkey-kp-enterkey-kp-equalkey-backkey-menukey-volume-upkey-volume-downmouse-button-leftmouse-button-rightmouse-button-middlemouse-button-sidemouse-button-extramouse-button-forwardmouse-button-backmouse-left-buttonmouse-right-buttonmouse-middle-buttonmouse-cursor-defaultmouse-cursor-arrowmouse-cursor-ibeammouse-cursor-crosshairmouse-cursor-pointing-handmouse-cursor-resize-ewmouse-cursor-resize-nsmouse-cursor-resize-nwsemouse-cursor-resize-neswmouse-cursor-resize-allmouse-cursor-not-allowedgamepad-button-unknowngamepad-button-left-face-upgamepad-button-left-face-rightgamepad-button-left-face-downgamepad-button-left-face-leftgamepad-button-right-face-upgamepad-button-right-face-rightgamepad-button-right-face-downgamepad-button-right-face-leftgamepad-button-left-trigger-1gamepad-button-left-trigger-2gamepad-button-right-trigger-1gamepad-button-right-trigger-2gamepad-button-middle-leftgamepad-button-middlegamepad-button-middle-rightgamepad-button-left-thumbgamepad-button-right-thumbgamepad-axis-left-xgamepad-axis-left-ygamepad-axis-right-xgamepad-axis-right-ygamepad-axis-left-triggergamepad-axis-right-triggergesture-nonegesture-tapgesture-doubletapgesture-holdgesture-draggesture-swipe-rightgesture-swipe-leftgesture-swipe-upgesture-swipe-downgesture-pinch-ingesture-pinch-outcamera-customcamera-freecamera-orbitalcamera-first-personcamera-third-personcamera-perspectivecamera-orthographictexture-filter-pointtexture-filter-bilineartexture-filter-trilineartexture-filter-anisotropic-4xtexture-filter-anisotropic-8xtexture-filter-anisotropic-16x##false Exported values:
(image-format img t)(image-to-pot img c)(image-alpha-crop img fl)(image-alpha-clear img c fl)(image-alpha-mask img1 img2)(image-alpha-premultiply i)(image-blur-gaussian i f)(image-resize i w h)(image-resize-nn i w h)(image-mipmaps i)(image-dither i r g b a)(image-flip-v i)(image-flip-h i)(image-rotate i deg)(image-rotate-cw i)(image-rotate-ccw i)(image-color-tint i c)(image-color-invert i)(image-color-grayscale i)(image-color-contrast i flt)(image-color-brightness i n)(image-color-replace i c1 c2)(gen-image-color w h c)(gen-image-gradient-linear w h dir start end)(gen-image-gradient-radial w h density inner outer)(gen-image-gradient-square w h density inner outer)(gen-image-checked w h cx cy c1 c2)(raw-bytevector->image w h bv)make-image(image->list i)(image->list-palette i maxp)image-colorsimage-palette##false Exported values:
(init-audio-device)(close-audio-device)(audio-device-ready?)(set-master-volume! vol)(file->wave fname)load-wave(file->sound fname)load-sound(wave->sound wave)(unload-wave w)(unload-sound s)(wave->file wave fname)(play-sound snd)(pause-sound snd)(resume-sound snd)(stop-sound snd)(sound-playing? snd)(set-sound-volume! snd vol)(set-sound-pitch! snd pitch)(format-wave! wave sample-rate sample-size channels)(copy-wave wave)(crop-wave wave init final)(file->music-stream fname)load-music-stream(unload-music-stream mus)(play-music-stream mus)(update-music-stream mus)(stop-music-stream mus)(pause-music-stream mus)(resume-music-stream mus)(music-stream-playing? mus)(set-music-volume! mus vol)(set-music-pitch! mus pitch)(music-time-length mus)(music-time-played mus)list->music-streamlist->wave(bytevector->music-stream type lst)(bytevector->wave type lst)##false Exported values:
(key-pressed? k)(key-down? k)(key-released? k)(key-up? k)(key-pressed)(char-pressed)(set-exit-key! k)(gamepad-available? n)(gamepad-name n)(gamepad-btn-pressed? n)(gamepad-btn-down? n)(gamepad-btn-released? n)(gamepad-btn-up? n)(gamepad-btn-pressed)(gamepad-axis-count n)(gamepad-axis-movement n axis)(mouse-btn-pressed? b)(mouse-btn-down? b)(mouse-btn-released? b)(mouse-btn-up? b)(mouse-x)(mouse-y)(mouse-pos)(set-mouse-pos! x y)(set-mouse-offset! x y)(set-mouse-scale! sx sy)(mouse-wheel)(touch-x)(touch-y)(touch-pos)(set-gestures-enabled! flags)(gesture-detected? g)(gesture-detected)(touch-points-count)(gesture-hold-duration)(gesture-drag-vector)(gesture-drag-angle)(gesture-pinch-vector)(gesture-pinch-angle)(load-image fname)list->image(bytevector->image type data)(export-image img fname)(load-texture fname)(image->texture img)(load-texture-cubemap fname lt)(unload-image img)(unload-texture txt)(unload-render-texture txt)(screen->image)(get-font-default)load-font(image->font image key first-char)(unload-font f)list->font(bytevector->font lst type font-size n-chars)(mouse-delta)(set-texture-filter! texture filter)##false Exported values:
draw-pixeldraw-rectangledraw-rectangle-lines(draw-line p1 p2 color)(draw-line-simple x1 y1 x2 y2 color)(draw-line-ex p1 p2 thick color)(draw-line-bezier p1 p2 thick color)(draw-line-strip pts color)(draw-circle-sector pos rad start-angle end-angle segments color)(draw-circle-sector-lines pos rad start-angle end-angle segments color)(draw-circle-gradient pos rad color1 color2)(draw-circle pos rad color)(draw-circle-lines pos rad color)(draw-ring center inner-rad outer-rad start-ang end-ang segments color)(draw-ring-lines center inner-rad outer-rad start-ang end-ang segments color)(draw-rectangle-simple x y w h color)(draw-rectangle-gradient-v pos w h col1 col2)(draw-rectangle-gradient-h pos w h col1 col2)(draw-rectangle-gradient-ex rec col1 col2 col3 col4)(draw-rectangle-rounded rect roundness segments color)(draw-rectangle-rounded-lines rect roundness segments color)draw-triangledraw-triangle-linesdraw-triangle-fandraw-triangle-strip(draw-poly center sides radius rot color)draw-texture(draw-texture-ex t pos rot scale tint)(draw-texture-pro t source-rect dest-rect origin rot tint)(draw-texture-rec t rect pos tint)draw-fps(draw-text font text pos f-size spacing color)(draw-text-simple text pos font-size color)measure-text