[comp.windows.x] help needed: quick exchange of window contents

fritzke@immd2.informatik.uni-erlangen.de (B. Fritzke) (09/03/90)

Hi there,
I want to display complicated, slowly changing line drawings in an
X-Window. The problem is, that the screen starts flickering very much,
if I

  1) make a drawing    (1 long call to XDrawSegments)
  2) flush the screen  (XFlush)
  3) clear the window  (XClearWindow)
  4) goto 1)

Is there a possibility to build up the new drawing somewhere in the
background while showing the old one and then switching to the new
drawing with one (quick) command?

I'm aware of pixmaps and the possibility of copying them into the 
window, but I would like to avoid copying because of performance
reasons.


Thanks in advance for any help,
(please answer by e-mail)

Bernd Fritzke

Bernd Fritzke ------>  e-mail: fritzke@immd2.informatik.uni-erlangen.de
University of Erlangen, CS IMMD II, Martensstr. 3,  8520 Erlangen (FRG)

mouse@LARRY.MCRCIM.MCGILL.EDU (09/04/90)

> I want to display complicated, slowly changing line drawings in an X
> window.  The problem is, that the screen starts flickering very much,
> if I

>   1) make a drawing    (1 long call to XDrawSegments)
>   2) flush the screen  (XFlush)
>   3) clear the window  (XClearWindow)
>   4) goto 1)

> Is there a possibility to build up the new drawing somewhere in the
> background while showing the old one and then switching to the new
> drawing with one (quick) command?

I know of three ways to do this.

(1) Use the Multi-Buffering extension.  This came out with R4; one
    hopes that most vendors have picked it up by now.  If available,
    this is probably the best bet.

(2) Use colormap and planemask tricks.  If you have a visual with a
    mutable colormap, and a sufficient depth (from your description, I
    would guess you need only one bit to display your picture, meaning
    a depth of two would suffice), you can set the colormap to display
    one picture and set the planemask to make that picture read-only,
    draw the next, and then display it fast by changing the colormap
    cells.  Then of course you change the planemask and draw the next
    picture, et cetera.

(3) Draw into a pixmap and copy it onto your window in one go.  You
    mention this but say

	> but I would like to avoid copying because of performance
	> reasons.

    Try it; you may find it doesn't hurt performance as much as you
    think it will.  This method is the most universally available, but
    costs server-side memory, which might be scarce (eg, an X
    terminal).

					der Mouse

			old: mcgill-vision!mouse
			new: mouse@larry.mcrcim.mcgill.edu