d3d11: Implement d3d11_immediate_context_DSGetSamplers().
[wine.git] / dlls / glu32 / tess.h
blob7c825de4182df1a540a2cd1835f06093f43790c8
1 /*
2 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
3 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
5 * Permission is hereby granted, free of charge, to any person obtaining a
6 * copy of this software and associated documentation files (the "Software"),
7 * to deal in the Software without restriction, including without limitation
8 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
9 * and/or sell copies of the Software, and to permit persons to whom the
10 * Software is furnished to do so, subject to the following conditions:
12 * The above copyright notice including the dates of first publication and
13 * either this permission notice or a reference to
14 * http://oss.sgi.com/projects/FreeB/
15 * shall be included in all copies or substantial portions of the Software.
17 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
18 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
19 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
20 * SILICON GRAPHICS, INC. BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY,
21 * WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
22 * OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
23 * SOFTWARE.
25 * Except as contained in this notice, the name of Silicon Graphics, Inc.
26 * shall not be used in advertising or otherwise to promote the sale, use or
27 * other dealings in this Software without prior written authorization from
28 * Silicon Graphics, Inc.
31 ** Author: Eric Veach, July 1994.
35 #ifndef __tess_h_
36 #define __tess_h_
38 #include <setjmp.h>
39 #include "wine/glu.h"
40 #include "mesh.h"
42 typedef struct Dict Dict;
44 /* priority queue */
46 /* Since we support deletion the data structure is a little more
47 * complicated than an ordinary heap. "nodes" is the heap itself;
48 * active nodes are stored in the range 1..pq->size. When the
49 * heap exceeds its allocated size (pq->max), its size doubles.
50 * The children of node i are nodes 2i and 2i+1.
52 * Each node stores an index into an array "handles". Each handle
53 * stores a key, plus a pointer back to the node which currently
54 * represents that key (ie. nodes[handles[i].node].handle == i).
57 typedef void *PQkey;
58 typedef long PQhandle;
59 typedef struct PriorityQSort PriorityQSort;
61 PriorityQSort *__gl_pqSortNewPriorityQ( int (*leq)(PQkey key1, PQkey key2) );
62 void __gl_pqSortDeletePriorityQ( PriorityQSort *pq );
64 int __gl_pqSortInit( PriorityQSort *pq );
65 PQhandle __gl_pqSortInsert( PriorityQSort *pq, PQkey key );
66 PQkey __gl_pqSortExtractMin( PriorityQSort *pq );
67 void __gl_pqSortDelete( PriorityQSort *pq, PQhandle handle );
69 PQkey __gl_pqSortMinimum( PriorityQSort *pq );
70 int __gl_pqSortIsEmpty( PriorityQSort *pq );
73 #define VertEq(u,v) ((u)->s == (v)->s && (u)->t == (v)->t)
74 #define VertLeq(u,v) (((u)->s < (v)->s) || \
75 ((u)->s == (v)->s && (u)->t <= (v)->t))
76 #define EdgeEval(u,v,w) __gl_edgeEval(u,v,w)
77 #define EdgeSign(u,v,w) __gl_edgeSign(u,v,w)
79 /* Versions of VertLeq, EdgeSign, EdgeEval with s and t transposed. */
81 #define TransLeq(u,v) (((u)->t < (v)->t) || \
82 ((u)->t == (v)->t && (u)->s <= (v)->s))
83 #define TransEval(u,v,w) __gl_transEval(u,v,w)
84 #define TransSign(u,v,w) __gl_transSign(u,v,w)
87 #define EdgeGoesLeft(e) VertLeq( (e)->Dst, (e)->Org )
88 #define EdgeGoesRight(e) VertLeq( (e)->Org, (e)->Dst )
90 #undef ABS
91 #define ABS(x) ((x) < 0 ? -(x) : (x))
92 #define VertL1dist(u,v) (ABS(u->s - v->s) + ABS(u->t - v->t))
94 #define VertCCW(u,v,w) __gl_vertCCW(u,v,w)
96 int __gl_vertLeq( GLUvertex *u, GLUvertex *v );
97 GLdouble __gl_edgeEval( GLUvertex *u, GLUvertex *v, GLUvertex *w );
98 GLdouble __gl_edgeSign( GLUvertex *u, GLUvertex *v, GLUvertex *w );
99 GLdouble __gl_transEval( GLUvertex *u, GLUvertex *v, GLUvertex *w );
100 GLdouble __gl_transSign( GLUvertex *u, GLUvertex *v, GLUvertex *w );
101 int __gl_vertCCW( GLUvertex *u, GLUvertex *v, GLUvertex *w );
102 void __gl_edgeIntersect( GLUvertex *o1, GLUvertex *d1,
103 GLUvertex *o2, GLUvertex *d2,
104 GLUvertex *v );
106 /* The begin/end calls must be properly nested. We keep track of
107 * the current state to enforce the ordering.
109 enum TessState { T_DORMANT, T_IN_POLYGON, T_IN_CONTOUR };
111 /* We cache vertex data for single-contour polygons so that we can
112 * try a quick-and-dirty decomposition first.
114 #define TESS_MAX_CACHE 100
116 typedef struct CachedVertex {
117 GLdouble coords[3];
118 void *data;
119 } CachedVertex;
121 struct GLUtesselator {
123 /*** state needed for collecting the input data ***/
125 enum TessState state; /* what begin/end calls have we seen? */
127 GLUhalfEdge *lastEdge; /* lastEdge->Org is the most recent vertex */
128 GLUmesh *mesh; /* stores the input contours, and eventually
129 the tessellation itself */
131 void (GLAPIENTRY *callError)( GLenum errnum );
133 /*** state needed for projecting onto the sweep plane ***/
135 GLdouble normal[3]; /* user-specified normal (if provided) */
136 GLdouble sUnit[3]; /* unit vector in s-direction (debugging) */
137 GLdouble tUnit[3]; /* unit vector in t-direction (debugging) */
139 /*** state needed for the line sweep ***/
141 GLdouble relTolerance; /* tolerance for merging features */
142 GLenum windingRule; /* rule for determining polygon interior */
143 GLboolean fatalError; /* fatal error: needed combine callback */
145 Dict *dict; /* edge dictionary for sweep line */
146 PriorityQSort *pq; /* priority queue of vertex events */
147 GLUvertex *event; /* current sweep event being processed */
149 void (GLAPIENTRY *callCombine)( GLdouble coords[3], void *data[4],
150 GLfloat weight[4], void **outData );
152 /*** state needed for rendering callbacks (see render.c) ***/
154 GLboolean flagBoundary; /* mark boundary edges (use EdgeFlag) */
155 GLboolean boundaryOnly; /* Extract contours, not triangles */
156 GLUface *lonelyTriList;
157 /* list of triangles which could not be rendered as strips or fans */
159 void (GLAPIENTRY *callBegin)( GLenum type );
160 void (GLAPIENTRY *callEdgeFlag)( GLboolean boundaryEdge );
161 void (GLAPIENTRY *callVertex)( void *data );
162 void (GLAPIENTRY *callEnd)( void );
163 void (GLAPIENTRY *callMesh)( GLUmesh *mesh );
166 /*** state needed to cache single-contour polygons for renderCache() */
168 GLboolean emptyCache; /* empty cache on next vertex() call */
169 int cacheCount; /* number of cached vertices */
170 CachedVertex cache[TESS_MAX_CACHE]; /* the vertex data */
172 /*** rendering callbacks that also pass polygon data ***/
173 void (GLAPIENTRY *callBeginData)( GLenum type, void *polygonData );
174 void (GLAPIENTRY *callEdgeFlagData)( GLboolean boundaryEdge,
175 void *polygonData );
176 void (GLAPIENTRY *callVertexData)( void *data, void *polygonData );
177 void (GLAPIENTRY *callEndData)( void *polygonData );
178 void (GLAPIENTRY *callErrorData)( GLenum errnum, void *polygonData );
179 void (GLAPIENTRY *callCombineData)( GLdouble coords[3], void *data[4],
180 GLfloat weight[4], void **outData,
181 void *polygonData );
183 jmp_buf env; /* place to jump to when memAllocs fail */
185 void *polygonData; /* client data for current polygon */
188 void GLAPIENTRY __gl_noBeginData( GLenum type, void *polygonData );
189 void GLAPIENTRY __gl_noEdgeFlagData( GLboolean boundaryEdge, void *polygonData );
190 void GLAPIENTRY __gl_noVertexData( void *data, void *polygonData );
191 void GLAPIENTRY __gl_noEndData( void *polygonData );
192 void GLAPIENTRY __gl_noErrorData( GLenum errnum, void *polygonData );
193 void GLAPIENTRY __gl_noCombineData( GLdouble coords[3], void *data[4],
194 GLfloat weight[4], void **outData,
195 void *polygonData );
197 #define CALL_BEGIN_OR_BEGIN_DATA(a) \
198 if (tess->callBeginData != &__gl_noBeginData) \
199 (*tess->callBeginData)((a),tess->polygonData); \
200 else (*tess->callBegin)((a));
202 #define CALL_VERTEX_OR_VERTEX_DATA(a) \
203 if (tess->callVertexData != &__gl_noVertexData) \
204 (*tess->callVertexData)((a),tess->polygonData); \
205 else (*tess->callVertex)((a));
207 #define CALL_EDGE_FLAG_OR_EDGE_FLAG_DATA(a) \
208 if (tess->callEdgeFlagData != &__gl_noEdgeFlagData) \
209 (*tess->callEdgeFlagData)((a),tess->polygonData); \
210 else (*tess->callEdgeFlag)((a));
212 #define CALL_END_OR_END_DATA() \
213 if (tess->callEndData != &__gl_noEndData) \
214 (*tess->callEndData)(tess->polygonData); \
215 else (*tess->callEnd)();
217 #define CALL_COMBINE_OR_COMBINE_DATA(a,b,c,d) \
218 if (tess->callCombineData != &__gl_noCombineData) \
219 (*tess->callCombineData)((a),(b),(c),(d),tess->polygonData); \
220 else (*tess->callCombine)((a),(b),(c),(d));
222 #define CALL_ERROR_OR_ERROR_DATA(a) \
223 if (tess->callErrorData != &__gl_noErrorData) \
224 (*tess->callErrorData)((a),tess->polygonData); \
225 else (*tess->callError)((a));
227 void __gl_renderMesh( GLUtesselator *tess, GLUmesh *mesh );
228 void __gl_renderBoundary( GLUtesselator *tess, GLUmesh *mesh );
230 GLboolean __gl_renderCache( GLUtesselator *tess );
232 /* __gl_computeInterior( tess ) computes the planar arrangement specified
233 * by the given contours, and further subdivides this arrangement
234 * into regions. Each region is marked "inside" if it belongs
235 * to the polygon, according to the rule given by tess->windingRule.
236 * Each interior region is guaranteed be monotone.
238 int __gl_computeInterior( GLUtesselator *tess );
240 #endif