#ifndef	V_STROKE_H
#define	V_STROKE_H

/* 
 *	Extended information can be optionally associated with each
 *	polyline, glyph and object; attribute sizes must be passed
 *	to meshCreateStrokesEx().
 */
  
typedef struct	mesh_stroke_s	/* single polyline */
{
	u32_t		num_coords;		/* number of geometry data */
	vec3_t		*coords;		/* geometry data */
	void_p		attrib;			/* user-defined attribute */
}	mesh_stroke_t, *mesh_stroke_p;

#ifndef	GL_VERTEX3V
#ifdef	DOUBLEVEC
#define	GL_VERTEX3V	glVertex3dv
#else	/* !DOUBLEVEC */
#define	GL_VERTEX3V	glVertex3fv
#endif	/* !DOUBLEVEC */
#endif	/* !GL_VERTEX3V */

#define	DRAW_STROKE(stroke) { \
			u32_t i,len=(stroke).num_coords; \
            glBegin(GL_LINE_STRIP); \
			for(i=0;i<len;i++) \
				GL_VERTEX3V((stroke).coords[i]); \
			glEnd(); \
		}

#ifdef	__cplusplus
extern	"C" {
#endif		/* __cplusplus */
	/* Constructor and destructor */
	vhandle_t	V_GLOBAL	meshCreateStrokesEx(
		u32_t attrib_size,				/* per - object attribute */
		u32_t per_glyph_attrib_size,	/* per - glyph attribute */
		u32_t per_stroke_attrib_size);	/* per - stroke attribute */
	vhandle_t	V_GLOBAL	meshCreateStrokes(void);
    void	V_GLOBAL	meshDeleteStrokes(vhandle_t ms);
    /* Methods for creation of glyphs */
	void	V_GLOBAL	meshStrokeCoord(vhandle_t ms,
    	vec_t x,vec_t y,vec_t z);
	void	V_GLOBAL	meshStrokeCoordv(vhandle_t ms,vec3_t xyz);
	/* Returns number of new stroke or -1 on error */
	s32_t	V_GLOBAL	meshEndStroke(vhandle_t ms);
	void	V_GLOBAL	meshCancelStroke(vhandle_t ms);
	/* Returns number of new glyph or -1 on error */
	s32_t	V_GLOBAL	meshEndGlyph(vhandle_t ms);
	void	V_GLOBAL	meshCancelGlyph(vhandle_t ms);
	/* Releases temporary buffers */
	void	V_GLOBAL	meshFinishStrokes(vhandle_t ms);
	/* Returns number of complete glyphs */
	u32_t	V_GLOBAL	meshGlyphCount(vhandle_t ms);
	/* Returns number of complete strokes for uncomplete glyph */
	u32_t	V_GLOBAL	meshStrokesCount(vhandle_t ms,
    	u32_t glyph_num);
	/* Returns attribute sizes */
	vboolean V_GLOBAL 	meshStrokeAttribSizes(vhandle_t ms,
		u32_t *per_stroke_attrib_size_ret,
		u32_t *per_glyph_attrib_size_ret,
		u32_t *attrib_size_ret);
	/* Returns stroke # 'stroke_num' of glyph # 'glyph_num' */
	mesh_stroke_p	V_GLOBAL meshGlyphStroke(vhandle_t ms,
    	u32_t glyph_num,u32_t stroke_num);
	/* Returns pointer to attribute buffer for glyph # 'glyph_num' */
	void_p	V_GLOBAL	meshGlyphAttrib(vhandle_t ms,u32_t glyph_num);
	/* Returns pointer to attribute buffer of object */
	void_p	V_GLOBAL 	meshStrokesAttrib(vhandle_t ms);
#ifdef	__cplusplus
}
#endif		/* __cplusplus */

#endif	/* V_STROKE_H */
