1

Can I get the SDL libraries on Raspbian? I don't actually have a Raspberry Pi, but before I get one I want to know if I can.

If I can then:

  • Does it have all the features of SDL 1.2?
  • How long does it take to compile code that uses the libraries?
  • How fast will the resulting program run?
1

3 Answers 3

2

I have used SDL 1.2 on the Raspberry Pi with Raspbian, by installing the libsdl1.2-dev package that lenik suggests. It also works from the console, so X is not needed.

The only special thing with running from the console on the Raspberry Pi, is that you have to check the supported screen size and then initialize your screen with wathever values you get. See Gordon's post on this. Another thing to note there is that the Raspberry Pi (at least by default?) uses 16 bit/pixel colors, so use 16 bit/pixel throughout the program for the best performance. Also see the thread Idiot's guide to C++/SDL Setup in the Raspberry Pi forum.

I do roughly this in a platform game I am working on, mostly from the forum thread:

SDL_Surface * makeWindow()
{
    SDL_Surface *screen;
    if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_AUDIO|SDL_INIT_JOYSTICK) < 0)
        dieSDL("SDL init failed: %s\n");

    const SDL_VideoInfo* videoInfo = SDL_GetVideoInfo ();
    int systemX = videoInfo->current_w;
    int systemY = videoInfo->current_h;
    int systemZ = videoInfo->vfmt->BitsPerPixel;

    printf ("%d x %d, %d bpp\n", systemX, systemY, systemZ);

    screen = SDL_SetVideoMode(systemX, systemY, systemZ,
                              SDL_SWSURFACE); // | SDL_FULLSCREEN);
    if (screen == NULL)
        dieSDL("SDL_SetVideoMode failed: %s\n");

    return screen;
}

The game is here, but there isn't any Raspberry Pi version published yet.

1
$ apt-cache search sdl

gave me (among many others) the following:

libsdl1.2-dbg - Simple DirectMedia Layer debug files
libsdl1.2-dev - Simple DirectMedia Layer development files

looks like sdl c/c++ development for Raspberry Pi is supported, or at least present in the latest build of Raspbian.

2
  • Have you actually tried using the libraries?
    – user8709
    Jul 28, 2013 at 11:07
  • i have a headless (sans monitor) setup, there's no point. there are plenty of preinstalled games/app that do, however.
    – lenik
    Jul 28, 2013 at 13:01
-1

I have created a video and posted it on youtube showing how to download and setup SDL 2.0 for the raspberry pi on youtube.

http://www.youtube.com/watch?v=Yo7hO7GZ-ug

3
  • 30 minutes video?? are you for real?
    – lenik
    Aug 16, 2013 at 3:00
  • This is clearly someone just trying to promote his Youtube channel... Aug 6, 2016 at 12:00
  • @EduardoCosta Self-promotion is not forbidden, preferably including disclosure (which this does) if it involves an appropriate solution to a question (and although the question was not exactly "How do I setup SDL?", the other two prior answers were already more-or-less about that, so to be fair, this one is no more or less appropriate). I have removed the "please subscribe and share line", however.
    – goldilocks
    Aug 6, 2016 at 12:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.