From 7b52cc13af4e85f1ca2deb6b6c77de9c95ea0dcf Mon Sep 17 00:00:00 2001 From: scuri Date: Fri, 17 Oct 2008 06:10:33 +0000 Subject: First commit - moving from LuaForge to SourceForge --- html/en/guide.html | 161 +++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 161 insertions(+) create mode 100644 html/en/guide.html (limited to 'html/en/guide.html') diff --git a/html/en/guide.html b/html/en/guide.html new file mode 100644 index 0000000..e6d393c --- /dev/null +++ b/html/en/guide.html @@ -0,0 +1,161 @@ + + + + + + + +Guide + + + + + + +

Guide

+

Getting Started

+ +

The CD library is a basic graphic library (GL). In a GL paradigm you use primitives, which have + attributes, to draw on a canvas. All the library functions reflect this paradigm.

+

The canvas is the basic element. It can have several forms: a paper, a video monitor, a graphic + file format, etc. The virtual drawing surface where the canvas exists is represented by a driver. + Only the driver knows how to draw on its surface. The user does not use the driver directly, but only the canvas.

+

To make the library simple we use the concept of an active canvas, over which all the primitives are drawn. This + also allows the use of an expansion mechanism using function tables. Unfortunately if a function is called without an + active canvas a memory invasion will occur. On the other hand, the mechanism allows the library to be expanded with + new drivers without limits.

+

The attributes are also separated from the primitives. They reside in the canvas in a state + mechanism. If you change the attribute's state in the canvas all the primitives drawn after that canvas and that + depend on the attribute will be drawn in a different way.

+

The set of primitives is very small but complete enough to compose a GL. Some primitives are + system dependent for performance reasons. Some drivers (window and device based) use system functions to optimally + implement the primitives. Sometimes this implies in a in small different behavior of some functions. Also some + primitives do not make sense in some drivers, like server images in file-based drivers.

+

The set of available functions is such that it can be implemented in most drivers. Some drivers have sophisticated + resources, which cannot be implemented in other drivers but can be made available using a generic attribute mecanism. +

+ +

Building Applications

+ +

All the CD functions are declared in the cd.h header file; World Coordinate functions are declared in the + wd.h header file; and each driver has a correspondent header file that must be included to create a canvas. + It is important to include each driver header after the inclusion of the cd.h header file.

+

To link the application you must add the cd.lib/libcd.a/libcd.so and + freetype6.lib/libfreetype.a/libfreetype.so libraries to the linker options. If you use + an IUP Canvas then you must also link with the iupcd.lib/libiupcd.a/libiupcd.so library + available in the IUP distribution.

+

In UNIX, CD uses the Xlib (X11) libraries. To link an application in UNIX, add also the "-lX11" option in the linker call.

+

The download files list includes the Tecgraf/PUC-Rio Library + Download Tips document, with a description of all the available binaries.

+ +

Building the Library

+ +

In the Downloads you will ne able to find pre-compiled binaries for many +platforms, all those binaries were built using Tecmake. Tecmake is a command line multi compiler build tool +based on GNU make, available at + http://www.tecgraf.puc-rio.br/tecmake. Tecmake is + used by all the Tecgraf libraries and many applications.

+

In UNIX, you do not need to install Tecmake, a compact version of Tecmake for +UNIX is already included in the source code package. Just type "make" in the +command line on the "src" folder and all libraries and executables will be +build. +

+

In Windows, the easiest way to build everything is to install the Tecmake tool into your system. It is easy and helps a lot. + The Tecmake configuration files (*.mak) available at the "src" folder are very easy to understand also. +Also there are files named +make_uname.bat that build the libraries using Tecmake. To build for Windows using + Visual C 7.0 (2005) for example, just execute "make_uname vc7" , or the +DLLs with Visual C++ 9 (2008) type "make_uname dll9". The Visual +Studio workspaces with the respective projects available in the source package +is for debugging purposes only.

+

Make sure you have all the dependencies for the library you want installed, +see the documentation bellow.

+

If you are going to build all the libraries, +the makefiles and projects expect the following directory tree:

+
\mylibs\
+        cd\
+        im\
+        lua5.1\
+

Libraries Dependencies

+
cd -> gdi32 user32 comdlg32 (system - Windows)
+   -> X11 (system - UNIX)
+   -> FreeType (included as separate library)
+cdgdiplus -> cd
+          -> gdiplus (system - Windows)
+cdxrender -> cd
+          -> Xrender Xft (system - UNIX)
+cdpdf    -> pdflib (included as separate library)
+cdlua51  -> cd
+         -> lua5.1
+cdluaim51 -> cdlua51
+          -> imlua51 
+cdluapdf51 -> cdlua51
+           -> cdpdf
+

As a general rule (excluding system dependencies and included third party +libraries): CD has NO external dependencies, and CDLua depends on Lua and IMLua. +Just notice that not all CDLua libraries depend on IMLua.

+ +

Environment Variables

+ +

CDDIR - This environment variable is used by some drivers to locate useful + data files, such as font definition files. It contains the directory path without the final slash.
+ CD_QUIET - In UNIX, if this variable is defined, it does not show the library's + version info on sdtout.
+ CD_XERROR - In UNIX, if this variable is + defined, it will show the X-Windows error messages on sdterr.

+ +

Implementing a Driver

+ +

The best way to implement a new driver is based on an existing one. For this reason, we provide + a code of the + simplest driver possible, see CDXX.H and CDXX.C. + But first you should read the Internal Architecture.

+ +

Intercepting Primitives

+ +

To fill data structures of library primitives during a cdPlay call you must + implement a driver and activate it before calling cdPlay. Inside your driver + primitives you can fill your data structure with the information interpreted by the cdPlay + function.

+ +

IUP Compatibility

+ +

The IupCanvas element of the IUP + interface toolkit can be used as a visualization surface for a CD canvas. There are two moments in which one must be + careful when an application is using both libraries: when creating the CD canvas, and when changing the size of the + IUP canvas.

+

Creating the CD Canvas

+ +

The CD_IUP driver parameter needs only the Ihandle* of the + IupCanvas. But cdCreateCanvas must be called after the IupCanvas element has been + mapped into the native system.

+

But a call to IupShow generates an ACTION callback. And a + direct call to IupMap can generate a RESIZE_CB callback. 

+

So the best way to create a CD canvas for a IUP canvas is to use the + IupCanvas MAP_CB callback. This callback will be always called before + any other callback.

+ +

The application must be linked with the iupcd + library that it is available in the IUP package.

+ +

Resizing the IUP Canvas

+ +

When a IupCanvas is resized the CD canvas must be notified of the size + change. To do that simply call cdCanvasActivate in the + RESIZE_CB callback.

+ + + + + + -- cgit v1.2.3