Re: Flicker free animation with Xlib - how? - Xwindows

This is a discussion on Re: Flicker free animation with Xlib - how? - Xwindows ; Boltar (boltar2003@yahoo.co.uk) wrote: Hi Boltar, : I will soon be writing a graphics application that will require : flicker free graphics using Xlib. In the past I have tried the : old draw - undraw method but that can produce ...

+ Reply to Thread
Results 1 to 2 of 2

Thread: Re: Flicker free animation with Xlib - how?

  1. Re: Flicker free animation with Xlib - how?

    Boltar (boltar2003@yahoo.co.uk) wrote:
    Hi Boltar,

    : I will soon be writing a graphics application that will require
    : flicker free graphics using Xlib. In the past I have tried the
    : old draw - undraw method but that can produce nasty flicker. I have also
    : tried using the double buffer dbe extension but it seems just too
    : slow for large windows. I have also tried viewing the code of
    : xlock which seems to manage without using dbe but I've yet to figure
    : out how it does it (the code frankly is just too complex). Can anyone
    : suggest a way to do it?
    The right way would be writing an extension of the current
    implementation of the SYNC-extension of XFree86 :-)

    If you don't have time for that and if you don't mind using
    a dirty hack, you should have a quick look at a page that
    I assembled some time ago...
    URL http://www.complang.tuwien.ac.at/skr...y_xfree86.html

    On this page I describe how the xf86vidmode-extension of XFree86
    can be utilized to force synchronization with the vertical retrace.
    (Be aware that the code presented uses 'busy waiting'. If your
    app is somewhat performance-critical, you should probably not
    consider that hack...)

    Regards,
    Stefan

    --
    Stefan Kral http://www.complang.tuwien.ac.at/skral/

  2. Re: Flicker free animation with Xlib - how?

    skral@mips.complang.tuwien.ac.at (Kral Stefan) writes:

    >The right way would be writing an extension of the current
    >implementation of the SYNC-extension of XFree86 :-)


    Well, it's a question of terminology I suppose. Flicker occurs when
    pixels change colour more than once during an animation frame. If an
    object is "undrawn" (by being painted over with the background colour)
    and then redrawn in its new position, then in the region where the old
    and new objects overlap, the pixels will have their colour changed
    twice.

    Double-buffering, whether assisted by hardware or done in software,
    always removes flicker. Just drawing in an off-screen pixmap or XImage
    and then updating the entire changed area at once will do it.

    You only need vertical refresh synchronisation to deal with "tearing"
    artifacts, which are usually a lot less severe than flicker but can be
    annoying when you are trying to do smooth animation of large objects or
    soft scrolling.

    Hardware framebuffer page flipping synchronised to vertical refresh
    will cure both flicker and tearing. It's usually a necessity for
    full-screen games, but (somewhat surprisingly) not for video playback.


+ Reply to Thread