lispgames / cl-sdl2

Common Lisp bindings for SDL2 using C2FFI.
MIT License
309 stars 82 forks source link

sdl2-examples:basic-test window can't be closed on OSX #75

Closed liuxueyang closed 6 years ago

liuxueyang commented 8 years ago

I use SBCL in emacs SLIME. I press ESCAPE and it does not work. How to deal with this? Any help? Thanks. 😃 image

rpav commented 8 years ago

You appear to be using an inferior lisp and SBCL; I'm surprised you get this much. As far as I know, the only way to safely touch the GUI in OSX is by overriding the initial thread the lisp creates and doing all handling there.

With CCL, this can be done automatically. With SBCL, you need to do more work, manually creating a thread for slime/swank and using sdl2:make-this-thread-main.

liuxueyang commented 8 years ago

I switch to CCL, and run (sdl2-examples:basic-test), there is no window appears. ;-(

borodust commented 8 years ago

Similar issue here (SBCL bare or in SLIME in macosx). App skeleton is like that:

(defun sdl-main ()
  (sdl2:with-init (:everything)
    (sdl2:with-window (win :title "placeholder" :flags '(:opengl :shown))
      (sdl2:with-gl-context (gl-context win)
        (sdl2:gl-make-current win gl-context)

        (sdl2:with-event-loop (:method :poll)
          (:keyup (:keysym keysym)
            (when (sdl2:scancode= (sdl2:scancode-value keysym) :scancode-escape)
              (sdl2:push-event :quit)))
           (:idle ()

             ; drawing goes here

             (sdl2:delay 10))
           (:quit () t))))))

(defun main ()
  ; making other thread main for sdl
  (bt:make-thread (lambda ()
            (sdl2:make-this-thread-main #'sdl-main))))

Window with properly rendered image shows up, but doesn't respond to input (ESC btn in this case). Also osx menu-bar for this window is stuck too.

P.S. Bare CCL behaves exactly the same.

borodust commented 8 years ago

Made a quick C prototype (main.c) to check if there's anything wrong with SDL itself. Nope. Input event handling works just fine.

borodust commented 8 years ago

Apparently, it's not really an osx window that shown when drawing with opengl. It pops up even when you don't specify neither :opengl nor :shown flags when creating a window. Bloody hell...

mfiano commented 6 years ago

Is this still an issue @borodust ?

borodust commented 6 years ago

I don't know. Feel free to close.