How To Install & Use SDL2 on Raspbian PI

22 posts
by jwzumwalt » Mon Oct 14, 2013 1:52 am
How To Install & Use SDL2 on Raspbian PI
By: Jan Zumwalt - October 15, 2013

I have a new project that needed good 2D graphics. Even though SDL1, EGL, GLES, GLES2, VG are preloaded with the "Raspian" version of RPI that I am using, I was interested in scaling and rotation and wanted to checkout SDL2.

A google search turns up almost nothing so I found myself blazing a trail. Neither the "synaptic" or "apt-get" repositories have the SDL2 library at the time of this writing. Oddly (at least for Raspbian) there does not seem to be any issue with the installation.

The only comprehnesive example I found was this utube video that includes links to a custom version that uses "CodeBlocks". I could not get it working on my Raspbian (Weezy Debian) version.

I was desperate and was not optimistic - but once you know one trick, it is REALLY EASY to get SDL2 running!

Get Loaded
1) Download - Get the linux generic release and unzip it in any directory. The really neat thing is the necessary Debian install files are provided and will setup automatically.

2) Install - Navigate to the Debian subdirectory. The instructions are in the text file "install.txt". All that is needed is to go to the unzip directory as root and run the following command './configure; make; make install'. It took about 50min to 1hr to do it's thing.

3) Done - It's ready... except ... :(

I spent the next two days not getting anything to compile. I eventually found out that SDL1 and SDL2 expect a custom made config program to pass the compiler library and include file information. This program is set up during the install process.

4) - Compile - Use these commands for SDL1 or SDL2 compiles
For sdl1 progs use...
Code: Select all
gcc `sdl-config --cflags --libs` -v -o myprog main.c > compile.log 2>&1

For sdl2 programs use...
Code: Select all
gcc `sdl2-config --cflags --libs` -v -o myprog main.c > compile.log 2>&1

NOW... you are up and running.

(Note: I tried for several days to manually provide the LIB and INC settings but I was unable to get anything to compile. You can run the "sdl2-config --cflags --libs" from a terminal and see what is being sent to the gcc compiler but when I tried to cut and past the same thing in a manual compile, it just would not work for me.)

I quickly found that SDL needs several support libraries to be able to use images and fonts.
The packages are located at
SDL2_image-2.0.0 - bmp is built in but you need this for jpg, png etc.
SDL2_mixer-2.0.0 - audio support
SDL2_net-2.0.0 - network support
SDL2_ttf-2.0.12 - trutype font support
SDL_rtf-0.1.0 - rich text format support

The install instructions for each package are the same so I have provided just one example.

Image Support, SDL2_image-2.0.0 - instructions are for 'root' user (you can also use sudo)
1) Download the package from
2) unzip
3) cd to the working directory
5) ./configure && make && make install

When you are done, you will receive this message
Libraries have been installed in: /usr/local/lib

