lispgames / cl-sdl2

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

sdl2:gl-get-swap-interval has an invalid return value check #100

Closed TeMPOraL closed 6 years ago

TeMPOraL commented 6 years ago

Currently, sdl2:gl-get-swap-interval throws up if the underlying function returns -1, due to use of check-rc macro. -1 is a legitimate return value for this function, and it happens to be what's returned on one of the platforms I'm developing on.

I currently use the following hotfix in my projects:

(defmacro check-not-below (form lower-limit)
  (with-gensyms (rc)
    `(let ((,rc ,form))
       (when (< ,rc ,lower-limit)
         (error 'sdl2::sdl-rc-error :rc ,rc :string (sdl2-ffi.functions:sdl-get-error)))
       ,rc)))

;; SDL_GL_GetSwapInterval() can return -1 as a valid value; currently, CL-SDL restricts
;; the return value to >= 0, which is incorrect.
(defun sdl2:gl-get-swap-interval ()
  (check-not-below (sdl2-ffi.functions:sdl-gl-get-swap-interval) -1))
TeMPOraL commented 6 years ago

Oh, I just realized I made a PR for that a few months ago - #84.

mfiano commented 6 years ago

Fixed