Skip to content

Common Lisp bindings and interface to the Allegro 5 game programming library

Notifications You must be signed in to change notification settings

ariSunz/cl-liballegro

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 

Repository files navigation

http://liballeg.org/images/logo.png

cl-liballegro

Interface and bindings to the Allegro 5 game programming library

Check out how the bindings’ source code is organized and compare it to the API reference.

Requires

libffi

Usage

  1. al_* becomes al:*
  2. (al:rest secs) is (al:rest-time secs) because of symbol interference with #’cl:rest.
  3. Enums/constants are shortened, check constants if you need help finding them.
  4. Type names have changed too, check types if you need help finding them.
  5. To access slots from a C struct, you can use CFFI:MEM-REF create a plist
    (defcstruct display-mode
      (width :int)
      (height :int)
      (format :int)
      (refresh-rate :int))
    
    (with-foreign-object (test '(:struct display-mode))
      (let ((plist (mem-ref test '(:struct display-mode))))
        (print plist)
        (print (getf plist 'width))))
        
  6. I’ve got a neat OPTIONAL lispy interface here which provides an entire fixed timestep game loop
  7. Everything else is pretty much 1-to-1
  8. If you’re getting crashes on MacOS, put all your code into callback and pass it to al:run-main.
  9. Examples exist if you get lost

Feel free to raise an issue to request a feature or for me to work on something

Functionality

Pretty much complete except:

I won’t work on the following sections because Common Lisp has more suitable implementations unless there’s a usecase or I’m bored.

  • Memory
  • Threads

FAQ

(More found under gh-pages branch)

https://resttime.github.io/cl-liballegro/

Why can’t my program find the DLL in Windows?

There are path problems in Windows because the DLL files (which contain all the functions the CFFI calls upon) doesn’t have a default location unlike in Unix environments. When the library loads in Windows, it will look for the DLL in the current folder of the FILE.LISP that evaluates (ql:quickload “cl-liballegro”) This means you must have a copy of the DLL file in the directory of FILE.LISP, not in the cl-liballegro directory unless the FILE.LISP is in there. SLIME however, likes to change the default search folder to the one Emacs is in when it starts.

With SBCL

;; Open command prompt in the folder that contains both the DLL and game.lisp`
> sbcl
> (load "game.lisp") ; File contains (ql:quickload "cl-liballegro")

With Emacs + SLIME

game.lisp contains (ql:quickload :cl-liballegro)

;; Looks for the DLL at /path/to/Desktop/allegro.dll
C-x C-f /path/to/Desktop/file9.lisp
M-x slime
C-x C-f /path/to/Desktop/game/game.lisp
C-c C-l
;; Looks for the DLL at /path/to/Desktop/game/allegro.dll
C-x C-f /path/to/Desktop/file9.lisp
C-x C-f /path/to/Desktop/game/game.lisp
M-x slime
C-c C-l
;; Looks for the DLL at /whatever/default/emacs/directory/allegro.dll
M-x slime
C-x C-f /path/to/Desktop/game/game.lisp
C-c C-l

License

Project under zlib license

About

Common Lisp bindings and interface to the Allegro 5 game programming library

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages

  • Common Lisp 100.0%