If you ever happen to want to link against installed libraries in a given directory,
LIBDIR, you must either use libtool, and specify the full pathname of the library,
or use the `-LLIBDIR' flag during linking and do at least one of the following:

- add LIBDIR to the `LD_LIBRARY_PATH' environment variable during execution
- add LIBDIR to the `LD_RUN_PATH' environment variable during linking
- use the `-Wl,-rpath -Wl,LIBDIR' linker flag
- have your system administrator add LIBDIR to `/etc/'

See any operating system documentation about shared libraries for
more information, such as the ld(1) and manual pages.

I just include the directories with the -L and -I compiler commands

# file locations
LIB="-L./ -L./lib -L~/lib -L/lib -L/usr/lib -L/usr/local/lib -L/usr/lib/arm-linux-gnueabihf"
INC="-I./ -I./lib -I~/include -I/usr/include"

# graphic file locations
GINC="-I/opt/vc/include -Iopt/vc/src/hello_pi/libs"

# compile program
gcc `sdl2-config --cflags --libs` $LIB $GLIB $INC $GINC -v -o <program> <source> >> compile.log 2>&1

That's it, your done!

A discussion of various options in using these packages can be found at

Development Environment
For completeness I am providing my actual compiler script "" and ".desktop" link so it can all be compiled from a text or xterm terminal.

This file is called "" and can be run from a terminal or "desktop" link.
Code: Select all

  printf "\n"
  printf "\t+----------------------------+\n"
  printf "\t|       Compile main.c       |\n"
  printf "\t|          SDL2 test         |\n"
  printf "\t+----------------------------+\n\t"
  printf "\n\t Start Compile: "; date

  date > compile.log; printf "\n" >> compile.log

  # file locations
  LIB="-L./ -L./lib -L~/lib -L/lib -L/usr/lib -L/usr/local/lib -L/usr/lib/arm-linux-gnueabihf"
  INC="-I./ -I./lib -I~/include -I/usr/include"

  # graphic file locations
  GINC="-I/opt/vc/include -Iopt/vc/src/hello_pi/libs"

  # compile program
  gcc `sdl2-config --cflags --libs` $LIB $GLIB $INC $GINC -v -o sdl2_test main.c  >> compile.log 2>&1

  # run program
  if [ -f sdl2_test ]; then
    printf "\tEnd of program... \n"   
    cat ./compile.log
    printf "\t *** There where errors, compile aborted. ***\n"

  # required so xterm will not close
  printf "\n\t%s" "press any key to exit: "
  read -n 1


This is the "compile.desktop" GUI link file to be able to click on and compile from a xterm.
Code: Select all
[Desktop Entry]
Comment=Compiles C program
Exec=xterm  -sb -rightbar -fg Beige -bg "rgb:00/10/20" -e "cd /root/<path to program>  && ./"

Try It!
Here is the "main.c" SDL2 test program...
Code: Select all
#include <SDL2/SDL.h>

// +--------------------------------------------------+
// |            Minimal SDL2 Test Program            |
// |  Creates a graphics window then shuts it down    |
// |  after 10 seconds.                               |
// +--------------------------------------------------+

int main ( int argc, char** argv )
    SDL_Window *window;


    window = SDL_CreateWindow(
                              "SDL2 TEST PROGRAM",    // window title
                              SDL_WINDOWPOS_CENTERED, // the x position of the window
                              SDL_WINDOWPOS_CENTERED, // the y position of the window
                              400,400,                // window width and height
                              SDL_WINDOW_RESIZABLE    // create resizeable window
    if(window == NULL)                                // if no win, show error
        printf("Could not create SDL2 test window: %s\n", SDL_GetError());
        return 1;

    SDL_Delay(10000);                                 // 10sec delay
    SDL_DestroyWindow(window);                        // kill window
    SDL_Quit();                                       // clean up
    return 0;                                         // return success

So there you have it!
Lets all get together and start sharing our SDL2 programs!!!

Test Programs
Once you install SDL2 a comprehensive set of test routines are provided with the core package - but no compile info is provided. It was at this point that I ran into my problems until I ran across the need to pass LIB & INC info using the "sdl-config" program.

I created a script that tries to compile all of them. Some will compile while others don't.
I have not looked at the problems but I expect to find they need the "image" and "font" packages.
Code: Select all

#  +--------------------------------------+
#  |    Compile all SDL2 Test Programs    |
#  +--------------------------------------+

while read F  ; do
  printf "\n"
  printf "\t+-----   Compileing $F.c  -----+\n"
  printf "\n\t Start time: "
  printf "\n"
  gcc `sdl2-config --cflags --libs` -o $F $F.c
  printf "\n\t End time: "
  printf "\n"
done <./filelist.txt

filelist.txt - These test programs compile OK
Code: Select all

These programs don't compile.
They also did not compile after loading Image and Font support.


To compile a single program use this script
Code: Select all

# check for 2 arguments
ARGS=2    # number of arguments

if [ $# -ne $ARGS ]; then
  printf "\t  +---------------------------------------+\n"
  printf "\t  |          Compile SDL2 Program         |\n"
  printf "\t  |                                       |\n"
  printf "\t  |     ver Oct 1, 2013       |\n"
  printf "\t  |                                       |\n"
  printf "\t  |  Usage:                               |\n"
  printf "\t  | <program> <source>      |\n"
  printf "\t  |                                       |\n"
  printf "\t  |  Example:                             |\n"
  printf "\t  |  myprog  main.c        |\n"
  printf "\t  +---------------------------------------+\n"

  exit 1  # general error

  printf "\n"
  printf "\t+-----   Compileing $2  -----+\n"
  printf "\n\t Start time: "; date

  # file locations
  LIB="-L./ -L./lib -L~/lib -L/lib -L/usr/lib -L/usr/local/lib -L/usr/lib/arm-linux-gnueabihf"
  INC="-I./ -I./lib -I~/include -I/usr/include"

  # graphic file locations
  GINC="-I/opt/vc/include -Iopt/vc/src/hello_pi/libs"

  # compile program
  gcc `sdl2-config --cflags --libs` $LIB $GLIB $INC $GINC -v -o $1 $2 >> compile.log 2>&1

  printf "\n\t End time: ";  date
  printf "\n"

exit 0

Going Further
According to the test programs there are some problems with programs trying to use OpenGL, OpenGles, and Heptic that is pre-loaded on the Raspbian.
So, it would be nice to integrate these other common graphics packages along with the other major SDL2 packages - fonts, images, rich text, mixer, etc at
User avatar
Posts: 44
Joined: Sun Aug 04, 2013 4:00 pm
by Redrobes » Mon Oct 14, 2013 11:48 pm
Bravo ! Nice long and verbose bit of information to get it going.

I think there was another post about how to get SDL2 going with some more good advice on the boards somewhere - C++ forum topic I think. Anyway, this is something I would like to have a play with when I get some time. I'm sure its possible but its nice to have someone path beat it before hand.

All this info is very much appreciated.
User avatar
Posts: 80
Joined: Mon Dec 26, 2011 9:19 pm
Location: S.W. UK
by tednilsen » Fri Dec 06, 2013 10:57 am

I have sucessfully(?) compiled the SDL2 as shown here, but I get these errors when trying to compile a simple test (Free Pascal).
After searching the web, I've learnt that "vc_dispmanx_element_add" has to do with OpenGLES somehow, and it seem to be some linking issues...

...any idea? I would love to be able to use SDL2 in FPC, so I can move my code from Windows to RPi..

First line is ok... second line triggers the error:
Code: Select all
if SDL_Init(SDL_INIT_VIDEO) <> 0 then exit;
win := SDL_CreateWindow('SDL', 0, 0, 640, 480, SDL_WINDOW_SHOWN);

Message output:
Code: Select all
/usr/bin/ld: warning: link.res contains output sections; did you forget -T?
/usr/local/lib/ undefined reference to `vc_dispmanx_element_add'
/usr/local/lib/ undefined reference to `vc_dispmanx_update_start'
/usr/local/lib/ undefined reference to `vc_dispmanx_resource_delete'
/usr/local/lib/ undefined reference to `graphics_get_display_size'
/usr/local/lib/ undefined reference to `vc_dispmanx_update_submit_sync'
/usr/local/lib/ undefined reference to `bcm_host_init'
/usr/local/lib/ undefined reference to `vc_dispmanx_update_submit'
/usr/local/lib/ undefined reference to `vc_dispmanx_element_remove'
/usr/local/lib/ undefined reference to `vc_dispmanx_rect_set'
/usr/local/lib/ undefined reference to `vc_dispmanx_display_open'
/usr/local/lib/ undefined reference to `vc_dispmanx_resource_write_data'
/usr/local/lib/ undefined reference to `vc_dispmanx_element_change_attributes'
/usr/local/lib/ undefined reference to `vc_dispmanx_resource_create'
gfLib.lpr(37,32) Error: Error while linking
gfLib.lpr(37,32) Fatal: There were 1 errors compiling module, stopping
Posts: 10
Joined: Fri Dec 06, 2013 10:37 am
by kouky » Wed Dec 11, 2013 7:57 pm

