1
votes

I have emacs configured with SLIME for developing in Common Lisp (sbcl) on Arch Linux. The thing is, I now want to start working with OpenGL as well, so I've installed cl-opengl to provide the necessary bindings. I have also set up a symlink on .local/share/common-lisp to /usr/share/common-lisp (I should be able to load all systems using ASDF that way).

However, when I try to compile the following code in SLIME (using C-c C-k)

(require :asdf)                 ; need ASDF to load other things
(asdf:load-system :cl-opengl)   ; load OpenGL bindings
(asdf:load-system :cl-glu)      ; load GLU bindings
(asdf:load-system :cl-glut)     ; load GLUT bindings

(defclass my-window (glut:window)
  ()
  (:default-initargs :width 400 :height 300
                     :title "My Window Title"
                     :x 100 :y 100
                     :mode '(:double :rgb :depth)))

(defmethod glut:display-window :before ((win my-window))
  (gl:shade-model :smooth)        ; enables smooth shading
  (gl:clear-color 0 0 0 0)        ; background will be black
  (gl:clear-depth 1)              ; clear buffer to maximum depth
  (gl:enable :depth-test)         ; enable depth testing
  (gl:depth-func :lequal)         ; okay to write pixel if its depth
                                  ; is less-than-or-equal to the
                                  ; depth currently written
                                  ; really nice perspective correction
  (gl:hint :perspective-correction-hint :nicest)
)

(defmethod glut:display ((win my-window))
  (gl:clear :color-buffer-bit :depth-buffer-bit)
  (gl:load-identity))

(defmethod glut:reshape ((win my-window) width height)
  (gl:viewport 0 0 width height)  ; reset the current viewport
  (gl:matrix-mode :projection)    ; select the projection matrix
  (gl:load-identity)              ; reset the matrix

  ;; set perspective based on window aspect ratio
  (glu:perspective 45 (/ width (max height 1)) 1/10 100)
  (gl:matrix-mode :modelview)     ; select the modelview matrix
  (gl:load-identity)              ; reset the matrix
)

(glut:display-window (make-instance 'my-window))

I get the following error:

READ error during COMPILE-FILE:
Package GLUT does not exist.

even though cl-glut.asd exists in /usr/share/common-lisp/systems.

What am I doing wrong?

1

1 Answers

3
votes

ASDF:LOAD-SYSTEM doesn't take effect until load time, since it's a plain function. If you want the effect to happen at compile time, you have to wrap it in an eval-when form. But it's better to write a system definition that :depends-on those other systems.