【问题标题】:install lispbuilder-sdl on Mac OS X在 Mac OS X 上安装 lispbuilder-sdl
【发布时间】:2016-04-23 03:03:35
【问题描述】:

有人在 Mac OS X 上开发常见的 lisp 游戏吗?最近想在Mac OS X上搭建一个lisp游戏开发,但是卡住了。

Operating System version: 
    ProductName:    Mac OS X
    ProductVersion: 10.11.4
    BuildVersion:   15E65

sbcl version: 
    SBCL 1.3.3

我找到 Github 存储库页面:https://github.com/lispbuilder/lispbuilder/wiki/DownloadInstallation 并按照 OS X 安装部分进行操作。我尝试安装 SDL 1.2 的运行时库和运行时二进制文件以及 SDL 2.0 的开发库。它的行为如下:

当我运行一些在使用 lispbuilder-sdl 的 Linux 上运行良好的简单代码时:

(defun draw-a-box-in-window ()
(sdl:with-init
  ()
(let ((width 500)
      (height 500))
  (sdl:window width height)
  (setf (sdl:frame-rate) 60)
  (sdl:clear-display
   (sdl:color
    :r 127
    :g 127
    :b 127))
  (sdl:draw-box
   (sdl:rectangle
    :x (floor (/ width 3))
    :y (floor (/ height 3))
    :w (floor (/ height 3))
    :h (floor (/ height 3)))
   :color (sdl:color
           :r 200
           :g 200
           :b 200))
  (sdl:update-display)
  (sdl:with-events
      ()
    (:quit-event () t)
    (:key-down-event ()
                     (when (sdl:key-down-p :sdl-key-q)
                       (sdl:push-quit-event)))))))
(draw-a-box-in-window)

发生了一些错误:

arithmetic error FLOATING-POINT-INEXACT signalled
[Condition of type FLOATING-POINT-INEXACT]

Restarts:
0: [RETRY] Retry SLIME evaluation request.
1: [*ABORT] Return to SLIME's top level.
2: [ABORT] abort thread (#<THREAD "worker" RUNNING {1005D039E3}>)

Backtrace:
0: ("bogus stack frame")
1: ("foreign function: -[NSPlaceholderNumber initWithDouble:]")
2: ("foreign function: +[CALayer defaultValueForKey:]")

有人知道怎么解决吗?谢谢。

【问题讨论】:

    标签: macos sdl common-lisp sdl-2


    【解决方案1】:

    你好@aries_liuxueyangm,我向你推荐这个解决方案。

    (ql:quickload 'lispbuilder-sdl)
    
    (asdf:operate 'asdf:load-op :lispbuilder-sdl)
    (asdf:operate 'asdf:load-op :cocoahelper)
    
    (defparameter *random-color* sdl:*white*)
    
    (defun draw-a-box-in-window ()
    (sdl:with-init
      ()
    (let ((width 500)
          (height 500))
      (sdl:window width height)
      (setf (sdl:frame-rate) 60)
      (sdl:clear-display
       (sdl:color
        :r 127
        :g 127
        :b 127))
      (sdl:draw-box
       (sdl:rectangle
        :x (floor (/ width 3))
        :y (floor (/ height 3))
        :w (floor (/ height 3))
        :h (floor (/ height 3)))
       :color (sdl:color
               :r 200
               :g 200
               :b 200))
      (sdl:update-display)
      (sdl:with-events
          ()
        (:quit-event () t)
        (:key-down-event ()
                         (when (sdl:key-down-p :sdl-key-q)
                           (sdl:push-quit-event)))))))
    
    
    (defun main (argv &aux (argc (length argv)))
      (draw-a-box-in-window)
    )
    
    (sb-int:with-float-traps-masked (:invalid :inexact :overflow) (main *posix-argv*))
    

    【讨论】:

    • 这行得通。非常感谢!虽然有时会发生一些奇怪的事情。
    • @aries 如果它有效,您应该将答案标记为正确。这给了回答者他们当之无愧的业力
    • @Baggers 感谢您的建议。我刚刚标记了它。
    猜你喜欢
    • 1970-01-01
    • 2011-07-28
    • 2017-01-16
    • 2013-11-09
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多