CD_DBUFFER

CD - Canvas Draw

CD_DBUFFER - Double Buffer Driver using a server image (cddbuf.h)

Implements the concept of offscreen drawing. It is based on a Server Image (the back buffer) and a Window canvas (the front buffer).

Use

The canvas is created by means of a call to function cdCreateCanvas(CD_DBUFFER, Data), after which other functions in the CD library can be called as usual. This function creates a CD canvas to use with an existing window canvas (Native Windows or IUP). The parameter Data is a pointer to the already created canvas.

Any amount of such canvases may exist simultaneously. It is important to note that a call to function cdKillCanvas is required to properly end the driver. Call function cdKillCanvas for this driver before calling cdKillCanvas for the window driver.

The drawing functions will work normally as if they were drawn on the server image driver. When function cdCanvasFlush is executed, the image is drawn in the window canvas passed as parameter in the canvas creation.

When the window's size changes, the server image is automatically recreated using the same size as the canvas. This is done in the function cdCanvasActivate.

We suggest you to implement rubber bands using XOR directly on the front buffer.

To use this driver in Windows using GDI+ is necessary to call cdUseContextPlus(1) before creating the canvas.

Behavior of Functions

This driver is greatly platform-dependent. For further detail, see the Behavior of Functions in each platform: Microsoft Windows (GDI), Windows Using GDI+, X-Windows (XLIB). However, it should be noted that some functions behave differently from the basic functions of each platform.

Control

  • Flush: draws the contents of the image into the window. It is affected by Origin and Clipping, but not by WriteMode.