#include #include /* * gcc -o testcase -g testcase.c `sdl-config --libs --cflags` */ #define xres 800 #define yres 480 SDL_Surface *screen; /* just to make happy when bug is fixed :) */ void inline fractal (SDL_Surface *s) { static int i=0; char *p = s->pixels; int x,y; for (y = 0; y < s->h; ++y) for (x = 0; x < s->w; ++x) { *p = (x+i) ^ y; p += s->format->BytesPerPixel; } i++; } int main (int argc, char **argv) { const SDL_VideoInfo *info =NULL; unsigned int fullscreen = 0; if (argc > 1) { if (strcmp(argv[1], "-f") == 0) fullscreen = 1; } if(SDL_Init(SDL_INIT_VIDEO|SDL_INIT_TIMER)<0) { fprintf (stderr,"SDL_Init failed, exit\n"); goto exit; } atexit(SDL_Quit); info = SDL_GetVideoInfo(); if (!info) { fprintf (stderr,"SDL_GetVideoInfo failed, exit\n"); goto exit; } if (fullscreen) { screen = SDL_SetVideoMode(xres, yres, info -> vfmt -> BitsPerPixel, SDL_SWSURFACE|SDL_FULLSCREEN); } else { screen = SDL_SetVideoMode(xres, yres, info -> vfmt -> BitsPerPixel, SDL_SWSURFACE); } SDL_ShowCursor(SDL_DISABLE); if(!screen) { fprintf(stderr, "failed to setup screen, exit\n"); goto exit; } fractal (screen); SDL_UpdateRect (screen, 0, 0, 0, 0); sleep (2); exit: return 0; }