Graphical applications with raylib on 9front 2

This is a continuation of this post.

I recently also ported raylib-owl to run on 9front. It utilizes raylib9, as described in the previous article, alongside a port of owl lisp.

Installation

; hget https://pub.krzysckh.org/raylib9-owl.tgz | tar xvz
; cd raylib9-owl
; build.rc
; cp bin/ol-rl $home/bin/$objtype/ol-rl

if compilation gets stuck on re-building until a fixed point is reached - kill the process and re-build.rc it.

Usage

This is a sample Owl lisp program demonstrating basics of raylib.

(import
 (owl toplevel)
 (owl random)
 (prefix (owl sys) sys/)
 (raylib))

(define *width* 400)
(define *height* 400)

(define colors (vector red green blue))
(define n-glendas 150)

(define (eeper)
  (sleep 1000)
  (mail 'threadmain #t)
  (eeper))

(define (init-glendas)
  (let loop ((r (seed->rands 42)) (acc ()))
    (if (= (length acc) n-glendas) acc
        (lets ((r x (rand-range r 0 *width*))
               (r y (rand-range r 0 *height*)))
      (loop r (append acc (list (list x y))))))))

(define (main args)
  (with-window
   *width* *height* "a window"
   (let* ((pngdata (file->list "/tmp/g.png"))
          (g (image->texture (list->image ".png" pngdata))))
     (let loop ((n 0) (gs (init-glendas)))
       (let ((n (if (check-mail) (modulo (+ n 1) (vector-length colors)) n)))
         (draw
          (clear-background (vector-ref colors n))
          (for-each (lambda (pos) (draw-texture g pos red)) gs)
          (draw-fps '(0 370))
          (draw-text-simple "Hello" '(0 0) 22 white))
         (next-thread)
         (if (window-should-close?)
             (catch-thread null)
             (loop n (map (lambda (l) (list (car l) (modulo (+ 1 (cadr l)) *height*)))
                          gs))))))))

(lambda (args)
  (sys/system '("/bin/rc" "-c" "topng < /lib/face/48x48x4/g/glenda.1 > /tmp/g.png"))
  (thread 'eeper (eeper))
  (thread 'threadmain (main args)))
; ol-rl -r file.scm

Limitations Bugs

same as the c version plus