Flickering problem

Hi everyone again =)

After downloading the 48 Mb of the mailing archive (after all, it worth
the download) and searching throw all the mails for flickering problems, I
found some tips about solving some problems that people (and myself) was
having.

It says that one way to solve flickering problems is to use double
buffering, but as I wasn’t able to use double buffering under SVGALIB
(that Sam has explained is not implemented yet) and because you can’t use
double buffering under X11, I was a little clueless.

Anyway, after making several test with no good results, I finally get to
have my little test with no flickers but that brings to me several
questions of why it could be happening and if it is a problem on the code
that I wrote before or in the library.

Ok, here comes the explanations of what have happened till I make it work
fine:

  1. setting SDL_SetVideoMode with the flag SDL_DOUBLEBUF on a console using
    SVGALIB (fullscreen)
    Test:
  • I blit two surfaces, one background and one sprite, and in the next
    frame I blit the background first to delete the sprite and blit the sprite
    again so it could be on the new position, one SDL_Flip on each loop.
    Result:
  • The sprite flickers badly.
  1. using the same SDL_SetVideoMode unde X11 with fullscreen or without it
    Test:
  • Same as above
    Result:
  • The sprite never flickers
  1. setting SDL_SetVideoMode with SDL_SWSURFACE but not SDL_DOUBLEBUF on a
    console using SVGALIB (fullscreen)
    Test:
  • The same as above
    Result:
  • The sprite doesn’t flicker anymore
  1. same SDL_SetVideoMode that on step 3 but under X11 with fullscreen and
    without it
    Test:
  • Same as above
    Result:
  • The sprite doesn’t flicker,

So, as you can see, it flicker only when you try to use SDL_DOUBLEBUF on
the console (fullscreen) and the driver doesn’t support it.

I don’t know if that is a problem with SVGALIB too, or if I should make my
code to test if the driver support double buffering and disabling it if
not so the flicker is avoided. Anyway, if the driver doesn’t support
double buffering, it should fall to use SWSURFACE to avoid the flickering?

Last question, why is flickering then when trying to use SDL_DOUBLEBUF
when it’s not supported?, is it normal?

Greettings.
Ernesto.

Ernesto Domato wrote:

It says that one way to solve flickering problems is to use double
buffering

Correct but SDL_DOUBLEBUF requests hardware page-flipping, which is just
one way of implementing double-buffering. You can always use a software
screen surface (SDL_SWSURFACE) and get double-buffering that way

So, as you can see, it flicker only when you try to use SDL_DOUBLEBUF on
the console (fullscreen) and the driver doesn’t support it.

If you pass SDL_DOUBLEBUF | SDL_HWSURFACE to SetVideoMode and the video
target does not support page-flipping, the screen surface will be the
hardware frame buffer and will thus not be double-buffered, unless you
provide it yourself. You can always look at the screen surface flags
after SetVideoMode to see what you actually got

If double buffering isn’t supported, then (as you said) SDL_Flip() just calls
SDL_UpdateRect(…) for the whole screen.

In other words, there is no inherent attempt inside SDL (or, via SDL :wink: to
sync the frame rate with the refresh rate of your screen.

Furthermore, (from what I gathered from your descriptions) you don’t seem to
be placing much (if any) delay between each SDL_Flip() (screen/window
refresh). In other words, you seem to be just blitting these surfaces as fast
as possible without any delay.

This will naturally cause flickering (depending on your hardware, it can be
very bad flickering) since the screen/window could be updating itself during
screen redraws.

The best thing to do, if you want to go a frame-rate route, is to call your
SDL_Flip() (or SDL_UpdateRect(…) or SDL_UpdateRects(…) ) after you have
checked for some *sufficient delay between screen/window updates.

*by “sufficient delay” I am really talking arbitrarily. It really depends on
your desired frame-rate.On Friday 07 September 2001 5:14pm, Ernesto Domato wrote:

So, as you can see, it flicker only when you try to use SDL_DOUBLEBUF on
the console (fullscreen) and the driver doesn’t support it.

I don’t know if that is a problem with SVGALIB too, or if I should make my
code to test if the driver support double buffering and disabling it if
not so the flicker is avoided. Anyway, if the driver doesn’t support
double buffering, it should fall to use SWSURFACE to avoid the flickering?

Last question, why is flickering then when trying to use SDL_DOUBLEBUF
when it’s not supported?, is it normal?


Sam “Criswell” Hart <@Sam_Hart> AIM, Yahoo!:
Homepage: < http://www.geekcomix.com/snh/ >
PGP Info: < http://www.geekcomix.com/snh/contact/ >
Tux4Kids: < http://www.geekcomix.com/tux4kids/ >