NAME
	tdDraw() - draw an object in immediate mode
	
C SPECIFICATION

	TDboolean tdDraw(TDobject *object,
			 TDprimitive mode,
			 int mask)

PARAMETERS

	object - valid TDobject.

	mode   - primitive drawing mode.  Symbolic constants TD_POINTS,
	         TD_LINES, TD_LINE_LOOP, TD_LINE_STRIP, TD_TRIANGLES,
		 TD_TRIANGLE_STRIP, TD_TRIANGLE_FAN, TD_QUADS, TD_QUAD_STRIP,
		 TD_POLYGON are accepted.

	mask   - bitwise OR of masks that indicate the type of data that is
		 to be used for rendering.  The masks are TD_VERTEX, TD_NORMAL,
		 TD_TEXVERTEX, and TD_MATERIAL.  In addition to these, the
		 mask TD_ALL is provided as a shortcut for specifying all of
		 the masks.

RETURN VALUES

	TD_TRUE if all went well, 
	TD_FALSE if an error occurred

DESCRIPTION

	tdDraw makes the appropriate calls to OpenGL to render a TDobject.
	It renders the object in immediate mode (not display list mode).

	tdDraw renders an object using the primitive mode specified by the
	mode parameter.  The mode parameter can be one of the following:

		TD_POINTS          - draw the objects as points
		TD_LINES           - draw the object as a set of lines
				     according to each polygons edges.
		TD_LINE_LOOP       - draw the object as a set of line loops
				     according to each polygons edges.
		TD_LINE_STRIP      - draw the object as a set of line strips
				     according to each polygons edges.
		TD_TRIANGLES       - draw the object as triangles.	
		TD_TRIANGLE_STRIP  - draw the object as triangle strips
		TD_TRIANGLE_FAN    - draw the object as triangle fan by
				     splitting up each polygon into a triangle
				     strip.
		TD_QUADS           - draw the object as quadrilaterals
		TD_QUAD_STRIP      - draw the object as quad strips 
		TD_POLYGON         - draw the object as polygons 

	Currently the modes TD_TRIANGLE_STRIP and TD_QUAD_STRIP are not
	yet implemented.  If the modes TD_TRIANGLES or TD_QUADS are desired,
	the object must have the appropriate data built with calls to 
	tdGenTriangles() or tdGenQuads() respectively or an error is generated.

	If the mode is TD_POINTS, no material parameters are sent.  The color
	of the points will reflect the current material parameters.

	A mask of at least TD_VERTEX must be specified for anything to be
	drawn.  If TD_NORMAL, TD_TEXVERTEX or TD_MATERIAL are specified,
	the corresponding data must be available in the object, or a 
	warning is generated.  (See tdGen*Normals() or tdGen*Texvertices())
	tdDraw will draw the object according to the mask parameter.  If
	the mask parameter is TD_VERTEX, then ONLY vertex data will be
	used to draw the object (i.e., no normals/texvertices/materials).
	Therefore, to get a fully colored, textured, lit object, a mask of
	TD_VERTEX | TD_TEXVERTEX | TD_NORMAL | TD_MATERIAL (or TD_ALL) must
	be specified.

ERRORS
	TD_ERROR if object is null.
	TD_ERROR if mode is TD_TRIANGLES or TD_QUADS and there is no
	         triangle or quad data respectively.
	TD_WARNING if mask is TD_TEXVERTEX and there are no texture vertices
		   in the object.
	TD_WARNING if mask is TD_NORMAL and there are no normals in the
		   object.



NAME
	tdGenDList() - build a display list for an object
	
C SPECIFICATION

	int tdGenDList(TDobject *object,
		       TDprimitive mode,
		       int mask)

PARAMETERS

	object - valid TDobject.

	mode   - primitive drawing mode.  Symbolic constants TD_POINTS,
	         TD_LINES, TD_LINE_LOOP, TD_LINE_STRIP, TD_TRIANGLES,
		 TD_TRIANGLE_STRIP, TD_TRIANGLE_FAN, TD_QUADS, TD_QUAD_STRIP,
		 TD_POLYGON are accepted.

	mask   - bitwise OR of masks that indicate the type of data that is
		 to be used for rendering.  The masks are TD_VERTEX, TD_NORMAL,
		 TD_TEXVERTEX, and TD_MATERIAL.  In addition to these, the
		 mask TD_ALL is provided as a shortcut for specifying all of
		 the masks.

RETURN VALUES

	The number of the list generated if all went well,
	0 if an error occurred.

