I imagine there are two concurrent threads: one receiving input from the programmer and another running the graphics and window event loop. How do these two communicate? I tried writing something similar as a teenager and the multithreading work quickly overwhelmed me. Perhaps there's a better approach?
It's also a good idea to write some macros to send the forms to the main thread when working with graphics libs.
This in clojure will eval the form once at the desired point in the program, it just queues up the forms and executes one every time it's called. The stuff below is racey but works.
(def eval-points (atom {}))
(defn eval-package
[package]
(binding [*ns* (:ns package)]
(eval (:form package))))
(defmacro eval-point
[name]
(swap! eval-points assoc name [])
`(do (let [fs# (~name @eval-points)]
(when (peek fs#)
(eval-package (peek fs#))
(swap! eval-points assoc ~name (pop fs#))))))
(defmacro package-form
[& form]
`{:ns ~*ns*
:form '(do ~@form)})
(defmacro eval-at
[name & form]
`(swap! eval-points
assoc
~name
(conj (~name @eval-points)
(package-form ~@form))))
So you would place (eval-point :foo) somewhere in the main loop so things like OpenGL calls are possible, then when evaling forms from the REPL you wrap them like:(eval-at :foo (blah 0.3 0.3 0.3))
You can easily do the same in common lisp.
1. As per CL error handling/continuations, if something goes wrong you are dropped into the debugger and can live fix the problem without losing the OpenGL context (usually, I've still found ways to break things of course, since you have some more manual memory management happening with the GPU). CEPL has a 'live continue' feature that handles this for OpenGL/threads.
2. Live changing of code as in usual CL REPL works well. If you want to change stuff on the GPU, like a texture or shader, you may need to repush it to the GPU depending how your main loop draws stuff. For instance, I'll just once set a shader, so if I want to change it I'll need to explicitly update it to the GPU.
Anyway, is all rather great, can't imagine doing this stuff manually like I used to back in the C days and before real GPU programming.
[0] https://github.com/cbaggers/cepl