SDL

From HaskellWiki

Introduction[edit]

The Haskell packages hsSDL2 and sdl2 are bindings to the C library libSDL

From Wikipedia:
Simple DirectMedia Layer (SDL) is a cross-platform, free and open source software multimedia library written in C, that presents a simple interface to various platforms' graphics, sound, and input devices. Software developers use it to write computer games or other multimedia applications that can run on many operating systems [...] .

The SDL introduction page lists the operating systems:

  • Windows
  • Mac OS X
  • Linux
  • iOS
  • Android


Installation[edit]

For installation of SDL2 or hsSDL2 on Windows, see SDL/Windows.

Installation of SDL 1.x: A Haskell adventure in Windows

Problems[edit]

Haskell-SDL with Mac OS X[edit]

There are some issues with the Haskell SDL bindings and Mac OS X, notably linking problems that result in an error such as:


Linking test ...
Undefined symbols:
  "_SDL_main", referenced from:
      -[SDLMain applicationDidFinishLaunching:] in libSDLmain.a(SDLMain.o)
ld: symbol(s) not found
collect2: ld returned 1 exit status


In the SDL bindings' MACOSX file, there is some mention of a code example that shows how to solve this. Unfortunately, the Darcs repository where this code resides is down. After asking Nick Alexander, who was mentioned in the MACOSX file, he referred to the following work by Audrey Tang, where the Main-file trick for making this compile can still be found: [1]


Libraries[edit]

  • hsSDL2, high-level bindings for SDL2
  • sdl2, high- and low-level bindings for SDL2
  • hs-sdl2-image, an image file loading library
  • hsSDL2-ttf, a sample library that allows you to use TrueType fonts
  • hs-sdl2-mixer, a sample multi-channel audio mixer library
  • Sprig, a foreign Binding to Jonny D's SDL Primitives Generator (SPriG) library
  • graphics-drawingcombinators, a functional wrapper around OpenGL, so you don't have to go into the deep, dark world of imperative stateful programming just to draw stuff
  • haskgame, provides a video/audio/event handling library suitable for creating games or GUIs
  • cv-combinators, provides a functional combinator library for computer vision (used by RMP)
  • TeaHS, a simple library for use creating 2D games
  • cal3d-examples, examples for the Cal3d animation library
  • lui, a set of composable purely functional widgets and a mainloop adapter to adapt the widgets to run in IO
  • Helm, a functionally reactive game engine

Bindings to SDL 1.x:

  • SDL, the main package (see this fork for an updated version supporting GHC >= 7.4).
  • SDL-image, an image file loading library
  • SDL-mixer, a sample multi-channel audio mixer library
  • SDL-ttf, a sample library that allows you to use TrueType fonts
  • SDL-gfx, SDL graphics drawing primitives and other support functions

Applications using SDL[edit]

  • Level 0, a Snake II clone written in Haskell
  • HTicTacToe, a tic-tac-toe game
  • YACPong Yet Another Pong Clone
  • Eternal10Seconds, a 2-D shooting game
  • Raincat, a game developed by Carnegie Mellon students
  • TimePiece, a simple tile-based digital clock screen saver
  • TypeClass, a typing speed game
  • breakout, a simple Breakout game implementation
  • brians-brain, the Brian's Brain cellular automaton implemented in just 49 lines of Haskell
  • ffmpeg-tutorials, tutorials on ffmpeg usage to play video/audio
  • freekick2, a soccer game
  • hbeat, a toy step sequencer program written using OpenGL and the SDL libraries
  • hogre-examples, examples for using Hogre, Haskell bindings to OGRE (Object-Oriented Graphics Rendering Engine)
  • starrover2, a space simulation game
  • astrds, an incomplete 2d space game
  • fallingblocks, a fun falling blocks game
  • haskanoid, an arkanoid clone with optional Wiimote and Kinect support, written using FRP.
  • haskell-snake, yet another Snake clone, with multiplayer support

See also the reverse dependencies listing for sdl2 and SDL

Commercial applications[edit]

  • The Android Haskell game Magic Cookies! is written using the FRP implementation Yampa and hsSDL2.

Links[edit]

  • HSDL, an alternative binding to libSDL (last update in 2005)
  • Using HSDL, an automatic translation from Japanese