This is the sdl2kit Reference Manual, generated automatically by Declt version 2.3 "Robert April" on Tue Feb 20 09:19:43 2018 GMT+0.
|• Introduction:||What sdl2kit is all about|
|• Systems:||The systems documentation|
|• Files:||The files documentation|
|• Indexes:||Concepts, functions, variables and data types|
This is a utility kit for
cl-sdl2 that provides something similar to
GLUT. However, it's also geared at being useful for "real"
applications or games.
At the moment, this includes the following functionality:
For an example, see
To make a new window, you simply create a subclass of
GL-WINDOW, and implement the
WINDOW protocol. You should
primarily specialize on
window-event WINDOW TYPE TIMESTAMP DATA1 DATA2: Handle a WM event (see the SDL2 documentation for parameters)
mousebutton-event WINDOW STATE TIMESTAMP BUTTON X Y
mousemotion-event WINDOW TIMESTAMP X Y
textinput-event WINDOW TIMESTAMP TEXT
keyboard-event WINDOW STATE TIMESTAMP REPEAT-P KEYSYM
other-event WINDOW EVENT: Other events not implemented yet
close-window WINDOW: Close the window. If you add a method to this, the window will not be closed unless you
CALL-NEXT-METHOD. This may be useful!
INITIALIZE-INSTANCE requires you
or simply define your method as
:AFTER. (This is due to method ordering being most-specific-first.)
Of these, you should only call
CLOSE-WINDOW from user
code. However, these can be called from any thread safely.
By default, windows do not render continuously, but only when
is called, or when an expose event is received. You may do the
following to enable idle rendering:
(setf (idle-render WINDOW) t)
You may do this at any time, and also set it to
NIL to disable idle
When an unhandled error happens in
RENDER, this could lead to
unpleasant effects: often a long string of errors until the window is
close, or the error is fixed, especially if
IDLE-RENDER is enabled.
However, sdl2kit will automatically disable window rendering if such an error occurs. This will prevent further errors from occurring. To re-enable or check the status of rendering, use the following:
(render-enabled WINDOW): Return the status of rendering
(setf (render-enabled WINDOW) BOOLEAN): Set the state of window rendering
Note that this only prevents rendering; events and other callbacks will still be active. This makes it easy to close a window if desired before fixing the issue.
While you can call
manually, you should define a startup function. This will ease a
number of things:
(define-start-function run-my-game (&key (w 1280) (h 720)) (sdl2:gl-set-attr :context-major-version 3) (sdl2:gl-set-attr :context-minor-version 3) (sdl2:gl-set-attr :context-profile-mask 1) (sdl2:gl-set-attr :stencil-size 8) (make-instance 'game-window :w w :h h))
This wraps the function in
SDL2:IN-MAIN-THREAD, as well as pre- and
This is convenient, but it's even more important for making binaries. When you dump a lisp image, this makes sure the initialization and startup of cl-sdl2 and sdl2kit are in the right order.
Typically when you dump a binary, you define a "toplevel function" to be called. It should look something like this:
(save-my-lisp :toplevel-function (lambda () (sdl2:make-this-thread-main 'run-my-game)))
This will prevent additional threads from being created (unless your
game makes them itself), and everything should run and exit seamlessly
(but see below).
(RUN-MY-GAME) should also work normally in Sly or
It's worth noting that in some lisp implementations, all SDL and OpenGL
calls must be made from the main thread. The
can be run as follows:
(ql:quickload :sdl2kit-examples) (sdl2.kit:define-start-function cube-test (&key (w 800) (h 500)) (sdl2:gl-set-attr :stencil-size 8) (sdl2:gl-set-attr :context-profile-mask 1) (sdl2:gl-set-attr :context-major-version 3) (sdl2:gl-set-attr :context-minor-version 3) (make-instance 'kit.sdl2.test:cube-window :w w :h h)) (sdl2:make-this-thread-main #'cube-test)
Quitting sdl2kit can by done with
(kit.sdl2:quit). This also quits
(sdl2:quit). Normally, you should not need to do
this during development, or if you're running things in Sly or SLIME.
However, if you're making a binary, you probably want your game to
exit! In this case, calling
or some other event should be sufficient to exit, if you're using a
startup function as above.
Build integration is coming soon, so it's easy to tell whether you're running "as a binary" or not. Currently to do this, you will need to set some flag yourself during the build process, which is also available during normal runs.
The main system appears first, followed by any subsystem dependency.
|• The sdl2kit system:|
Chip Collier <email@example.com>
A utility kit for SDL2
Files are sorted by type and then listed depth-first from the systems components trees.
|• Lisp files:|
|• The sdl2kit.asd file:|
|• The sdl2kit/package.lisp file:|
|• The sdl2kit/window.lisp file:|
|• The sdl2kit/keyboard.lisp file:|
|• The sdl2kit/main.lisp file:|
|• Concept index:|
|• Function index:|
|• Variable index:|
|• Data type index:|
|Jump to:||F L S|
|File, Lisp, sdl2kit.asd:||The sdl2kit<dot>asd file|
|File, Lisp, sdl2kit/keyboard.lisp:||The sdl2kit/keyboard<dot>lisp file|
|File, Lisp, sdl2kit/main.lisp:||The sdl2kit/main<dot>lisp file|
|File, Lisp, sdl2kit/package.lisp:||The sdl2kit/package<dot>lisp file|
|File, Lisp, sdl2kit/window.lisp:||The sdl2kit/window<dot>lisp file|
|Lisp File, sdl2kit.asd:||The sdl2kit<dot>asd file|
|Lisp File, sdl2kit/keyboard.lisp:||The sdl2kit/keyboard<dot>lisp file|
|Lisp File, sdl2kit/main.lisp:||The sdl2kit/main<dot>lisp file|
|Lisp File, sdl2kit/package.lisp:||The sdl2kit/package<dot>lisp file|
|Lisp File, sdl2kit/window.lisp:||The sdl2kit/window<dot>lisp file|
|sdl2kit.asd:||The sdl2kit<dot>asd file|
|sdl2kit/keyboard.lisp:||The sdl2kit/keyboard<dot>lisp file|
|sdl2kit/main.lisp:||The sdl2kit/main<dot>lisp file|
|sdl2kit/package.lisp:||The sdl2kit/package<dot>lisp file|
|sdl2kit/window.lisp:||The sdl2kit/window<dot>lisp file|
|Jump to:||F L S|
|The sdl2kit system|
|The sdl2kit system|