I have just started experimenting with SDL on the PSP a bit, and I can't seem to get rid of the tearing if the frame rate is high. For example, with something like this:
Code: Select all
Uint32 colors[3];
colors[0] = SDL_MapRGB(screen->format, 0xFF, 0, 0);
colors[1] = SDL_MapRGB(screen->format, 0, 0xFF, 0);
colors[2] = SDL_MapRGB(screen->format, 0, 0, 0xFF);
int c = 0;
SDL_Event evt;
while (true) {
if (SDL_PollEvent(&evt)) {
switch (evt.type) {
case SDL_KEYDOWN:
break;
case SDL_QUIT:
exit(0);
}
}
++c;
c = c % 3;
SDL_FillRect(screen, NULL, colors[c]);
SDL_Flip(screen);
SDL_Delay(10);
}
However, the result looks like 4 bands of colors flash really fast (tearing). I am guessing it's something to do with vsync, but I am not experienced at all in graphics programming.
If I change SDL_Delay(10) to SDL_Delay(100), all is well.
I am calling SDL_SetVideoMode with "SDL_SWSURFACE | SDL_DOUBLEBUF". Is there anything else I can do?
Thanks for your help