GL Driver
This driver represents a driver for drawing using
OpenGL. The implementation uses the OpenGL functions only.
For the font support, this driver uses the
FTGL library, which it was written against the
Free Type library. Currently CD is
using the FTGL version 2.1.3-rc5 with modifications.
The CD distribution includes the FTGL library, this is a third party
library not developed at Tecgraf. GTL and Freetype licenses are also free and have the
same freedom as the Tecgraf Library License. You
can read the license and copyright in the files
ftgl.txt and freetype.txt. FTGL is copyright to Henry Maddocks.
The driver is not dependent of system functions. It uses only the OpenGL
portable functions. So if the window canvas changes its size the attribute "SIZE"
must be set with the new size.
Use
The canvas is created by means of a call to the function
cdCreateCanvas(CD_GL,
Data), after which other functions in the CD library can be called as usual. The Data parameter string has the following format:
"widthxheight [resolution]" in C "%dx%d %g"
It must include the initial canvas' dimensions. Width and height
are provided in pixels (note the lowercase "x" between them). If
width or height are 0 then 1 will be used. The
resolution is optional, its default value is "3.78 pixels/mm" (96 DPI).
IMPORTANT: When the canvas
is created the OpenGL rendering context must already be set with the *MakeCurrent
native system function.
To use this driver, the application must be linked with the "cdgl",
the ftgl library and the OpenGL library. The FTGL library is dependent also
on the GLU library.
In Lua, it is necessary to call function cdluagl_open() after a call
to function cdlua_open(), apart from linking with the "cdluagl"
library. This is not necessary if you do require"cdluagl".
Behavior of Functions
Control
-
Activate: updates the OpenGL viewport and default
transformation. The SIZE attribute must be updated before
activating the canvas. It will reset the current transformation.
-
Play: does nothing, returns
CD_ERROR.
Coordinate System and Clipping
-
UpdateYAxis: does nothing.
-
Clipping: only support rectangular areas.
-
Complex Regions: not supported.
Primitives
-
Begin: CD_PATH
is simulated. CD_FILL allows convex polygons only.
- Floating point primitives are supported.
Client Images
- When OpenGL version is greater than 1.x, images are handled with
textures and follow transformation and clipping. When OpenGL version is 1.x
images are bitmaps, and do NOT follow transformation and can not be
positioned outside the clipping region.
Attributes
-
LineStyle: in
CD_CUSTOM, style patterns more than 16 bits are not supported.
-
LineCap: does nothing.
-
LineJoin: does nothing.
-
Stipple:
does nothing.
-
Pattern:
does nothing.
-
FillMode: does nothing.
-
NativeFont: also accepts the
X-Windows font string format.
-
Font: Uses the same logic of the Simulation
driver to find a Truetype font file, but ADDFONTMAP is not supported.
Colors
Exclusive Attributes
- "ALPHA": allows the usage of an alpha
channel for the drawing shapes. Assumes values "1" (active) and "0"
(inactive). Default value: "1".
- "ANTIALIAS": allows the use of
anti-aliasing for the drawing shapes. Assumes values "1" (active) and "0"
(inactive). Default value: "1".
- "GLVERSION": returns a string with
the OpenGL version or release number. It is empty if the OpenGL is not available.
- "IMGINTERP": changes how
interpolation is used in image scale. Can be "BEST" (highest-quality),
"BILINEAR" (linear interpolation), "GOOD" (quality similar to BILINEAR),
"NEAREST" (nearest-neighbor filtering) or "FAST" (quality similar to NEAREST).
Default: "GOOD". (since 5.8.3)
- "ROTATE": allows the usage of 1
angle and 1 coordinate (x, y), that define a global rotation transformation
centered in the specified coordinate. Use 1 real and 2 integer values inside a
string ("%g %d %d" = angle x y).
- "SIZE": sets the canvas size.
Must be used after the window is resized. The format is the same of the data
parameter in cdCreateCanvas, "widthxheight [resolution]"
or in C "%dx%d %g".
IMPORTANT: this attribute
must be updated when the canvas window size is changed.
- "UTF8MODE": enables the usage
of the UTF-8 encoding for strings. It can have the following
values: "1" or "0". Default is "0".