3 ms·
I don't know about CEPL but when just using OpenGL you can simply redefine functions that are called in the main thread and they will execute there. You build u
by ffwacom 6y ago
I don't know about CEPL but when just using OpenGL you can simply redefine functions that are called in the main thread and they will execute there. You build up a lot of indirection to allow redefining things at run time.
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.