“包GLUT不存在”,即使在Arch Linux中安装了cl-opengl

时间:2013-04-22 21:28:38

标签: lisp common-lisp glut slime sbcl

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

然而,当我尝试在SLIME中编译以下代码时(使用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))

我收到以下错误:

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

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

我做错了什么?

1 个答案:

答案 0 :(得分:3)

ASDF:LOAD-SYSTEM在加载时间之前不会生效,因为它是一个普通的函数。如果希望在编译时发生效果,则必须将其包装在eval-when形式中。但最好写一个:depends-on那些其他系统的系统定义。