Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
*.fasl
*.fas
*.so
*.dylib
lib/
raylib.h
shim.h
11 changes: 11 additions & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -42,3 +42,14 @@ lib/lisp-raylib.dll:
lib/lisp-raylib-shim.dll: c/shim.c c/raylib.h
cd c && x86_64-w64-mingw32-gcc -L"../lib" -llisp-raylib -O3 -fPIC -shared -o lisp-raylib-shim.dll shim.c
mv c/lisp-raylib-shim.dll lib/

# --- MacOS --- #

macos: lib/ lib/liblisp-raylib.dylib lib/liblisp-raylib-shim.dylib raylib.h shim.h

lib/liblisp-raylib.dylib:
cd vendored/raylib-c/src/ && $(MAKE) PLATFORM=$(PLATFORM)
cp vendored/raylib-c/src/liblisp-raylib.5.5.0.dylib lib/liblisp-raylib.dylib

lib/liblisp-raylib-shim.dylib: c/shim.c lib/liblisp-raylib.dylib
$(CC) -O3 -fPIC -dynamiclib -o lib/liblisp-raylib-shim.dylib c/shim.c -Ivendored/raylib-c/src/ -Llib/ -llisp-raylib -Wl,-rpath,@loader_path
19 changes: 19 additions & 0 deletions README.org
Original file line number Diff line number Diff line change
Expand Up @@ -328,5 +328,24 @@ clean:

This copies the underlying =.so= files into a =lib/= local to your application, so
that when the =raylib= system loads, it will find them where it expects.
** macOS
On macOS the window must be created on the main thread. This can be accomplished
using `trivial-main-thread` with something like:

#+begin_src common-lisp
(defun launch ()
(raylib:init-window +screen-width+ +screen-height+ "My Game")
;; Game loop, drawing etc ...
)

(defun main ()
,#+darwin
(trivial-main-thread:with-body-in-main-thread ()

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great, so it looks like trivial-main-thread concerns can be pushed to the level of the application and be kept out of the lib.

,#+sbcl
(sb-int:set-floating-point-modes :traps '())

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Any idea why this ended up being necessary?

@egbulmer egbulmer May 30, 2026

Copy link
Copy Markdown
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I found this explanation in the cl-glfw3 library and a few discussions around similar problems (1, 2). Given that comment, it may be that only the window initialisation code needs to have floating point traps disabled. I'll do some tests to confirm.

Update: I ran a quick test and unfortunately it seems that drawing calls such as (rl:end-drawing) also trigger the traps.

Copy link
Copy Markdown
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Roger, thanks for the update.

(launch))
#-darwin
(launch))
#+end_src

** Creating Release Builds
13 changes: 12 additions & 1 deletion lisp/package.lisp
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,8 @@ restarted. Note the use of `:dont-save' below. This is to allow the package to
be compiled with `.so' files found in one location, but run with ones from another."
(let ((dir (case target
(:linux "/usr/lib/")
(:darwin #+arm64 "/opt/homebrew/lib/"
#-arm64 "/usr/local/lib/")
(t "lib/"))))
#+linux
(progn
Expand All @@ -57,7 +59,11 @@ be compiled with `.so' files found in one location, but run with ones from anoth
#+win32
(progn
(load-shared-object (merge-pathnames "lisp-raylib.dll" dir) :dont-save t)
(load-shared-object (merge-pathnames "lisp-raylib-shim.dll" dir) :dont-save t))))
(load-shared-object (merge-pathnames "lisp-raylib-shim.dll" dir) :dont-save t))
#+darwin
(progn
(load-shared-object (merge-pathnames "liblisp-raylib.dylib" dir) :dont-save t)
(load-shared-object (merge-pathnames "liblisp-raylib-shim.dylib" dir) :dont-save t))))

#+sbcl
(load-shared-objects)
Expand All @@ -69,6 +75,11 @@ be compiled with `.so' files found in one location, but run with ones from anoth
(ffi:load-foreign-library #p"lib/liblisp-raylib.so")
(ffi:load-foreign-library #p"lib/liblisp-raylib-shim.so"))

#+(and ecl darwin)
(progn
(ffi:load-foreign-library #p"lib/liblisp-raylib.dylib")
(ffi:load-foreign-library #p"lib/liblisp-raylib-shim.dylib"))

;; --- Keyboard and Gamepad --- ;;

;; HACK: 2024-12-29 Hacked manually as I couldn't figure out a first-class way
Expand Down