由于sdl_delay,lispbuilder-sdl在osx上不起作用

时间:2016-07-17 06:08:18

标签: macos lisp sdl common-lisp

我的操作系统是OS X 10.11.5,代码包含emacs + slime + sbcl
我使用命令加载lispbuilder-sdl:

(asdf:operate 'asdf:load-op :cocoahelper)
(asdf:operate 'asdf:load-op :lispbuilder-sdl)

然后复制here

上的示例代码
(sdl:with-init ()
  (sdl:window 320 240)
  (sdl:update-display)
  (sdl:with-events ()
     (:quit-event () t)))

但什么也没发生,所以我输入'C-c C-c'来终止这个过程, 它显示了一些错误:

Restarts:
0: [CONTINUE] Continue from break.
1: [RETRY] Retry SLIME REPL evaluation request.
2: [*ABORT] Return to SLIME's top level.
3: [ABORT] abort thread (#<THREAD "repl-thread" RUNNING {1003FC0003}>)

Backtrace:
0: ("bogus stack frame")
1: ("foreign function: SDL_Delay")
2: (LISPBUILDER-SDL-CFFI::SDL-DELAY 27)
3: ((SB-PCL::EMF LISPBUILDER-SDL::PROCESS-TIMESTEP) #<unavailable argument> #<unavailable argument> #<LISPBUILDER-SDL:FPS-FIXED {10059F6E43}> #<FUNCTION (LAMBDA NIL :IN #:DROP-THRU-TAG-1) {10056C6A0B}>)
4: ((:METHOD LISPBUILDER-SDL::PROCESS-TIMESTEP :AROUND (LISPBUILDER-SDL::FPS-MANAGER T)) #<LISPBUILDER-SDL:FPS-FIXED {10059F6E43}> #<FUNCTION (LAMBDA NIL :IN #:DROP-THRU-TAG-1) {10056C6A0B}>) [fast-metho..
5: ((LAMBDA ()))
6: (SB-INT:SIMPLE-EVAL-IN-LEXENV (LISPBUILDER-SDL:WITH-INIT NIL (LISPBUILDER-SDL:WINDOW 320 240) (LISPBUILDER-SDL:UPDATE-DISPLAY) (LISPBUILDER-SDL:WITH-EVENTS NIL (:QUIT-EVENT NIL T))) #<NULL-LEXENV>)
7: (EVAL (LISPBUILDER-SDL:WITH-INIT NIL (LISPBUILDER-SDL:WINDOW 320 240) (LISPBUILDER-SDL:UPDATE-DISPLAY) (LISPBUILDER-SDL:WITH-EVENTS NIL (:QUIT-EVENT NIL T))))

有没有人可以帮我修复此错误?

1 个答案:

答案 0 :(得分:0)

我试图重现你的例子(Linux / SBCL)。第一:

(ql:quickload :lispbuilder-sdl)

然后:

(sdl:with-init ()
  (sdl:window 320 240)
  (sdl:update-display)
  (sdl:with-events ()
    (:quit-event () t)))

当REPL挂起时(如预期的那样)显示一个空窗口,直到我关闭窗口并再次使用REPL。但是如果我在显示窗口时执行 C-c C-c ,那么我会获得类似于你的堆栈跟踪:

Interrupt from Emacs
   [Condition of type SIMPLE-ERROR]

Restarts:
 0: [CONTINUE] Continue from break.
 1: [RETRY] Retry SLIME REPL evaluation request.
 2: [*ABORT] Return to SLIME's top level.
 3: [ABORT] abort thread (#<THREAD "repl-thread" RUNNING {1003498033}>)

Backtrace:
  0: ("bogus stack frame")
  1: ((SB-PCL::EMF LISPBUILDER-SDL::PROCESS-TIMESTEP) #<unavailable argument> #<unavailable argument> #<LISPBUILDER-SDL:FPS-FIXED {1006F962A3}> #<FUNCTION (LAMBDA NIL :IN #:DROP-THRU-TAG-1) {1006F95F0B}>)
  2: ((:METHOD LISPBUILDER-SDL::PROCESS-TIMESTEP :AROUND (LISPBUILDER-SDL::FPS-MANAGER T)) #<LISPBUILDER-SDL:FPS-FIXED {1006F962A3}> #<FUNCTION (LAMBDA NIL :IN #:DROP-THRU-TAG-1) {1006F95F0B}>) [fast-metho..
  3: ((LAMBDA ()))
  4: (SB-INT:SIMPLE-EVAL-IN-LEXENV (LISPBUILDER-SDL:WITH-INIT NIL (LISPBUILDER-SDL:WINDOW 320 240) (LISPBUILDER-SDL:UPDATE-DISPLAY) (LISPBUILDER-SDL:WITH-EVENTS NIL (:QUIT-EVENT NIL T))) #<NULL-LEXENV>)
  5: (EVAL (LISPBUILDER-SDL:WITH-INIT NIL (LISPBUILDER-SDL:WINDOW 320 240) (LISPBUILDER-SDL:UPDATE-DISPLAY) (LISPBUILDER-SDL:WITH-EVENTS NIL (:QUIT-EVENT NIL T))))
 --more--

但是,一切都按预期工作,因为我可以选择继续执行或中止。这就是中断的目的。

我的猜测是一切正常,但你看不到窗口。我不知道为什么我不熟悉OS X。也许如果您尝试按SDL window does not show中的建议实际显示内容(见下文),它可能会起作用。 这是一个吸引人的例子:

(sdl:with-init ()
  (sdl:window 320 240)
  (sdl:update-display)
  (sdl:with-events ()
    (:quit-event () t)
    (:idle (sdl:fill-surface sdl:*white*)
           (sdl:update-display))))