cbe3c8df1176f17791f2217816a3e6514f9cb1a6
[reactos.git] / reactos / dll / glu32 / libtess / tess.h
1 /*
2 ** License Applicability. Except to the extent portions of this file are
3 ** made subject to an alternative license as permitted in the SGI Free
4 ** Software License B, Version 1.1 (the "License"), the contents of this
5 ** file are subject only to the provisions of the License. You may not use
6 ** this file except in compliance with the License. You may obtain a copy
7 ** of the License at Silicon Graphics, Inc., attn: Legal Services, 1600
8 ** Amphitheatre Parkway, Mountain View, CA 94043-1351, or at:
9 **
10 ** http://oss.sgi.com/projects/FreeB
11 **
12 ** Note that, as provided in the License, the Software is distributed on an
13 ** "AS IS" basis, with ALL EXPRESS AND IMPLIED WARRANTIES AND CONDITIONS
14 ** DISCLAIMED, INCLUDING, WITHOUT LIMITATION, ANY IMPLIED WARRANTIES AND
15 ** CONDITIONS OF MERCHANTABILITY, SATISFACTORY QUALITY, FITNESS FOR A
16 ** PARTICULAR PURPOSE, AND NON-INFRINGEMENT.
17 **
18 ** Original Code. The Original Code is: OpenGL Sample Implementation,
19 ** Version 1.2.1, released January 26, 2000, developed by Silicon Graphics,
20 ** Inc. The Original Code is Copyright (c) 1991-2000 Silicon Graphics, Inc.
21 ** Copyright in any portions created by third parties is as indicated
22 ** elsewhere herein. All Rights Reserved.
23 **
24 ** Additional Notice Provisions: The application programming interfaces
25 ** established by SGI in conjunction with the Original Code are The
26 ** OpenGL(R) Graphics System: A Specification (Version 1.2.1), released
27 ** April 1, 1999; The OpenGL(R) Graphics System Utility Library (Version
28 ** 1.3), released November 4, 1998; and OpenGL(R) Graphics with the X
29 ** Window System(R) (Version 1.3), released October 19, 1998. This software
30 ** was created using the OpenGL(R) version 1.2.1 Sample Implementation
31 ** published by SGI, but has not been independently verified as being
32 ** compliant with the OpenGL(R) version 1.2.1 Specification.
33 **
34 */
35 /*
36 ** Author: Eric Veach, July 1994.
37 **
38 ** $Date$ $Revision: 1.1 $
39 ** $Header: /cygdrive/c/RCVS/CVS/ReactOS/reactos/lib/glu32/libtess/tess.h,v 1.1 2004/02/02 16:39:15 navaraf Exp $
40 */
41
42 #ifndef __tess_h_
43 #define __tess_h_
44
45 #include <GL/glu.h>
46 #include <setjmp.h>
47 #include "mesh.h"
48 #include "dict.h"
49 #include "priorityq.h"
50
51 #ifndef GLAPIENTRY
52 #define GLAPIENTRY APIENTRY
53 #endif
54
55 /* The begin/end calls must be properly nested. We keep track of
56 * the current state to enforce the ordering.
57 */
58 enum TessState { T_DORMANT, T_IN_POLYGON, T_IN_CONTOUR };
59
60 /* We cache vertex data for single-contour polygons so that we can
61 * try a quick-and-dirty decomposition first.
62 */
63 #define TESS_MAX_CACHE 100
64
65 typedef struct CachedVertex {
66 GLdouble coords[3];
67 void *data;
68 } CachedVertex;
69
70 struct GLUtesselator {
71
72 /*** state needed for collecting the input data ***/
73
74 enum TessState state; /* what begin/end calls have we seen? */
75
76 GLUhalfEdge *lastEdge; /* lastEdge->Org is the most recent vertex */
77 GLUmesh *mesh; /* stores the input contours, and eventually
78 the tessellation itself */
79
80 void (GLAPIENTRY *callError)( GLenum errnum );
81
82 /*** state needed for projecting onto the sweep plane ***/
83
84 GLdouble normal[3]; /* user-specified normal (if provided) */
85 GLdouble sUnit[3]; /* unit vector in s-direction (debugging) */
86 GLdouble tUnit[3]; /* unit vector in t-direction (debugging) */
87
88 /*** state needed for the line sweep ***/
89
90 GLdouble relTolerance; /* tolerance for merging features */
91 GLenum windingRule; /* rule for determining polygon interior */
92 GLboolean fatalError; /* fatal error: needed combine callback */
93
94 Dict *dict; /* edge dictionary for sweep line */
95 PriorityQ *pq; /* priority queue of vertex events */
96 GLUvertex *event; /* current sweep event being processed */
97
98 void (GLAPIENTRY *callCombine)( GLdouble coords[3], void *data[4],
99 GLfloat weight[4], void **outData );
100
101 /*** state needed for rendering callbacks (see render.c) ***/
102
103 GLboolean flagBoundary; /* mark boundary edges (use EdgeFlag) */
104 GLboolean boundaryOnly; /* Extract contours, not triangles */
105 GLUface *lonelyTriList;
106 /* list of triangles which could not be rendered as strips or fans */
107
108 void (GLAPIENTRY *callBegin)( GLenum type );
109 void (GLAPIENTRY *callEdgeFlag)( GLboolean boundaryEdge );
110 void (GLAPIENTRY *callVertex)( void *data );
111 void (GLAPIENTRY *callEnd)( void );
112 void (GLAPIENTRY *callMesh)( GLUmesh *mesh );
113
114
115 /*** state needed to cache single-contour polygons for renderCache() */
116
117 GLboolean emptyCache; /* empty cache on next vertex() call */
118 int cacheCount; /* number of cached vertices */
119 CachedVertex cache[TESS_MAX_CACHE]; /* the vertex data */
120
121 /*** rendering callbacks that also pass polygon data ***/
122 void (GLAPIENTRY *callBeginData)( GLenum type, void *polygonData );
123 void (GLAPIENTRY *callEdgeFlagData)( GLboolean boundaryEdge,
124 void *polygonData );
125 void (GLAPIENTRY *callVertexData)( void *data, void *polygonData );
126 void (GLAPIENTRY *callEndData)( void *polygonData );
127 void (GLAPIENTRY *callErrorData)( GLenum errnum, void *polygonData );
128 void (GLAPIENTRY *callCombineData)( GLdouble coords[3], void *data[4],
129 GLfloat weight[4], void **outData,
130 void *polygonData );
131
132 jmp_buf env; /* place to jump to when memAllocs fail */
133
134 void *polygonData; /* client data for current polygon */
135 };
136
137 void GLAPIENTRY __gl_noBeginData( GLenum type, void *polygonData );
138 void GLAPIENTRY __gl_noEdgeFlagData( GLboolean boundaryEdge, void *polygonData );
139 void GLAPIENTRY __gl_noVertexData( void *data, void *polygonData );
140 void GLAPIENTRY __gl_noEndData( void *polygonData );
141 void GLAPIENTRY __gl_noErrorData( GLenum errnum, void *polygonData );
142 void GLAPIENTRY __gl_noCombineData( GLdouble coords[3], void *data[4],
143 GLfloat weight[4], void **outData,
144 void *polygonData );
145
146 #define CALL_BEGIN_OR_BEGIN_DATA(a) \
147 if (tess->callBeginData != &__gl_noBeginData) \
148 (*tess->callBeginData)((a),tess->polygonData); \
149 else (*tess->callBegin)((a));
150
151 #define CALL_VERTEX_OR_VERTEX_DATA(a) \
152 if (tess->callVertexData != &__gl_noVertexData) \
153 (*tess->callVertexData)((a),tess->polygonData); \
154 else (*tess->callVertex)((a));
155
156 #define CALL_EDGE_FLAG_OR_EDGE_FLAG_DATA(a) \
157 if (tess->callEdgeFlagData != &__gl_noEdgeFlagData) \
158 (*tess->callEdgeFlagData)((a),tess->polygonData); \
159 else (*tess->callEdgeFlag)((a));
160
161 #define CALL_END_OR_END_DATA() \
162 if (tess->callEndData != &__gl_noEndData) \
163 (*tess->callEndData)(tess->polygonData); \
164 else (*tess->callEnd)();
165
166 #define CALL_COMBINE_OR_COMBINE_DATA(a,b,c,d) \
167 if (tess->callCombineData != &__gl_noCombineData) \
168 (*tess->callCombineData)((a),(b),(c),(d),tess->polygonData); \
169 else (*tess->callCombine)((a),(b),(c),(d));
170
171 #define CALL_ERROR_OR_ERROR_DATA(a) \
172 if (tess->callErrorData != &__gl_noErrorData) \
173 (*tess->callErrorData)((a),tess->polygonData); \
174 else (*tess->callError)((a));
175
176 #endif