Haskell bindings to the SDL2 library
Clone or download
chrisdone Tweak max allocs in tests
They're still constant, but on my GHC and system they are 3.5KB instead
of <3KB. A simple Constant overhead.

sdl2-2.4.1.0: test (suite: sdl-space)

Progress 1/2: sdl2-2.4.1.0
pollEvent

  Case             Allocated  GCs
  pollEvent 1          1,496    0
  pollEvent 10         1,624    0
  pollEvent 100        1,624    0
  pollEvent 1000       1,624    0
  pollEvent 10000      1,624    0

pollEvent+clear

  Case                     Allocated  GCs
  pollEvent + clear 1          2,208    0
  pollEvent + clear 10         3,512    0
  pollEvent + clear 100        3,512    0
  pollEvent + clear 1000       3,512    0
  pollEvent + clear 10000      3,512    0

pollEvent+present

  Case                      Allocated  GCs
  pollEvent + present 1         2,240    0
  pollEvent + present 10        3,544    0
  pollEvent + present 100       3,544    0
  pollEvent + present 1000      3,544    0

pollEvent+drawColor

  Case                        Allocated  GCs
  pollEvent + drawColor 1         2,360    0
  pollEvent + drawColor 10        3,664    0
  pollEvent + drawColor 100       3,664    0
  pollEvent + drawColor 1000      3,664    0
  pollEvent + drawColor 2000      3,664    0

pollEvent+drawRect

  Case                       Allocated  GCs
  pollEvent + drawRect 1         2,432    0
  pollEvent + drawRect 10        3,736    0
  pollEvent + drawRect 100       3,736    0
  pollEvent + drawRect 1000      3,736    0

animated rect

  Case                Allocated  GCs
  animated rect 1         2,432    0
  animated rect 10        3,736    0
  animated rect 100       3,736    0
  animated rect 1000      3,736    0
  animated rect 2000      3,736    0

animated rects

  Case                 Allocated  GCs
  animated rects 1         3,280    0
  animated rects 10        4,584    0
  animated rects 100       4,584    0
  animated rects 1000      4,584    0
  animated rects 2000      4,584    0
  animated rects 3000      4,584    0

sdl2-2.4.1.0: Test suite sdl-space passed
Latest commit 791a5c7 Aug 31, 2018

README.md

This package provides Haskell bindings for the SDL2 library.

What is SDL2?

SDL (Simple DirectMedia Layer) is a library for cross-platform development of interactive applications. SDL provides routines for managing windows, rendering graphics, processing sound, collecting input data, and much more.

The Haskell sdl2 library provides both a high- and low-level API to interface with SDL.

You may also want to check out:

  • sdl2-image - For handling different image formats such as jpg and png.
  • sdl2-mixer - For playing audio.
  • sdl2-gfx - For drawing graphics primitives such as circles and polygons.
  • sdl2-ttf - For handling true type fonts.

Building

Build Status

If you don't have SDL 2.0.6 or higher on your system via your package manager, you can install it from the official SDL site.

On Ubuntu you can install from source with a simple

./configure && make -j4 && sudo make install

On OSX you can install SDL with homebrew. pkg-config is also recommended.

brew install sdl2 pkg-config

On Windows you can install SDL with pacman under MSYS2 (or use stack's embedded MSYS2).

pacman -S mingw-w64-x86_64-pkg-config mingw-w64-x86_64-SDL2

Get Started

Take a look at the getting started guide.

Contributing

We need your help! The SDL API is fairly large, and the more hands we have, the quicker we can reach full coverage and release this to Hackage. There are a few ways you can help:

  1. Browse http://wiki.libsdl.org/CategoryAPI and find functions that aren't exposed in the high-level bindings.

  2. The above can be somewhat laborious - an easier way to find out what's missing is to write code.

    Both of these would be useful if they were translated to Haskell, and we'd be happy to store this code in this repository.

  3. Documentation is welcome, but may not be the best use of your time as we are currently in a period of rapid development as we find the most productive API.

Development

Using cabal repl

You can use cabal repl as a development tool, but you'll need to configure the project in a slightly non-standard way first:

cabal configure --ghc-option=-fPIC

You only need to do this once (unless you reconfigure). From this point, cabal repl should Just Work.