[SDL] Using SDL on framebuffer console (radeonfb)

David sdl.20.comm at spamgourmet.com
Tue Nov 1 06:08:00 PST 2005


I had a problem about using SDL on framebuffer device (radeonfb in my case). I
wrote a very simple program which looked like this:

#include <SDL.h>
int main ()
    SDL_Surface *surface;

    if (SDL_Init (SDL_INIT_VIDEO) < 0)
         // oops
         return -1;

    // SDL_SetVideoMode ( ... );
    SDL_Quit ();
    return 0;

(Case 1) Now, when I ran it on framebuffer console (using radeonfb), the screen
turned blank. I had to switch to another console screen and back again to
restore it.

(Case 2) If I uncommented out the SDL_SetVideoMode () call, then the screen was
restored properly.

I ran gdb and found out the this: in SDL-1.2.9/src/video/fbcon/SDL_fbvideo.c,
function FB_VideoInit (), line 445, it read:

/* save hardware palette, if needed */
FB_SavePalette (this,  &finfo, &vinfo);

It was responsible for the blanking in case 1: when I stepped over this line
with gdb, the screen went blank immediately.

What is interesting is that in case 2, SDL_SetVideoMode () ultimately called
FB_SetVideoMode (), which called the 'opposite' function (line 734 of same
source file):

/* Restore the original palette */
FB_RestorePalette (this);

It seemed to 'balance things out' and the screen would be restored properly when
SDL_Quit () was called ultimately.

However, if the SDL_SetVideoMode () is commented out, FB_RestorePalette ()
seemed not to be called anywhere - and certainly not in FB_VideoQuit () function.

Should every call of FB_SavePalette () be matched by a call to FB_RestorePalette
()? If so, then I could just hack FB_VideoQuit () to add a FB_RestorePalette ()
call. But this means FB_RestorePalette () could be called TWICE, once in
FB_SetVideoMode (), once in FB_VideoQuit (). Is it OK?

Or, what would be the proper fix for case 1?

Thanks for your help.


More information about the SDL mailing list