A brief note on using SDL on the Raspberry Pi
Just a few notes to highlight some of the issues I’ve had with the Simple Direct Media (SDL) libraries and the Raspberry Pi. Most of this is to do with using it in direct framebuffer mode, but also applicable to running under X.
The first, which seems obvious is that the Pi has a 16 bit per pixel framebuffer (although I understand this can be changed somehow). So when I ported my application (BASIC) to the Pi, it worked fine, but was slow! Presumably due to SDL doing the conversion from 32bpp to 16bpp for every SD_FLip() or SDL_UpateRect() call.
Once I switched to 16bpp, then things started to move a lot faster!
The other issue appears to be with running in SDL_HWSURFACE and/or SDL_DOUBLEBUF modes. On the console these appear to either crash the Pi, or cause writes to NOT be double buffered, but to go directly to the visible framebuffer memory!
It’s possible this is due to a bug in the SDL driver, a bug in the Raspbrtty Pi framebuffer driver, or a combination of both. It’s also possible it’s something else, but tracking it down is going to be time consuming.
Another issue is the actual screen size on the Pi. It’s variable. Very variable, so important to do a
videoInfo = SDL_GetVideoInfo () ;
then to use use the videoInfo->current_w, videoInfo->current_h and videoInfo->vfmt->BitsPerPixel values.
But do check when running under X – in this case I’m using a default X and Y size.