DESCRIPTION
	tdGenDList creates a display list containing the appropriate calls to
	OpenGL to render a TDobject.  The display list is only COMPILED, it is
	NOT executed when tdGenDList is called.  Use glCallList() to actually
	send the rendering commands.

	tdGenDList renders an object using the primitive mode specified by the
	mode parameter.  The mode parameter can be one of the following:

		TD_POINTS          - draw the objects as points
		TD_LINES           - draw the object as a set of lines
				     according to each polygons edges.
		TD_LINE_LOOP       - draw the object as a set of line loops
				     according to each polygons edges.
		TD_LINE_STRIP      - draw the object as a set of line strips
				     according to each polygons edges.
		TD_TRIANGLES       - draw the object as triangles.	
		TD_TRIANGLE_STRIP  - draw the object as triangle strips
		TD_TRIANGLE_FAN    - draw the object as triangle fan by
				     splitting up each polygon into a triangle
				     strip.
		TD_QUADS           - draw the object as quadrilaterals
		TD_QUAD_STRIP      - draw the object as quad strips 
		TD_POLYGON         - draw the object as polygons 

	Currently the modes TD_TRIANGLE_STRIP and TD_QUAD_STRIP are not
	yet implemented.  If the modes TD_TRIANGLES or TD_QUADS are desired,
	the object must have the appropriate data built with calls to 
	tdGenTriangles() or tdGenQuads() respectively or an error is generated.

	If the mode is TD_POINTS, no material parameters are sent.  The color
	of the points will reflect the current material parameters.

	A mask of at least TD_VERTEX must be specified for anything to be
	drawn.  If TD_NORMAL, TD_TEXVERTEX or TD_MATERIAL are specified,
	the corresponding data must be available in the object, or a 
	warning is generated.  (See tdGen*Normals() or tdGen*Texvertices())
	tdDraw will draw the object according to the mask parameter.  If
	the mask parameter is TD_VERTEX, then ONLY vertex data will be
	used to draw the object (i.e., no normals/texvertices/materials).
	Therefore, to get a fully colored, textured, lit object, a mask of
	TD_VERTEX | TD_TEXVERTEX | TD_NORMAL | TD_MATERIAL (or TD_ALL) must
	be specified.

ERRORS
	TD_ERROR if object is null.
	TD_ERROR if mode is TD_TRIANGLES or TD_QUADS and there is no
	         triangle or quad data respectively.
	TD_WARNING if mask is TD_TEXVERTEX and there are no texture vertices
		   in the object.
	TD_WARNING if mask is TD_NORMAL and there are no normals in the
		   object.



NAME
	tdWriteObject() - writes an object out to a file
	
C SPECIFICATION

	TDboolean tdWriteObject(TDobject *object,
		 		char *pathname)

PARAMETERS

	object   - valid TDobject.

	pathname - filename of the file the object is to be written in.


RETURN VALUES

	TD_TRUE if all went well, 
	TD_FALSE if an error occurred

DESCRIPTION

	Any valid TDobject may be written to a file in any of the supported
	formats.  The supported formats are:

		.obj   - Wavefront file format
		.aoff  - DEC Object File Format 
		.dxf   - Drawing Interchange File format (Autodesk)
		.iob   - Lightwave 3D Object File format 
		.tddd  - Imagine File format 
    
	tdWriteObject() uses the extension of the pathname to determine which
	type of object file format to write.  Therefore, the pathname should
	be of the format path+filename+extension.  For example, if the object
	name were 'apple' and the desired output was to be in the directory
	/objects/wavefront in Wavefront .obj format, the pathname would be
	"/object/wavefront/apple.obj".  If the output is to be to a file
	in the current directory, the path portion of the pathname may be 
	omitted.

	tdWriteObject() doesn't check to see if there is already a file with
	the name pathname, so all checking for this should be done in the
	clients code.

	Writing of anything but Wavefront file format is unsupported in this
	implimentation of TD-Lib.

	The .obj (geometry) file is always written, but the .mtl (material
	parameters) file is only written if material parameters exist for the
	object.  Textures associated with the materials are not written, but
	the filename of any texture is placed appropriately in the .mtl file.

ERRORS
	TD_ERROR if object is null.
	TD_ERROR if pathname cannot be opened.



NAME
	tdReadObject() - reads an object from a file
	
C SPECIFICATION

	TDobject *tdReadObject(char *pathname)

PARAMETERS

	pathname - filename of the file to read the object from.


RETURN VALUES

	A pointer to the object if all went well,
	NULL if an error occurred.

