FreeSG is a general-purpose scene-graph library built on top of the Agar library ( FreeSG implements a compact and easily extensible object/scene graph representation, designed to simplify such tasks as real-time rendering and geometrical queries.

In addition to the base scene-graph library (libfreesg), the FreeSG distribution also includes a separate library for geometrically constrained 2D sketching (libfreesg_sk), and a library for tiling (libfreesg_map). These libraries share the same version number and release cycle, but they are separate and can be always packaged and distributed independently.


Since the FreeSG API Reference is also intended as a detailed specification (defining function prototypes, structures and function behavior in detail), the content can become repetitive and difficult to read, so the API Reference uses a number of conventions:
  1. The return value for functions returning int, unless otherwise documented, represents an error code (where 0 = success, -1 = failure). On failure, the error message can be retrieved using the standard Agar function AG_GetError(3).
  2. When FreeSG and Agar are both compiled with threads support, functions are thread-safe unless documented otherwise (see CONVENTIONS section of AG_Threads(3) for important details related to thread safety which also apply to FreeSG).

FreeSG uses the Agar object system. There is generally one manual page per Agar object class. A number of manual page sections are standard throughout the documentation, this includes:
INHERITANCE HIERARCHYList of parent (inherited) classes. See AG_Object(3) for details on inheritance with the Agar object system.
EVENTSList of events defined by this object (and optionally, a list of events potentially raised by this object). See AG_Event(3) for details on Agar events.
STRUCTURE DATAList of public structure members which are safe to access directly (in the specified way). Function interfaces are always available so developers who prefer to use them exclusively can ignore these sections.

Note: Multithreaded applications must use AG_ObjectLock(3) prior to accessing this data (although the object can be assumed locked in some contexts, see AG_Event(3) for details).


The base freesg library implements scene rendering and geometrical methods in 3D.

To use this library, link against freesg-config --libs
SG(3) Base scene graph object.
SG_Image(3) Textured polygon generated from an image surface.
SG_Camera(3) Viewpoint in scene (tied to the SG_View(3) widget).
SG_CgProgram(3) Vertex/fragment program in the Cg language.
SG_Circle(3) Circle (reference geometry).
SG_Geom(3) Base class for reference geometry objects.
SG_Light(3) Light source.
SG_Node(3) Base class for all elements of a SG(3) scene.
SG_Object(3) Base class for polyhedral objects (using boundary representation).
SG_Plane(3) Plane (reference geometry).
SG_Point(3) Single point (reference geometry).
SG_Polygon(3) Polygon (reference geometry).
SG_PolyBall(3) Sphere (as polyhedral approximation).
SG_PolyBox(3) Rectangular box (as polyhedron).
SG_Program(3) Base class for vertex or fragment programs.
SG_Rectangle(3) Rectangle (reference geometry).
SG_Sphere(3) Sphere (reference geometry).
SG_Texture(3) A texture compiled from a set of surfaces. May also be used to specify parameters for the fixed lighting model.
SG_Triangle(3) Triangle (reference geometry).
SG_View(3) Agar visualization widget for displaying a SG scene.
SG_Voxel(3) Voxel object.


The freesg_sk library implements the standard dimensioned 2D sketching capabilities one would find in a modern CAD application. Sketches can contain sets of metric relations (i.e., distances, angles) and logical relations (i.e., coincidence, parallelism, tangency), and the SK solver attempts to find a solution using degree-of-freedom analysis.

To use this library, link against freesg-sk-config --libs.
SK(3) Base sketch object.
SK_View(3) Agar visualization widget for sketch objects.


The freesg_map library implements scenes constructed from traditional 2D tiling methods.

To use this library, link against freesg-map-config --libs.
MAP(3) Base map object.
MAP_Actor(3) Map object rendered dynamically.
MAP_View(3) Agar visualization widget for map objects.