Quick notes on using CEPL on macOS

Datetime:2016-08-23 05:12:13          Topic: Lisp           Share

16 Aug 2016

Just jotting down some notes while trying to get CEPL working on my oldish MacBook Pro running El Capitan.

  • Use SBCL. I usually default to ClozureCL, but for the moment I can’t get swank:*communication-style* nil to work with it, and things will just break horribly if you end up off the main thread in CEPL. SBCL works fine.
  • To make sure that Swank starts up with the right communication style, I stuck this in ~/.swank.lisp : #+sbcl (setf swank:*communication-style* nil)
  • My (old) Macs only support up to version 3.3 OpenGL contexts, but the version of CEPL that’s available in Quicklisp uses 4.1 contexts. The current HEAD on Github lets you choose your context version, so you’ll need to clone the CEPL repository and some of its dependencies locally in your Quicklisp local-projects directory. (list below)
  • Download the runtime frameworks for SDL2 and SDL2_image and stick them in ~/Libraries/Frameworks .
  • I’m haven’t been able to get the examples running directly yet: it seems like cepl.sdl2’s host step function is getting clobbered by the one in cepl.skitter.sdl2, so you need to avoid loading that.

Repositories you’ll need to clone locally:

  • cepl - https://github.com/cbaggers/cepl.git
  • cepl.sdl2 - https://github.com/cbaggers/cepl.sdl2.git
  • cepl.skitter - https://github.com/cbaggers/cepl.skitter.git
  • rtg-math - https://github.com/cbaggers/rtg-math.git
  • varjo - https://github.com/cbaggers/varjo.git

Actually running it in SLIME:

  • Once you have your .swank.lisp set up, and Emacs configured to use SBCL, start SLIME as normal. (e.g. M-x slime)
  • Load cepl.sdl2: (ql:quickload "cepl.sdl2")
  • Initialize CEPL, passing it a window size and the OpenGL context version you need: (cepl:repl 480 320 3.3)
  • If everything went well, you should have a blank, untitled window somewhere on your desktop, probably behind your Emacs window. Clicking on the SBCL icon on your dock won’t bring it forward, you’ll have to go looking for it.

Again, I can’t get the examples to run directly, but you can run the triangle example below by:

  • Loading livesupport: (ql:quickload "livesupport") . The examples use it to keep your REPL usable while Swank is in single-threaded mode.
  • Load the example listed below.
  • Run (triangle::run-loop) to start it, and hit enter an extra time to get your REPL back.
  • Run (triangle::stop-loop) to stop it.
(in-package :cl-user)
(defpackage :triangle
  (:use #:cl #:cepl #:livesupport))

(in-package :triangle)

(defparameter *array* nil)
(defparameter *stream* nil)
(defparameter *running* nil)

(defstruct-g pos-col
  (position :vec3 :accessor pos)
  (color :vec4 :accessor col))

(defun-g tri-vert ((vert pos-col))
  (values (v! (pos vert) 1.0)
          (col vert)))

(defun-g tri-frag ((color :vec4))
  color)

(def-g-> prog-1 ()
  tri-vert tri-frag)

(defun step-demo ()
  (step-host)
  (update-repl-link)
  (clear)
  (map-g #'prog-1 *stream*)
  (swap))

(defun run-loop ()
  (setf *running* t
        *array* (make-gpu-array (list (list (v!  0.5 -0.36 0) (v! 0 1 0 1))
                                      (list (v!    0   0.5 0) (v! 1 0 0 1))
                                      (list (v! -0.5 -0.36 0) (v! 0 0 1 1)))
                                :element-type 'pos-col)
        *stream* (make-buffer-stream *array*))
  (loop :while (and *running* (not (shutting-down-p))) :do
     (continuable (step-demo))))

(defun stop-loop ()
  (setf *running* nil))




About List