Skip to content

H2CO3/sdl2-sparkling

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

60 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

SDL2 bindings for Sparkling

Basic usage

  1. Import SDL
  2. Open window(s) to draw on
  3. Draw window; render
  4. Handle events
  5. 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.

Installing

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).

Examples

For example code, see the Sparkling files: