Difference between revisions of "SDL"

From HaskellWiki
Jump to navigation Jump to search
(→‎Libraries: clarifying difference between sdl2 and hsSDL2)
(13 intermediate revisions by 2 users not shown)
Line 1: Line 1:
 
== Introduction ==
 
== Introduction ==
The Haskell package [http://hackage.haskell.org/package/SDL SDL] is a binding to the [http://www.libsdl.org/ C library libSDL]
+
The Haskell packages [https://github.com/Lemmih/hsSDL2 hsSDL2] and [http://hackage.haskell.org/package/sdl2 sdl2] are bindings to the [http://www.libsdl.org/ C library libSDL]
   
 
From [http://en.wikipedia.org/wiki/Simple_DirectMedia_Layer Wikipedia]:
 
From [http://en.wikipedia.org/wiki/Simple_DirectMedia_Layer Wikipedia]:
 
<br>
 
<br>
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 including Windows, Mac OS X, OS 9, Linux, the PSP, Google Android, AmigaOS, AmigaOS 4, Haiku/BeOS, MorphOS, OpenVMS, Syllable, and WebOS. It manages video, events, digital audio, CD-ROM, sound, threads, shared object loading, networking and timers.
+
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 <nowiki>[...]</nowiki> .
  +
  +
The [http://wiki.libsdl.org/Introduction SDL introduction page] lists the operating systems:
  +
* Windows
  +
* Mac OS X
  +
* Linux
  +
* iOS
  +
* Android
   
   
 
== Installation ==
 
== Installation ==
For installation of SDL on Windows, see [http://jpmoresmau.blogspot.com/2010/05/haskell-sdl-on-windows-check-hacking.html Haskell SDL on Windows, check! (hacking required)]
 
Another page on installation of SDL:
 
[http://www.animal-machine.com/blog/2010/04/a-haskell-adventure-in-windows/ A Haskell adventure in Windows]
 
   
  +
For installation of SDL2 or hsSDL2 on Windows, see [[SDL/Windows]].
  +
  +
Installation of SDL 1.x:
 
[http://www.animal-machine.com/blog/2010/04/a-haskell-adventure-in-windows/ A Haskell adventure in Windows]
   
 
== Problems ==
 
== Problems ==
Line 32: Line 40:
 
== Libraries ==
 
== Libraries ==
   
* [http://hackage.haskell.org/package/SDL SDL], the main package
+
* [https://github.com/Lemmih/hsSDL2 hsSDL2], high-level bindings for SDL2
* [https://github.com/Lemmih/hsSDL2 hsSDL2], high-level bindings for SDL2
+
* [http://hackage.haskell.org/package/sdl2 sdl2], low-level bindings for SDL2
* [http://hackage.haskell.org/package/sdl2 sdl2], low-level bindings for SDL2
+
* [https://github.com/jdeseno/hs-sdl2-image hs-sdl2-image], an image file loading library
  +
* [https://github.com/osa1/hsSDL2-ttf hsSDL2-ttf], a sample library that allows you to use TrueType fonts
  +
* [https://github.com/jdeseno/hs-sdl2-mixer hs-sdl2-mixer], a sample multi-channel audio mixer library
 
* [http://hackage.haskell.org/package/Sprig Sprig], a foreign Binding to Jonny D's SDL Primitives Generator (SPriG) library
 
* [http://hackage.haskell.org/package/graphics-drawingcombinators 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
 
* [http://hackage.haskell.org/package/haskgame haskgame], provides a video/audio/event handling library suitable for creating games or GUIs
 
* [http://hackage.haskell.org/package/cv-combinators cv-combinators], provides a functional combinator library for computer vision (used by [http://hackage.haskell.org/package/RMP RMP])
 
* [http://hackage.haskell.org/package/TeaHS TeaHS], a simple library for use creating 2D games
 
* [http://hackage.haskell.org/package/cal3d-examples cal3d-examples], examples for the Cal3d animation library
  +
* [http://hackage.haskell.org/package/lui lui], a set of composable purely functional widgets and a mainloop adapter to adapt the widgets to run in IO
 
* [http://helm-engine.org Helm], a functionally reactive game engine
  +
  +
Bindings to SDL 1.x:
  +
* [http://hackage.haskell.org/package/SDL SDL], the main package (see [https://github.com/keera-studios/hssdl this fork] for an updated version supporting GHC >= 7.4).
 
* [http://hackage.haskell.org/package/SDL-image SDL-image], an image file loading library
 
* [http://hackage.haskell.org/package/SDL-image SDL-image], an image file loading library
 
* [http://hackage.haskell.org/package/SDL-mixer SDL-mixer], a sample multi-channel audio mixer library
 
* [http://hackage.haskell.org/package/SDL-mixer SDL-mixer], a sample multi-channel audio mixer library
 
* [http://hackage.haskell.org/package/SDL-ttf SDL-ttf], a sample library that allows you to use TrueType fonts
 
* [http://hackage.haskell.org/package/SDL-ttf SDL-ttf], a sample library that allows you to use TrueType fonts
 
* [http://hackage.haskell.org/package/SDL-gfx SDL-gfx], SDL graphics drawing primitives and other support functions
 
* [http://hackage.haskell.org/package/SDL-gfx SDL-gfx], SDL graphics drawing primitives and other support functions
* [http://hackage.haskell.org/package/Sprig Sprig], a foreign Binding to Jonny D's SDL Primitives Generator (SPriG) library
 
* [http://hackage.haskell.org/package/graphics-drawingcombinators 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
 
* [http://hackage.haskell.org/package/haskgame haskgame], provides a video/audio/event handling library suitable for creating games or GUIs
 
* [http://hackage.haskell.org/package/SFont SFont], a haskell port of Karl Bartel's bitmap SFont library ([http://liamoc.net/projects/sfont.html homepage])
 
* [http://hackage.haskell.org/package/cv-combinators cv-combinators], provides a functional combinator library for computer vision (used by [http://hackage.haskell.org/package/RMP RMP])
 
* [http://hackage.haskell.org/package/TeaHS TeaHS], a simple library for use creating 2D games
 
* [http://hackage.haskell.org/package/cal3d-examples cal3d-examples], examples for the Cal3d animation library
 
* [http://hackage.haskell.org/package/lui lui], Purely FunctionaL User Interface
 
* [http://helm-engine.org Helm], a functionally reactive game engine
 
   
 
== Applications using SDL ==
 
== Applications using SDL ==
Line 67: Line 79:
 
* [http://hackage.haskell.org/package/astrds astrds], an incomplete 2d space game
 
* [http://hackage.haskell.org/package/astrds astrds], an incomplete 2d space game
 
* [http://hackage.haskell.org/package/fallingblocks fallingblocks], a fun falling blocks game
 
* [http://hackage.haskell.org/package/fallingblocks fallingblocks], a fun falling blocks game
  +
* [http://hackage.haskell.org/package/haskanoid haskanoid], an arkanoid clone with optional Wiimote and Kinect support, written using FRP.
   
See also the [http://packdeps.haskellers.com/reverse/SDL reverse dependencies listing for SDL]
+
See also the reverse dependencies listing for [http://packdeps.haskellers.com/reverse/sdl2 sdl2] and [http://packdeps.haskellers.com/reverse/SDL SDL]
   
  +
=== Commercial applications ===
  +
  +
* The Android Haskell game [https://play.google.com/store/apps/details?id=uk.co.keera.games.magiccookies Magic Cookies!] is written using the FRP implementation Yampa and hsSDL2.
   
 
== Links ==
 
== Links ==
   
 
* [https://github.com/snkkid/LazyFooHaskell/ All LazyFoo's SDL tutorials ported to Haskell]
 
* [https://github.com/snkkid/LazyFooHaskell/ All LazyFoo's SDL tutorials ported to Haskell]
  +
  +
* [http://keera.co.uk/blog/2014/10/15/from-60-fps-to-500/ From 60 Frames per Second to 500 in Haskell]
   
 
* [http://keera.co.uk/blog/2014/08/13/most-inspiring-green-screen-you-will-ever-see/ The most inspiring green screen you will ever see], a blog article about implementing a game with [[FRP]] and SDL, running on Android
 
* [http://keera.co.uk/blog/2014/08/13/most-inspiring-green-screen-you-will-ever-see/ The most inspiring green screen you will ever see], a blog article about implementing a game with [[FRP]] and SDL, running on Android
   
* [http://hsdl.sourceforge.net/ HSDL], an alternative binding to libSDL
+
* [http://hsdl.sourceforge.net/ HSDL], an alternative binding to libSDL (last update in 2005)
   
 
* [http://translate.google.com/translate?hl=en&sl=ja&u=http://www.f13g.com/%25A5%25D7%25A5%25ED%25A5%25B0%25A5%25E9%25A5%25DF%25A5%25F3%25A5%25B0/Haskell/HSDL/&prev=/search%3Fq%3Dreadme%2Bhsdl%26num%3D25%26hl%3Den%26client%3Dopera%26rls%3Den%26hs%3DRDO Using HSDL], an automatic translation from Japanese
 
* [http://translate.google.com/translate?hl=en&sl=ja&u=http://www.f13g.com/%25A5%25D7%25A5%25ED%25A5%25B0%25A5%25E9%25A5%25DF%25A5%25F3%25A5%25B0/Haskell/HSDL/&prev=/search%3Fq%3Dreadme%2Bhsdl%26num%3D25%26hl%3Den%26client%3Dopera%26rls%3Den%26hs%3DRDO Using HSDL], an automatic translation from Japanese
   
  +
* [http://www.mail-archive.com/haskell@haskell.org/msg22958.html A modified set of SDL bindings] to compile with Jhc
 
  +
  +
[[Category:User interfaces]]

Revision as of 18:54, 16 January 2016

Introduction

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

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

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

Problems

Haskell-SDL with Mac OS X

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

  • hsSDL2, high-level bindings for SDL2
  • sdl2, 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

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

See also the reverse dependencies listing for sdl2 and SDL

Commercial applications

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

Links

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