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-rl
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
$ 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_32
windows targetting windows
you're on your own. good luck.
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
.
$ 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=0
with-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-rl
ovm.c
+ raylib.c
)
into ol-rl
implement api.md
fully
implement raymath-api.md
fully
##false Exported values:
draw
with-window
with-mainloop
vec
(vec2 a b)
(vec3 a b c)
(vec4 a b c d)
make-vector
rec
rectangle
rect
(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-camera2d
with-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:
colors
lightgray
gray
darkgray
yellow
gold
orange
pink
red
maroon
green
lime
darkgreen
skyblue
blue
darkblue
purple
violet
darkpurple
beige
brown
darkbrown
white
black
blank
magenta
raywhite
window-flags
flag-vsync-hint
flag-fullscreen-mode
flag-window-resizable
flag-window-undecorated
flag-window-hidden
flag-window-minimized
flag-window-maximized
flag-window-unfocused
flag-window-topmost
flag-window-always-run
flag-window-transparent
flag-window-highdpi
flag-window-mouse-passthrough
flag-borderless-windowed-mode
flag-msaa-4x-hint
flag-interlaced-hint
log-all
log-trace
log-debug
log-info
log-warning
log-error
log-fatal
log-none
key-null
key-apostrophe
key-comma
key-minus
key-period
key-slash
key-zero
key-one
key-two
key-three
key-four
key-five
key-six
key-seven
key-eight
key-nine
key-semicolon
key-equal
key-a
key-b
key-c
key-d
key-e
key-f
key-g
key-h
key-i
key-j
key-k
key-l
key-m
key-n
key-o
key-p
key-q
key-r
key-s
key-t
key-u
key-v
key-w
key-x
key-y
key-z
key-left-bracket
key-backslash
key-right-bracket
key-grave
key-space
key-escape
key-enter
key-tab
key-backspace
key-insert
key-delete
key-right
key-left
key-down
key-up
key-page-up
key-page-down
key-home
key-end
key-caps-lock
key-scroll-lock
key-num-lock
key-print-screen
key-pause
key-f1
key-f2
key-f3
key-f4
key-f5
key-f6
key-f7
key-f8
key-f9
key-f10
key-f11
key-f12
key-left-shift
key-left-control
key-left-alt
key-left-super
key-right-shift
key-right-control
key-right-alt
key-right-super
key-kb-menu
key-kp-0
key-kp-1
key-kp-2
key-kp-3
key-kp-4
key-kp-5
key-kp-6
key-kp-7
key-kp-8
key-kp-9
key-kp-decimal
key-kp-divide
key-kp-multiply
key-kp-subtract
key-kp-add
key-kp-enter
key-kp-equal
key-back
key-menu
key-volume-up
key-volume-down
mouse-button-left
mouse-button-right
mouse-button-middle
mouse-button-side
mouse-button-extra
mouse-button-forward
mouse-button-back
mouse-left-button
mouse-right-button
mouse-middle-button
mouse-cursor-default
mouse-cursor-arrow
mouse-cursor-ibeam
mouse-cursor-crosshair
mouse-cursor-pointing-hand
mouse-cursor-resize-ew
mouse-cursor-resize-ns
mouse-cursor-resize-nwse
mouse-cursor-resize-nesw
mouse-cursor-resize-all
mouse-cursor-not-allowed
gamepad-button-unknown
gamepad-button-left-face-up
gamepad-button-left-face-right
gamepad-button-left-face-down
gamepad-button-left-face-left
gamepad-button-right-face-up
gamepad-button-right-face-right
gamepad-button-right-face-down
gamepad-button-right-face-left
gamepad-button-left-trigger-1
gamepad-button-left-trigger-2
gamepad-button-right-trigger-1
gamepad-button-right-trigger-2
gamepad-button-middle-left
gamepad-button-middle
gamepad-button-middle-right
gamepad-button-left-thumb
gamepad-button-right-thumb
gamepad-axis-left-x
gamepad-axis-left-y
gamepad-axis-right-x
gamepad-axis-right-y
gamepad-axis-left-trigger
gamepad-axis-right-trigger
gesture-none
gesture-tap
gesture-doubletap
gesture-hold
gesture-drag
gesture-swipe-right
gesture-swipe-left
gesture-swipe-up
gesture-swipe-down
gesture-pinch-in
gesture-pinch-out
camera-custom
camera-free
camera-orbital
camera-first-person
camera-third-person
camera-perspective
camera-orthographic
texture-filter-point
texture-filter-bilinear
texture-filter-trilinear
texture-filter-anisotropic-4x
texture-filter-anisotropic-8x
texture-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-colors
image-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-stream
list->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-pixel
draw-rectangle
draw-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-triangle
draw-triangle-lines
draw-triangle-fan
draw-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