DESCRIPTION

	A TDobject may be read from a file in any of the the supported
	formats.  The supported formats are:

		.obj   - Wavefront file format
		.aoff  - DEC Object File Format 
		.dxf   - Drawing Interchange File format (Autodesk)
		.iob   - Lightwave 3D Object File format 
		.tddd  - Imagine File format 
    
	tdReadObject() uses the extension of the pathname to determine which
	type of object file format to read.  Therefore, the pathname should
	be of the format path+filename+extension.  For example, if the object
	name were 'apple' and the desired input file is in the directory
	/objects/wavefront in Wavefront .obj format, the pathname would be
	"/object/wavefront/apple.obj".  If the input is to be from a file
	in the current directory, the path portion of the pathname may be 
	omitted.

	Reading of .dxf, .iob, and .tddd file formats is unsupported in this
	implimentation of TD-Lib.

	If reading Wavefront files, in addition to the .obj file, any .mtl
	(material parameters) files specified in the .obj file will be read.

ERRORS
	TD_ERROR if pathname cannot be opened.



NAME
	tdReadTeximage() - reads a texture image file
	
C SPECIFICATION

	TDteximage *tdReadTeximage(char *filename)

PARAMETERS

	pathname - filename of the file to read the texture from.


RETURN VALUES

	A pointer to the texture image if all went well,
	NULL if an error occurred.

DESCRIPTION

	A TDteximage may be read from a file in any of the the supported
	formats.  The supported formats are:

		.rgb  - Iris RGB format
		.gif  - Graphics Interchange Format
		.jpeg - JPeg format
		.tif  - TIFF format
    
	tdReadTeximage() uses the extension of the pathname to determine which
	type of image file format to read.  Therefore, the pathname should
	be of the format path+filename+extension.  For example, if the texture
	name were 'apple' and the desired input file is in the directory
	/textures/rgb/ in Iris RGB (.rgb) format, the pathname would be
	"/textures/rgb/apple.rgb".  If the input is to be from a file
	in the current directory, the path portion of the pathname may be 
	omitted.

	Reading of .gif, .jpeg, and .tif file formats is unsupported in this
	implimentation of TD-Lib.

ERRORS
	TD_ERROR if pathname cannot be opened.



NAME
	tdGenTriangles() - Generates triangles from polygonal data
	
C SPECIFICATION

	int tdGenTriangles(TDobject *object)

PARAMETERS

	object - a valid TDobject.

RETURN VALUES

	The number of triangles the object was broken into if
	all went well, 0 if an error occurred.

DESCRIPTION

	tdGenTriangles() generates triangles from polygonal data by
	marching along the edge of the polygon, and connects the first
	vertex to the next two, then connects the first vertex to 
	vertexes 3 and 4 and so on. (Essentially making a triangle fan
	out of each polygon.)  This algorithm assumes that the
	polygons are convex.

ERRORS
	TD_ERROR if object is NULL.



NAME
	tdGenQuads() - Generates quadrilaterals (quads) from polygonal data
	
C SPECIFICATION

	int tdGenQuads(TDobject *object)

PARAMETERS

	object - a valid TDobject.

RETURN VALUES

	The number of quads the object was broken into if
	all went well, 0 if an error occurred.

DESCRIPTION

	tdGenQuads() generates quadrilaterals (quads) from polygonal data by
	marching along the edge of the polygon, and connects the first
	vertex to the next three, then connects the first vertex to 
	vertexes 4 and 5 and so on.  Unfortunately, since a polygon can
	consist of an odd number of vertices, this algorithm generates
	some degenerate quads, that is, quads that have repeated vertices.
	(Basically a triangle with the last vertex repeated).  This algorithm
	assumes that the polygons are convex.

ERRORS
	TD_ERROR if object is NULL.



NAME
	tdGenSmoothNormals() - Generates smooth(ish) vertex normals.
	
C SPECIFICATION

	TDnormal *tdGenSmoothNormals(TDobject *object)

PARAMETERS

	object - a valid TDobject.

RETURN VALUES

	A pointer to the normals if all went well,
	NULL if an error occurred.

DESCRIPTION

	tdGenSmoothNormals() generates smooth vertex normals by
	calculating the cross product of two vectors in the same plane as
	the face (effectively getting the normal of the face), and uses this
	normal as the normal for all vertices in the face.  Assuming that 
	vertices are shared between faces, some of the vertex normals for a
	given face will be written more than once with different values each
	time, which gives a smoother appearance to the object.

	Generating normals overrides any existing normals in the object.  A
	warning is issued if this occurs.	

ERRORS
	TD_ERROR if object is NULL.
	TD_ERROR if vertices do not exist in object.



NAME
	tdGenSpheremapTexvertices() - Generates spheremap texvertices
	
C SPECIFICATION

	TDtexvertex *tdGenSpheremapTexvertices(TDobject *object)

