[SDL] Double buffering waitretrace and flickering

Karsten-Olaf Laux klaux at student.uni-kl.de
Thu Aug 19 06:10:33 PDT 1999

on Don, 19 Aug 1999 dtabuenc at cs.ucr.edu wrote:
>Ok here is the code I promissed. It's pretty straight forward so I am
>either making a really silly mistake or something is not right.
>Basically I even took away the image blit and I am just filling a
>rectangle now. It runs fine in windowed mode (single buffered) when
>doing it in DGA mode under root horrible flicker! Anyone know where
>this flicker is comming from?
>#include <SDL/SDL.h>
>#include <iostream.h>
>#include <stdlib.h>
>int main()
>SDL_Surface *screen;

<<<<<<<  this should be 

if(screen->flags & SDL_DOUBLEBUF)

(this is one of my favorite faults ... I can't code a 100 lines without messing
"&&" and "&") your version returns always true, since both values are unequal 0
(meaning true in c). So there might be still the chance, that you are in fact
_not_ running a doublebuffer.

>        cout << "Using Double Buffering\n";
>        cout << "Using a single buffer\n";
>static Uint32 black=SDL_MapRGB(screen->format,0,0,0);
>static Uint32 blue= SDL_MapRGB(screen->format,0,0,255);;
> SDL_Rect dstrect;
>dstrect.x = (640/2-16);
>dstrect.y = (480-64);
>dstrect.w = 64;
>dstrect.h = 64;
>SDL_Event event;
>        {
>        SDL_FillRect(screen, 0,black);//Clear whole buffer
>        SDL_FillRect(screen,&dstrect, blue); //Fill in little blue rect on bottom
>        SDL_Flip(screen);
>        SDL_PollEvent(&event);
>        if(event.type == SDL_KEYDOWN)
>                exit(0);
>        }
Karsten-O. Laux           
klaux at student.uni-kl.de

More information about the SDL mailing list