Merged in fixes from 3.2 branch. Fixed clipping bug, segfault in
[mesa.git] / src / glu / mesa / tess.h
1 /* $Id: tess.h,v 1.16 1999/12/06 09:39:34 gareth Exp $ */
2
3 /*
4 * Mesa 3-D graphics library
5 * Version: 3.1
6 *
7 * Copyright (C) 1999 Brian Paul All Rights Reserved.
8 *
9 * Permission is hereby granted, free of charge, to any person obtaining a
10 * copy of this software and associated documentation files (the "Software"),
11 * to deal in the Software without restriction, including without limitation
12 * the rights to use, copy, modify, merge, publish, distribute, sublicense,
13 * and/or sell copies of the Software, and to permit persons to whom the
14 * Software is furnished to do so, subject to the following conditions:
15 *
16 * The above copyright notice and this permission notice shall be included
17 * in all copies or substantial portions of the Software.
18 *
19 * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
20 * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
21 * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
22 * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
23 * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
24 * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
25 */
26
27 /*****************************************************************************
28 *
29 * GLU 1.3 Polygon Tessellation by Gareth Hughes <garethh@bell-labs.com>
30 *
31 *****************************************************************************/
32
33 #ifndef __GLU_TESS_H__
34 #define __GLU_TESS_H__
35
36 #include <stdarg.h>
37 #include <stdio.h>
38
39 #include "gluP.h"
40
41 #include "tess_typedefs.h"
42 #include "tess_macros.h"
43 #include "tess_hash.h"
44 #include "tess_heap.h"
45 #if 0
46 #include "tess_grid.h"
47 #endif
48
49 #ifdef __cplusplus
50 extern "C" {
51 #endif
52
53 /*****************************************************************************
54 * The GLUtesselator structure:
55 *****************************************************************************/
56 struct GLUtesselator
57 {
58 tess_callbacks_t callbacks;
59 GLenum winding_rule;
60 GLboolean boundary_only;
61 GLdouble tolerance;
62 GLenum orientation;
63 void *data;
64 GLint num_contours;
65 tess_contour_t *contours, *last_contour;
66 tess_contour_t *current_contour;
67 GLdouble mins[2], maxs[2];
68 GLint num_vertices;
69 tess_vertex_t **sorted_vertices;
70 #if 0
71 tess_grid_t *grid; /* Not currently used... */
72 #endif
73 heap_t *ears;
74 GLboolean edge_flag;
75 GLuint label;
76 tess_plane_t plane;
77 GLenum error;
78 };
79
80
81 /*****************************************************************************
82 * Common tessellation functions:
83 *****************************************************************************/
84 extern void tess_error_callback( GLUtesselator *, GLenum );
85
86 extern GLdouble twice_contour_area( tess_contour_t *contour );
87 extern void reverse_contour( tess_contour_t *contour );
88 extern void delete_contour( tess_contour_t **contour );
89
90 extern void contour_dump( tess_contour_t *contour );
91
92
93 /*****************************************************************************
94 * Debugging output:
95 *****************************************************************************/
96 #ifdef DEBUG
97 extern int tess_dbg_level;
98
99 #define DBG_LEVEL_BASE 1
100 #define DBG_LEVEL_VERBOSE 10
101 #define DBG_LEVEL_ENTEREXIT 20
102
103 #ifdef _WIN32
104 #define DBG_STREAM stdout
105 #else
106 #define DBG_STREAM stderr
107 #endif
108
109 #ifdef __GNUC__
110 #define MSG( level, format, args... ) \
111 if ( level <= tess_dbg_level ) { \
112 fprintf( DBG_STREAM, "%9.9s:%d:\t ", __FILE__, __LINE__ ); \
113 fprintf( DBG_STREAM, format, ## args ); \
114 fflush( DBG_STREAM ); \
115 }
116 #else
117 #define MSG tess_msg
118 #endif /* __GNUC__ */
119
120 #else
121 #define MSG tess_msg
122 #endif /* DEBUG */
123
124 extern INLINE void tess_msg( GLint level, char *format, ... );
125 extern INLINE void tess_info( char *file, GLint line );
126
127 #ifdef __cplusplus
128 }
129 #endif
130
131 #endif /* __GLU_TESS_H__ */