00001 #ifndef _TESSELATOR_H_ 00002 #define _TESSELATOR_H_ 00003 00004 #include <list> 00005 #include <utility> 00006 00007 #include <ft2build.h> 00008 #include FT_FREETYPE_H 00009 00010 #include SYS_GL_HEADER 00011 #include SYS_GLU_HEADER 00012 #include <vectorizer.h> 00013 00014 #if defined(__WIN32__) || defined(_WIN32) 00015 #define CALL_CONVENTION __stdcall 00016 #else 00017 #define CALL_CONVENTION 00018 #endif 00019 00020 #ifdef __APPLE_CC__ 00021 typedef GLvoid (*GLUTesselatorFunction)(...); 00022 #elif defined( __mips ) || defined( __linux__ ) || defined( __FreeBSD__ ) || defined( __OpenBSD__ ) || defined( __sun ) || defined (__CYGWIN__) 00023 typedef GLvoid (*GLUTesselatorFunction)(); 00024 #elif defined(__WIN32__) || defined(_WIN32) 00025 typedef GLvoid (CALL_CONVENTION *GLUTesselatorFunction)( ); 00026 #else 00027 #error "Error - need to define type GLUTesselatorFunction for this platform/compiler" 00028 #endif 00029 00030 namespace glttf { 00031 00033 00039 class Tesselator 00040 { 00041 public: 00043 00052 Tesselator(Vectorizer &vectorizer, int windingRule); 00053 00055 ~Tesselator(); 00056 00058 00064 void draw(float nx = 0.0f, float ny = 0.0f, float nz = 1.0f, float z = 0.0f) const; 00065 00066 private: 00067 typedef std::pair<float, float> Vertex; 00068 typedef std::list<Vertex> VertexList; 00069 typedef std::pair<GLenum, VertexList> Primitive; 00070 typedef std::list<Primitive> PrimitiveList; 00071 00072 PrimitiveList primitives; 00073 Primitive *currentPrimitive; 00074 00075 static void CALL_CONVENTION vertexCallback(void *data, Tesselator *tess); 00076 static void CALL_CONVENTION errorCallback(GLenum error, Tesselator *tess); 00077 static void CALL_CONVENTION beginCallback(GLenum primitive, Tesselator *tess); 00078 static void CALL_CONVENTION combineCallback(GLdouble coords[3], void *vertex_data[4], GLfloat weight[4], GLdouble **dataOut, Tesselator *tess); 00079 static void CALL_CONVENTION endCallback(Tesselator *tess); 00080 00081 void beginPrimitive(GLenum primitive); 00082 void addVertex(float x, float y); 00083 void endPrimitive(); 00084 00085 std::list<GLdouble*> tempData; 00086 void addTempData(GLdouble *data); 00087 void freeTempData(); 00088 00089 void tesselate(Vectorizer &vectorizer, GLUtesselator *tess, GLdouble *data); 00090 }; 00091 00092 } 00093 00094 #endif