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.


; hget | 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.


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

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

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

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

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

(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)
   *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)))
          (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))
         (if (window-should-close?)
             (catch-thread null)
             (loop n (map (lambda (l) (list (car l) (modulo (+ 1 (cadr l)) *height*)))

(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