Direct2D Base Driver (since 5.12)

This driver represents a base driver for all system-dependent drivers implemented in the Microsoft Windows system, but uses a new API called Direct2D. The drivers Native Window, IUP, Image and Double Buffer were implemented.

The main motivation for the use of Direct2D was transparency for all the primitives. Beyond that we got other features like anti-aliasing, gradient filling and bezier lines.

This driver still does not completely replace the GDI Windows base driver, because Direct2D does not have support for XOR, EMF nor Printer. Also the applications need to adapt the rendering of text that is slightly different from GDI. It is know that Direct2D can be slower than GDI in some cases (specially when drawing in integer coordinates) and faster in other cases.

It has features similar to the GDI+ driver. But does not support the regular metafile input/output. On the other hand it seems to be faster than GDI+. It is similar to the OpenGL driver in the sense it was designed for display only. Printer support exists since Windows 8 only, but it is complicated and not implemented in CD.

To be able to use the driver the function cdInitDirect2D must be called. Notice that this is NOT a context plus driver.

The application must be linked with the "cddirect2d.lib" library and use the "cddirect2d.h" header. This driver only works in Windows.

In Lua, you should do require"cdluadirect2d". The cdInitDirect2D call is not necessary in Lua.

Extra Drivers (cddirect2d.h)

These are not ContextPlus drivers.

CD_DIRECT2D_NATIVEWINDOW - Native window Driver

Same as CD_NATIVEWINDOW, uses the same creation parameters. It is already double buffered and requires cdCanvasFlush to be called.

CD_DIRECT2D_IMAGE - Server Image Driver

Same as CD_IMAGE, uses a server image created by the native window driver.

CD_DIRECT2D_IMAGERGB - RGB Client Image Driver

Similar to CD_IMAGERGB, but accept only the size "wxh" as parameter. The image is always 32 bits per pixel RGBA and created internally. The data buffer can be obtained using the cdCanvasGetImageRGB function.

Behavior of Functions

Control

Coordinate System and Clipping

Primitives

Attributes

Colors

Client Images

Server Images

Exclusive Attributes