root/OpenSceneGraph/trunk/src/osg/glu/libtess/tess.h @ 11822

Revision 11822, 6.4 kB (checked in by robert, 4 years ago)

Added #define GLAPIENTRY to attempt to resolve some Windows build issues

Line 
1/*
2 * SGI FREE SOFTWARE LICENSE B (Version 2.0, Sept. 18, 2008)
3 * Copyright (C) 1991-2000 Silicon Graphics, Inc. All Rights Reserved.
4 *
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:
11 *
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.
16 *
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.
24 *
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.
29 */
30/*
31** Author: Eric Veach, July 1994.
32**
33*/
34
35#ifndef __tess_h_
36#define __tess_h_
37
38// #include <GL/glu.h>
39#include <osg/GLU>
40
41// simply define GLAPIENTRY as nothing so that we can keep function signatures the same as declaration.
42#define GLAPIENTRY
43
44#include <setjmp.h>
45#include "mesh.h"
46#include "dict.h"
47#include "priorityq.h"
48
49
50/* The begin/end calls must be properly nested.  We keep track of
51 * the current state to enforce the ordering.
52 */
53enum TessState { T_DORMANT, T_IN_POLYGON, T_IN_CONTOUR };
54
55/* We cache vertex data for single-contour polygons so that we can
56 * try a quick-and-dirty decomposition first.
57 */
58#define TESS_MAX_CACHE  100
59
60typedef struct CachedVertex {
61  GLdouble      coords[3];
62  void          *data;
63} CachedVertex;
64
65struct GLUtesselator {
66
67  /*** state needed for collecting the input data ***/
68
69  enum TessState state;         /* what begin/end calls have we seen? */
70
71  GLUhalfEdge   *lastEdge;      /* lastEdge->Org is the most recent vertex */
72  GLUmesh       *mesh;          /* stores the input contours, and eventually
73                                   the tessellation itself */
74
75  void          (GLAPIENTRY *callError)( GLenum errnum );
76
77  /*** state needed for projecting onto the sweep plane ***/
78
79  GLdouble      normal[3];      /* user-specified normal (if provided) */
80  GLdouble      sUnit[3];       /* unit vector in s-direction (debugging) */
81  GLdouble      tUnit[3];       /* unit vector in t-direction (debugging) */
82
83  /*** state needed for the line sweep ***/
84
85  GLdouble      relTolerance;   /* tolerance for merging features */
86  GLenum        windingRule;    /* rule for determining polygon interior */
87  GLboolean     fatalError;     /* fatal error: needed combine callback */
88
89  Dict          *dict;          /* edge dictionary for sweep line */
90  PriorityQ     *pq;            /* priority queue of vertex events */
91  GLUvertex     *event;         /* current sweep event being processed */
92
93  void          (GLAPIENTRY *callCombine)( GLdouble coords[3], void *data[4],
94                                GLfloat weight[4], void **outData );
95
96  /*** state needed for rendering callbacks (see render.c) ***/
97
98  GLboolean     flagBoundary;   /* mark boundary edges (use EdgeFlag) */
99  GLboolean     boundaryOnly;   /* Extract contours, not triangles */
100  GLUface       *lonelyTriList;
101    /* list of triangles which could not be rendered as strips or fans */
102
103  void          (GLAPIENTRY *callBegin)( GLenum type );
104  void          (GLAPIENTRY *callEdgeFlag)( GLboolean boundaryEdge );
105  void          (GLAPIENTRY *callVertex)( void *data );
106  void          (GLAPIENTRY *callEnd)( void );
107  void          (GLAPIENTRY *callMesh)( GLUmesh *mesh );
108
109
110  /*** state needed to cache single-contour polygons for renderCache() */
111
112  GLboolean     emptyCache;             /* empty cache on next vertex() call */
113  int           cacheCount;             /* number of cached vertices */
114  CachedVertex  cache[TESS_MAX_CACHE];  /* the vertex data */
115
116  /*** rendering callbacks that also pass polygon data  ***/ 
117  void          (GLAPIENTRY *callBeginData)( GLenum type, void *polygonData );
118  void          (GLAPIENTRY *callEdgeFlagData)( GLboolean boundaryEdge,
119                                     void *polygonData );
120  void          (GLAPIENTRY *callVertexData)( void *data, void *polygonData );
121  void          (GLAPIENTRY *callEndData)( void *polygonData );
122  void          (GLAPIENTRY *callErrorData)( GLenum errnum, void *polygonData );
123  void          (GLAPIENTRY *callCombineData)( GLdouble coords[3], void *data[4],
124                                    GLfloat weight[4], void **outData,
125                                    void *polygonData );
126
127  jmp_buf env;                  /* place to jump to when memAllocs fail */
128
129  void *polygonData;            /* client data for current polygon */
130};
131
132void GLAPIENTRY __gl_noBeginData( GLenum type, void *polygonData );
133void GLAPIENTRY __gl_noEdgeFlagData( GLboolean boundaryEdge, void *polygonData );
134void GLAPIENTRY __gl_noVertexData( void *data, void *polygonData );
135void GLAPIENTRY __gl_noEndData( void *polygonData );
136void GLAPIENTRY __gl_noErrorData( GLenum errnum, void *polygonData );
137void GLAPIENTRY __gl_noCombineData( GLdouble coords[3], void *data[4],
138                         GLfloat weight[4], void **outData,
139                         void *polygonData );
140
141#define CALL_BEGIN_OR_BEGIN_DATA(a) \
142   if (tess->callBeginData != &__gl_noBeginData) \
143      (*tess->callBeginData)((a),tess->polygonData); \
144   else (*tess->callBegin)((a));
145
146#define CALL_VERTEX_OR_VERTEX_DATA(a) \
147   if (tess->callVertexData != &__gl_noVertexData) \
148      (*tess->callVertexData)((a),tess->polygonData); \
149   else (*tess->callVertex)((a));
150
151#define CALL_EDGE_FLAG_OR_EDGE_FLAG_DATA(a) \
152   if (tess->callEdgeFlagData != &__gl_noEdgeFlagData) \
153      (*tess->callEdgeFlagData)((a),tess->polygonData); \
154   else (*tess->callEdgeFlag)((a));
155
156#define CALL_END_OR_END_DATA() \
157   if (tess->callEndData != &__gl_noEndData) \
158      (*tess->callEndData)(tess->polygonData); \
159   else (*tess->callEnd)();
160
161#define CALL_COMBINE_OR_COMBINE_DATA(a,b,c,d) \
162   if (tess->callCombineData != &__gl_noCombineData) \
163      (*tess->callCombineData)((a),(b),(c),(d),tess->polygonData); \
164   else (*tess->callCombine)((a),(b),(c),(d));
165
166#define CALL_ERROR_OR_ERROR_DATA(a) \
167   if (tess->callErrorData != &__gl_noErrorData) \
168      (*tess->callErrorData)((a),tess->polygonData); \
169   else (*tess->callError)((a));
170
171#endif
Note: See TracBrowser for help on using the browser.