PARAMETERS

	object - a valid TDobject.

RETURN VALUES

	A pointer to the texvertices if all went well,
	NULL if an error occurred.

DESCRIPTION

	tdGenSpheremapTexvertices generates texture coordinates according to
	a spherical projection of the texture map.  Sometimes referred to as
	spheremap, or reflection map texture coordinates.  It generates these
	by using the normal to calculate where that vertex would map onto
	a sphere.  Since it is impossible to map something flat perfectly
	onto something spherical, there is distortion at the poles.  This
	particular implementation causes the poles along the X axis to be
	distorted.

	Generating texvertices overrides any existing texvertices in the
	object.  A warning is issued if this occurs.	

ERRORS
	TD_ERROR if object is NULL.
	TD_ERROR if normals do not exist in object.



NAME
	tdGenLinearTexvertices() - Generates linear texvertices
	
C SPECIFICATION

	TDtexvertex *tdGenLinearTexvertices(TDobject *object)

PARAMETERS

	object - a valid TDobject.

RETURN VALUES

	A pointer to the texvertices if all went well,
	NULL if an error occurred.

DESCRIPTION
	
	tdGenLinearTexvertices generates texture coordinates according to a
	linear projection of the texture map.  It generates these by linearly
	mapping the vertices onto a square.

	Generating texvertices overrides any existing texvertices in the
	object.  A warning is issued if this occurs.	

ERRORS
	TD_ERROR if object is NULL.
	TD_ERROR if normals do not exist in object.



NAME
	tdVerbose() - Set the verbosity level of messages
	
C SPECIFICATION

	void tdVerbose(TDboolean verbose)

PARAMETERS
	verbose - boolean true or false

DESCRIPTION
	
	tdVerbose() sets verbose messages on or off, depending on the
	parameter verbose which may be one of the following:
		GL_TRUE   - print out everything (default)
		GL_FALSE  - only print out error messages (no warning or info)



NAME
	tdNewObject() - Create a new TDobject
	
C SPECIFICATION

	TDobject *tdNewObject(char *name)

PARAMETERS

	name - name of the object being created.

RETURN VALUES

	A pointer to the new object if all went well,
	NULL if an error occurred.

DESCRIPTION
	
	tdNewObject() allocates memory for an object data strucrure, and fills
	the new structure with default values.
	
	The tdReadObject() function calls this internally, so there is no
	need to call this function unless the user wishes to create their
	own object from scratch.



NAME
	tdDeleteObject() - Delete a TDobject
	
C SPECIFICATION

	void tdDeleteObject(TDobject *object)

PARAMETERS

	object - a pointer to a valid TDobject

DESCRIPTION
	
	tdDeleteObject() frees all memory associated with a TDobject
	data structure.



NAME
	tdDeleteObject() - Delete a TDobject
	
C SPECIFICATION

	void tdDeleteObjects(TDobject *object)

PARAMETERS

	object - a pointer to a valid TDobject

DESCRIPTION
	
	tdDeleteObjects() frees all memory associated with a TDobject
	data structure.

	NOTE that this routine goes through the WHOLE LIST of
	objects (until it hits a NULL) and frees ALL of them
	including any memory associated with them (such as
	materials and groups)

	This should be called when the client is going to be shutdown.



NAME
	tdSize() - Scales an object by a scalefactor.
	
C SPECIFICATION

	float tdSize(TDobject *object, float scalefactor)

PARAMETERS

	object      - a pointer to a valid TDobject

	scalefactor - factor to scale by

RETURN VALUES

	The scalefactor used if all goes well,
	0.0 if an error occurred.

DESCRIPTION
	
	tdScale() translates an object to the origin (0,0,0) and
	scales it by a scalefactor.

	If the scalefactor is zero (0.0), then the object is scaled by the
	maximum dimension of the object (this causes the
	object to be scaled to between -1.0 and 1.0 in all
	dimensions.

ERRORS
	TD_ERROR if object is NULL.



NAME
	tdGetError() - Retrieves the current error
	
C SPECIFICATION

	TDmessage tdGetError()

RETURN VALUES

	The current error (if one), may be one of the following:
	  TD_INFO     - informational message sent (no error)
	  TD_WARNING  - a warning was issued (no error)
	  TD_ERROR    - an error occurred
	  TD_NOMEMORY - there was insufficient memory for an operation
	  TD_FATAL    - a fatal error occurred

DESCRIPTION
	
	tdGetError() returns a value according to the current state of
        internal TD-Lib errors. 

	See the ERRORS section of each TD-Lib function call description
        for a list of errors that can be generated by each function.

