2024-07-24 Gridmapper Local

I was wondering whether I should get back to Gridmapper, but not using Javascript and the web but using Common Lisp. I spent some time on this two years ago. Of course by now I have forgotten everything – like how to build it!

two years ago

This is the Makefile that seems to work, given that I have both `gridmapper.asd` and `gridmapper.lisp` in the current directory.

SHELL = /bin/sh
LISP ?= sbcl --non-interactive
PWD   = $(shell pwd)

build:
	$(LISP) --eval '(asdf:load-asd "$(PWD)/gridmapper.asd")' \
	--eval '(asdf:load-system :gridmapper)' \
	--eval '(asdf:make :gridmapper)' \
	--eval '(quit)'

Surely there is a better way to do this?

If I replace `(asdf:load-system :gridmapper)` with `(ql:quickload :gridmapper)` it no longer gives me a warning about `cl-colors.asd` which I don't know anything about. I guess the warning is still preferable because it means no dependency on Quicklisp? I have no idea. The README comes with a long explanation of what to install and how to do it, in order to build Gridmapper – including the use of Quicklisp.

README

The hairiest part is that I need access to a function that isn't exported from the Cairo package. So now I'm accessing the private function (using two colons):

;; Sorry for the ugly hack… cairo_format_stride_for_width is not exported.
(cairo::cairo_format_stride_for_width :CAIRO_FORMAT_ARGB32 (surface-width surface)))))

Two years ago, there was a different solution to this that apparently no longer works. 🤷

​#Common Lisp

Using the browser as a universal user-interface is a pretty cool idea! Even if the application itself is a stand-alone program that can act as a web-server (like Oddmu), all the hard parts are abstracted away: line-breaks, hyphenation, spell-checking when writing. Perhaps using the canvas is hard? But using the DOM and SVG is something I've done countless times and by now I know my way around.

Oddmu

Sigh.

I suspect something like the following is required for every symbol that I want to use:

(defun render-fill-rect (&rest args) (apply 'HU.DWIM.SDL.FFI::|SDL_RenderFillRect| args))

And then take a look at the arguments. The other SDL2 binding already has this.

`rect.lisp` defines these:

(defun make-rect (x y w h)
  "Allocate and return a new SDL_Rect filled in with the arguments."
  (c-let ((rect sdl2-ffi:sdl-rect))
    (setf (rect :x) x
          (rect :y) y
          (rect :w) w
          (rect :h) h)
    rect))

(define-struct-accessors (rect sdl2-ffi:sdl-rect)
  :x :y (width :w) (height :h))

`render.lisp` defines this:

(defun render-fill-rect (renderer sdl-rect)
  "Use this function to fill a rectangle on the current rendering target with
the drawing color. "
  (check-rc (sdl2-ffi.functions:sdl-render-fill-rect renderer sdl-rect)))

So I am between a rock and a hard place. The SDL2 bindings I had were pretty good. They don't come with bindings for SDL2/gfx so I would I need to do the missing legwork myself. Which I could do.

Or I could stick with Javascript and the web.

Sadly, the situation for the Cairo library doesn't appear to be much better. The function `format-stride-for-width` is not exported and I suspect nobody is actively working on the library. My issue has no reaction since Jul 20, 2022.

My issue