I followed the instructions but ended-up with that error message:
/usr/bin/install: cannot create regular file '/usr/local/bin/sdl2-config' : permission denied

Any hints?

the solution was to do
sudo -s
Posts: 6
Joined: Sat Jun 09, 2012 10:48 am
by kouky » Thu Dec 12, 2013 12:11 pm
When using the 'SDL_RENDERER_ACCELERATED' flag on the SDL_CreateRenderer function, the window content is not drawn aymore, just seeing the pi desktop.

Is that mode not compatible with Raspbian?
Posts: 6
Joined: Sat Jun 09, 2012 10:48 am
by tibi38 » Sun Dec 15, 2013 11:04 am
Dear all a nice christmas time,
I tried to get it run on my pi, but every time I start in SDL2-image the showimage programm I run in the error-message:
SDL_CreateWindowAndRenderer() failed: No available video device

what is wrong in my environment?

Admin of
Posts: 42
Joined: Sat Nov 10, 2012 8:46 am
Location: Europe
by ulysess » Sat Jan 18, 2014 12:36 pm
Does anyone having problem with input devices? I'm trying to port some games and keyboard doesn't work.
Mis apuntes de...Raspberry Pi:
Google Docs RPi:
User avatar
Posts: 302
Joined: Thu Aug 02, 2012 6:35 am
Location: Spain
by Orange » Fri Mar 28, 2014 3:00 pm
Extremely useful post. Saved me a lot of time.

