1

我已经用 SLIME 配置了 emacs,以便在 Arch Linux 上使用 Common Lisp (sbcl) 进行开发。问题是,我现在也想开始使用 OpenGL,所以我安装了 cl-opengl 来提供必要的绑定。我还在 .local/share/common-lisp 上设置了一个到 /usr/share/common-lisp 的符号链接(我应该能够以这种方式使用 ASDF 加载所有系统)。

但是,当我尝试在 SLIME 中编译以下代码时(使用 Cc Ck)

(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))

我收到以下错误:

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

即使 cl-glut.asd 存在于 /usr/share/common-lisp/systems 中。

我究竟做错了什么?

4

1 回答 1

3

ASDF:LOAD-SYSTEM直到加载时间才生效,因为它是一个简单的函数。如果您希望效果在编译时发生,则必须将其包装在一个eval-when表单中。但是最好编写一个系统定义,而不是:depends-on那些其他系统。

于 2013-04-23T00:51:18.017 回答