Re: XForms: Double-buffering of image data

Steve Lamont (spl@szechuan.ucsd.edu)
Sat, 23 Oct 99 09:37:40 PDT

# To subscribers of the xforms list from spl@szechuan.ucsd.edu (Steve Lamont) :

> Does anyone know of a way to compose an image and graphics (lines, text,
> circles, etc) off-screen and then bit-blit it to an on-screen canvas
> window (or a free object window)? I tried freezing and unfreezing the
> form, turning on double-buffering for the canvas object, and even using
> XUnmapWindow and XMapWindow, but without success.

A Canvas object is not affected by XForms double buffering, since it
is basically just a raw X Window.

If you have Mesa3D or OpenGL, you should use it -- it will handle the
double buffering for you. Refer to the documentation for OpenGL for
details.

If you insist on using the XForms drawing functions or raw Xlib, the
easiest way is to create two Pixmaps, draw to an offscreen Pixmap, and
then just swap Pixmaps using XSetWindowBackgroundPixmap() and
XClearWindow(). You need to do the XClearWindow() to make the new
background Pixmap appear [yes, this is a bit counterintuitive]. The
other Pixmap is then ready to be drawn on.

> ... I know I can do this using Xlib calls by drawing into a
> pixmap first and then copying into a window, but I would rather do it
> with the Forms library if at all possible.

This is a hack and I'm not absolutely sure if it would work (though in
principle, I see no reason why it shouldn't) but you might try using
fl_winset() to make your Pixmap the current Drawable. Most of the
XForms drawing functions simply are wrappers around the Xlib drawing
functions, which take as an argument a Drawable, which can be either a
Window or a Pixmap. You may need to cast your Pixmap to Window to
keep the compiler from complaining but since both Windows and Pixmaps
are simply XIDs, there should be no untoward effects.

spl
_________________________________________________
To unsubscribe, send the message "unsubscribe" to
xforms-request@bob.usuhs.mil or see
http://bob.usuhs.mil/mailserv/xforms.html
XForms Home Page: http://bragg.phys.uwm.edu/xforms
List Archive: http://bob.usuhs.mil/mailserv/list-archives/