code for sdl_keyrepeat / SDL_VideoModeOK

Bernd Roesch nospamname at gmx.de
Sun Jun 14 18:15:04 BST 2009


Hello 

i have add this code, to get sdl better working, SDL_VideoModeOK return the
depth of the screen so netsurf use always best color depth in window mode.

please take a look, if thats possible to add.i test and it work ok.

its in file fb_frontend_sdl.c

framebuffer_t *fb_os_init(int argc, char** argv)
{
        framebuffer_t *newfb;
        int fb_width;
        int fb_height;
        int fb_depth;


        if ((option_window_width != 0) && (option_window_height != 0)) {
                fb_width = option_window_width;
                fb_height = option_window_height;                
        } else {
                fb_width = 800;
                fb_height = 600;
        }

        fb_depth = option_fb_depth;
        
        if ((fb_depth != 32) && (fb_depth != 16) && (fb_depth != 8))
                fb_depth = 16; /* sanity checked depth in bpp */

        newfb = calloc(1, sizeof(framebuffer_t));
        if (newfb == NULL)
                return NULL;

        if ( SDL_Init(SDL_INIT_VIDEO) < 0 ) {
                fprintf(stderr, "Unable to init SDL: %s\n", SDL_GetError());
                return NULL;
        }
        atexit(SDL_Quit);

        newfb->width = fb_width;
        newfb->height = fb_height;
  +      fb_depth = SDL_VideoModeOK(newfb->width,newfb->height,fb_depth,
SDL_SWSURFACE);
  +     newfb->bpp =    fb_depth;
  +     if (!fb_depth)return 0;
        sdl_screen = SDL_SetVideoMode(newfb->width, 
                                      newfb->height, 
                                      newfb->bpp, 
                                     SDL_SWSURFACE );

         if ( sdl_screen == NULL ) {
                fprintf(stderr, 
                        "Unable to set video: %s\n", SDL_GetError());
                free(newfb);
                return NULL;
        }
  +     SDL_EnableKeyRepeat(300, 50); 


Regards




More information about the netsurf-dev mailing list