Posts: 36
Joined: Tue Jan 24, 2012 6:41 am
by PiGraham » Fri May 02, 2014 8:03 pm
This was a useful thread. I have SDL2 working without X11 on Raspbian.

Unfortunately I can't run my code from GDB, or remotely with gdbserver because it hangs on SDL_init(SDL_INIT_VIDEO)
Code: Select all
126         if (SDL_Init(SDL_INIT_VIDEO|SDL_INIT_NOPARACHUTE) < 0) {
[New Thread 0xb6bfc470 (LWP 2714)]

I have to kill gdb to recover.
NB SDL_INIT_NOPARACHUTE is included because I found a suggestion that it might help to disable the signal traps that SDL sets up by default. It made no difference.

The apps run fine without gdb, both from the local session and via SSH.

One oddity is that testopengles and testopengles2 report no support, but SDL_RendererInfo reports the renderer name is opengles2 and flag
SDL_RENDERER_ACCELERATED is set as expected.

Any ideas? Can you run SDL2 apps in GDB on Raspbian?

testver reports:
Code: Select all
INFO: Compiled with SDL 2.0 or newer
INFO: Compiled version: (hg-7760:323c4532e447)
INFO: Linked version: (hg-7760:323c4532e447)

Compiled with:
Code: Select all

    # check for 2 arguments
    ARGS=1    # number of arguments

    if [ $# -ne $ARGS ]; then
      printf "\t  +---------------------------------------+\n"
      printf "\t  |          Compile SDL2 Program         |\n"
      printf "\t  |                                       |\n"
      printf "\t  |     ver Oct 1, 2013       |\n"
      printf "\t  |                                       |\n"
      printf "\t  |  Usage:                               |\n"
      printf "\t  | <program> <source>      |\n"
      printf "\t  |                                       |\n"
      printf "\t  |  Example:                             |\n"
      printf "\t  |  myprog                |\n"
      printf "\t  | compile myprog.c to binary myprog     |\n"
      printf "\t  +---------------------------------------+\n"

      exit 1  # general error

      printf "\n"
      printf "\t+-----   Compileing $2  -----+\n"
      printf "\n\t Start time: "; date

      # file locations
      LIB="-L./ -L./lib -L~/lib -L/lib -L/usr/lib -L/usr/local/lib -L/usr/lib/arm-linux-gnueabihf"
      INC="-I./ -I./lib -I~/include -I/usr/include"

      # graphic file locations
      GINC="-I/opt/vc/include -Iopt/vc/src/hello_pi/libs"

      # compile program
      gcc `sdl2-config --cflags --libs` $LIB $GLIB $INC $GINC -v -ggdb -o $1 $1.c

      printf "\n\t End time: ";  date
      printf "\n"

    exit 0

Code: Select all
  Copyright (C) 1997-2014 Sam Lantinga <>

  This software is provided 'as-is', without any express or implied
  warranty.  In no event will the authors be held liable for any damages
  arising from the use of this software.

  Permission is granted to anyone to use this software for any purpose,
  including commercial applications, and to alter it and redistribute it
 *                                                                              *
 * Running moose :) Coded by Mike Gorchak.                                      *
 *                                                                              *

#include <stdlib.h>
#include <stdio.h>

#include "SDL.h"

#define MOOSEPIC_W 64
#define MOOSEPIC_H 88


SDL_Color MooseColors[84] = {
    {49, 49, 49}, {66, 24, 0}, {66, 33, 0}, {66, 66, 66},
    {66, 115, 49}, {74, 33, 0}, {74, 41, 16}, {82, 33, 8},
    {82, 41, 8}, {82, 49, 16}, {82, 82, 82}, {90, 41, 8},
    {90, 41, 16}, {90, 57, 24}, {99, 49, 16}, {99, 66, 24},
    {99, 66, 33}, {99, 74, 33}, {107, 57, 24}, {107, 82, 41},
    {115, 57, 33}, {115, 66, 33}, {115, 66, 41}, {115, 74, 0},
    {115, 90, 49}, {115, 115, 115}, {123, 82, 0}, {123, 99, 57},
    {132, 66, 41}, {132, 74, 41}, {132, 90, 8}, {132, 99, 33},
    {132, 99, 66}, {132, 107, 66}, {140, 74, 49}, {140, 99, 16},
    {140, 107, 74}, {140, 115, 74}, {148, 107, 24}, {148, 115, 82},
    {148, 123, 74}, {148, 123, 90}, {156, 115, 33}, {156, 115, 90},
    {156, 123, 82}, {156, 132, 82}, {156, 132, 99}, {156, 156, 156},
    {165, 123, 49}, {165, 123, 90}, {165, 132, 82}, {165, 132, 90},
    {165, 132, 99}, {165, 140, 90}, {173, 132, 57}, {173, 132, 99},
    {173, 140, 107}, {173, 140, 115}, {173, 148, 99}, {173, 173, 173},
    {181, 140, 74}, {181, 148, 115}, {181, 148, 123}, {181, 156, 107},
    {189, 148, 123}, {189, 156, 82}, {189, 156, 123}, {189, 156, 132},
    {189, 189, 189}, {198, 156, 123}, {198, 165, 132}, {206, 165, 99},
    {206, 165, 132}, {206, 173, 140}, {206, 206, 206}, {214, 173, 115},
    {214, 173, 140}, {222, 181, 148}, {222, 189, 132}, {222, 189, 156},
    {222, 222, 222}, {231, 198, 165}, {231, 231, 231}, {239, 206, 173}


void quit(int rc)

void UpdateTexture(SDL_Texture *texture, int frame)
    SDL_Color *color;
    Uint8 *src;
    Uint32 *dst;
    int row, col;
    void *pixels;
    int pitch;

    if (SDL_LockTexture(texture, NULL, &pixels, &pitch) < 0) {
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't lock texture: %s\n", SDL_GetError());
    src = MooseFrames[frame];
    for (row = 0; row < MOOSEPIC_H; ++row) {
        dst = (Uint32*)((Uint8*)pixels + row * pitch);
        for (col = 0; col < MOOSEPIC_W; ++col) {
            color = &MooseColors[*src++];
            *dst++ = (0xFF000000|(color->r<<16)|(color->g<<8)|color->b);

main(int argc, char **argv)
    SDL_Window *window;
    SDL_Renderer *renderer;
    SDL_RWops *handle;
    SDL_Texture *MooseTexture;
    SDL_Event event;
    SDL_bool done = SDL_FALSE;
    int frame;

   /* Enable standard application logging */

    if (SDL_Init(SDL_INIT_VIDEO) < 0) {
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't initialize SDL: %s\n", SDL_GetError());
        return 1;

    /* load the moose images */
    handle = SDL_RWFromFile("moose.dat", "rb");
    if (handle == NULL) {
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Can't find the file moose.dat !\n");

    /* Create the window and renderer */
    window = SDL_CreateWindow("Happy Moose",
                              MOOSEPIC_W*4, MOOSEPIC_H*4,
    if (!window) {
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create window: %s\n", SDL_GetError());

    renderer = SDL_CreateRenderer(window, -1,SDL_RENDERER_PRESENTVSYNC );
    if (!renderer) {
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create renderer: %s\n", SDL_GetError());

    if (!MooseTexture) {
        SDL_LogError(SDL_LOG_CATEGORY_APPLICATION, "Couldn't set create texture: %s\n", SDL_GetError());

    /* Loop, waiting for QUIT or the escape key */
    frame = 0;
    while (!done) {
        while (SDL_PollEvent(&event)) {
            switch (event.type) {
            case SDL_KEYDOWN:
                if (event.key.keysym.sym == SDLK_ESCAPE) {
                    done = SDL_TRUE;
            case SDL_QUIT:
                done = SDL_TRUE;

        frame = (frame + 1) % MOOSEFRAMES_COUNT;
        UpdateTexture(MooseTexture, frame);

        SDL_RenderCopy(renderer, MooseTexture, NULL, NULL);

    return 0;

/* vi: set ts=4 sw=4 expandtab: */

This is a debug session:
Code: Select all
 sudo gdb teststreaming
GNU gdb (GDB) 7.4.1-debian
Copyright (C) 2012 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.  Type "show copying"
and "show warranty" for details.
This GDB was configured as "arm-linux-gnueabihf".
For bug reporting instructions, please see:
Reading symbols from /home/pi/SDL2/SDL/test/teststreaming...done.
(gdb) break main
Breakpoint 1 at 0x8b5c: file teststreaming.c, line 93.
(gdb) run
Starting program: /home/pi/SDL2/SDL/test/teststreaming
[Thread debugging using libthread_db enabled]
Using host libthread_db library "/lib/arm-linux-gnueabihf/".

Breakpoint 1, main (argc=1, argv=0xbefff854) at teststreaming.c:93
93          SDL_bool done = SDL_FALSE;
(gdb) next
99          if (SDL_Init(SDL_INIT_VIDEO) < 0) {
[New Thread 0xb6bfc470 (LWP 2904)]

************ HANGS HERE until teststreaming process is killed from another tty with
sudo kill -s9 pid ***********

[Thread 0xb6bfc470 (LWP 2904) exited]
warning: Unable to fetch general register.
warning: Error removing breakpoint 0
PC register is not available
Posts: 2488
Joined: Fri Jun 07, 2013 12:37 pm
Location: Waterlooville
by Keyaku » Thu Jun 05, 2014 12:09 am
Hello, everyone!

I hope I'm not complicating anything as I post this. My intention is exactly the opposite:
I created a script that, running the script as it is, will automatically download and install the latest SDL2 version (SDL2-2.0.3 as of this day).
Instructions are there, but, basically, you don't need to do a thing other than letting it run. Only when reinstalling or downgrading an SDL build will the script prompt you for a confirmation.
When the script ends, it creates jwzumwalt's (slightly modified to show up the selected SDL version).

Here's the link for the Github page.

Hope this saves time for a lot of people!
Posts: 8
Joined: Wed Jun 04, 2014 11:11 pm
by dholth » Fri Jun 06, 2014 3:33 am
I have the same keyboard problem, I'm running SDL2 2.0.3 but my app does not receive any keyboard events even though I'm in the input group. Joystick events seem to work however. Instead, I would like to be able to receive both joystick and keyboard events as input. Any hints?

I'm using my own pysdl2-cffi SDL2 wrapper to program SDL2 in Python. It takes about a minute to load the first time, but by patching cffi to cache pickled versions of the parsed C headers it starts up in 10-20 seconds on pypy 2.3. The particular demo I'm running goes about 23 frames per second running in 1080p fullscreen compared to 500 fps on my main computer.
Posts: 2
Joined: Fri Jun 06, 2014 3:29 am
by dholth » Fri Jun 06, 2014 10:57 am
By the way according to the migration guide, SDL_INIT_NOPARACHUTE does nothing in SDL2.
Posts: 2
Joined: Fri Jun 06, 2014 3:29 am
by chungkun » Sat Aug 23, 2014 4:06 pm
For sdl2 test, please cd to test directory and do
Posts: 1
Joined: Sat Aug 23, 2014 4:01 pm
by ZARk » Mon Oct 13, 2014 1:01 pm

Could someone post a simple "hello world" app built in SDL2 that uses HW Acceleration (with or without X11) ?

I can't get SDL2 to create a window without X11
and with X11 it's dead slow, so most probably isn't hw accelerated ...
Posts: 3
Joined: Mon Oct 13, 2014 10:39 am
by Sonny_Jim » Mon Oct 20, 2014 8:28 pm
I had problems getting SDL2 to let me do hardware acceleration with OpenGL ES, even though I was sure that I had everything right. I was getting errors like this:
Code: Select all
Couldn't create renderer: Unknown OpenGL context profile -1092887348

The solution was to build SDL2.0.3 with the following configure options:
Code: Select all
./configure --disable-video-opengl --disable-video-x11

You'll still be able to run SDL2 apps under X11, just this time using the OpenGL ES renderer. Hope this helps.
Posts: 45
Joined: Tue Oct 23, 2012 4:15 pm
by trabitboy » Tue Nov 25, 2014 9:48 pm
using the initial script I could compile SDL2 on raspbian,
and port a 2D project over the course of the last months.

So video works fine ( and is fast ) in console mode,
sound untested.

interestingly, gdb worked out of the box through ssh ( like running locally on the pi ), I had no hang as mentionned earlier in the thread.

This thread is a must :)
Posts: 2
Joined: Tue Nov 25, 2014 9:42 pm
by trabitboy » Mon Dec 01, 2014 9:31 am
I got accelerated video, gamepad working on a fairly large 2d project : I must say I am super pleased by how well it feels to play on the raspi !

Now, the audio is an mp3 playing in the background with several wav samples played as fx.

The software starts fine with audio, then starts to lag , audio is interrupted,
and I can see a couple buffer underruns in the console before audio stops completely ( software keeps on running ).

I was wondering if someone has used SDL mixer for a game on the pi with similar constraints?
( one audio track + certain number of small fxs ) .

My search tracks so far:
- will check cpu use with top
- will try to run only with music / only with fxs
- will try to downsample the mp3 > find a format that is lighter

If you have any more ideas of things to try, let me know ;o)
Posts: 2
Joined: Tue Nov 25, 2014 9:42 pm
by toxibunny » Mon Dec 01, 2014 10:18 am
very interesting thread. Is there any chance someone could make a youtube video, to show what the performance is like using hardware acceleration, please?
note: I may or may not know what I'm talking about...
Posts: 1383
Joined: Thu Aug 18, 2011 9:21 pm
by nigelbest » Mon Dec 01, 2014 3:39 pm
Been looking everywhere for this - thank you
Posts: 1
Joined: Mon Dec 01, 2014 3:32 pm
Location: Ditchling
by blacktm » Tue Dec 02, 2014 7:55 am
For yet another option to install SDL2, I have a command-line utility as part of a project I'm working on called Simple 2D ( Running the `` script with...
Code: Select all
bash install --sdl
...will compile and install SDL2 from source. You can also run the script from the web using...
Code: Select all
url=''; which curl > /dev/null && cmd='curl -fsSL' || cmd='wget -qO -'; bash <($cmd $url) install --sdl
Hope that helps. Enjoy!
Posts: 3
Joined: Wed Oct 22, 2014 7:17 pm
Location: Washington, DC
by watz » Wed Dec 03, 2014 10:14 am
Perfect! That script worked like a charm out of the box. Thanks :-)
Posts: 2
Joined: Wed Dec 03, 2014 7:40 am
by ThomasBR » Mon Jan 12, 2015 5:31 am
Hello altogether,
I worked since about 2 month at a special program enviroment with SDL2 and Raspbian, Version
of 09-09-2014. Now I came to the point, where I wanted to extend the window handling and
thats where the trouble started.
The first I tried out was to use rendering. I updated raspberry properly but I didn't
suceed to become a hardware rendering. The only thing I got was a very, very slow software
rendering and I'm shure that if I would write that in software from my own, it would
be about 20-50 times faster (that's no joke and although would be no special art, about
three seconds are a very long time to render a picture!).
Any other ideas for Version 09-09-2014 ?

The next thing I tried out was version 24-12-2014. With a lucky punch I found out how to
get keyboard and mouse io running. Unfortunately I didn't write it down what I made and
so until this time, I didn't suceed a second time. Only giving 'input' to user 'pi' is
not enough, at minimum 'pi' should get 'tty' and libudev-dev had to be loaded. But
there was a third thing and I have forgotten that. If someone knows the exact howto and
write it down, then I think he could not only make me but a lot of people very happy.

But now the next thing. With version 24-12-2014 rendering works very fast, but
now you can only open a fullscreen desktop window, better to say SDL2 always does so,
regardless which parameter you give to it. Also resizing the window an giving this
window to the renderer result in a small picture in a full screen window. But it's
very fast, my respect! Although if you don't use rendering. You alway get a full screen
desktop window.
Any ideas ?
(Sorry for my "half-baked" english ....)
Posts: 1
Joined: Sun Jan 11, 2015 1:47 pm