- Import SDL
- Open window(s) to draw on
- Draw window; render
- Handle events
- goto 3
// 1.
let SDL = dynld("sdl2");
// 2.
let window = SDL::OpenWindow("Title", optionalWidth, optionalHeight);
while true {
// 3.
window.fillRect(0, 0, window.width, window.height);
window.refresh();
// 4.
let event;
while (event = SDL::PollEvent()) != nil {
// do something with 'event' here...
}
// 5.
}
Check out the Documentation, starting with SDL.md, on how to get started and for further reference.
First things first, make sure that Sparkling
is installed.
Then, compile this with make
(no extra flags are necessary).
Finally, you must place the resulting library file in the same directory as
libspn
, which should be /usr/local/lib
(unless you specified another
installation directory).
For example code, see the Sparkling files: