Windows NT 4.0 source code leak
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

153 lines
5.3 KiB

5 years ago
  1. #ifndef __tess_h_
  2. #define __tess_h_
  3. /*
  4. ** Copyright 1994, Silicon Graphics, Inc.
  5. ** All Rights Reserved.
  6. **
  7. ** This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  8. ** the contents of this file may not be disclosed to third parties, copied or
  9. ** duplicated in any form, in whole or in part, without the prior written
  10. ** permission of Silicon Graphics, Inc.
  11. **
  12. ** RESTRICTED RIGHTS LEGEND:
  13. ** Use, duplication or disclosure by the Government is subject to restrictions
  14. ** as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  15. ** and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  16. ** successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  17. ** rights reserved under the Copyright Laws of the United States.
  18. **
  19. ** Author: Eric Veach, July 1994.
  20. */
  21. #ifdef NT
  22. #include <glos.h>
  23. #endif
  24. #include <GL/glu.h>
  25. #include "mesh.h"
  26. #include "dict.h"
  27. #ifdef NT
  28. #include "priority.h"
  29. #else
  30. #include "priorityq.h"
  31. #endif
  32. /* The begin/end calls must be properly nested. We keep track of
  33. * the current state to enforce the ordering.
  34. */
  35. enum TessState { T_DORMANT, T_IN_POLYGON, T_IN_CONTOUR };
  36. /* We cache vertex data for single-contour polygons so that we can
  37. * try a quick-and-dirty decomposition first.
  38. */
  39. #define TESS_MAX_CACHE 100
  40. typedef struct CachedVertex {
  41. GLdouble coords[3];
  42. void *data;
  43. } CachedVertex;
  44. struct GLUtesselator {
  45. /*** state needed for collecting the input data ***/
  46. GLenum state; /* what begin/end calls have we seen? */
  47. GLUhalfEdge *lastEdge; /* lastEdge->Org is the most recent vertex */
  48. GLUmesh *mesh; /* stores the input contours, and eventually
  49. the tesselation itself */
  50. void (*callError)( GLenum errno );
  51. /*** state needed for projecting onto the sweep plane ***/
  52. GLdouble normal[3]; /* user-specified normal (if provided) */
  53. GLdouble sUnit[3]; /* unit vector in s-direction (debugging) */
  54. GLdouble tUnit[3]; /* unit vector in t-direction (debugging) */
  55. /*** state needed for the line sweep ***/
  56. GLdouble relTolerance; /* tolerance for merging features */
  57. GLenum windingRule; /* rule for determining polygon interior */
  58. GLboolean fatalError; /* fatal error: needed combine callback */
  59. Dict *dict; /* edge dictionary for sweep line */
  60. PriorityQ *pq; /* priority queue of vertex events */
  61. GLUvertex *event; /* current sweep event being processed */
  62. void (*callCombine)( GLdouble coords[3], void *data[4],
  63. GLfloat weight[4], void **outData );
  64. /*** state needed for rendering callbacks (see render.c) ***/
  65. GLboolean flagBoundary; /* mark boundary edges (use EdgeFlag) */
  66. GLboolean boundaryOnly; /* Extract contours, not triangles */
  67. GLUface *lonelyTriList;
  68. /* list of triangles which could not be rendered as strips or fans */
  69. void (*callBegin)( GLenum type );
  70. void (*callEdgeFlag)( GLboolean boundaryEdge );
  71. void (*callVertex)( void *data );
  72. void (*callEnd)( void );
  73. void (*callMesh)( GLUmesh *mesh ); // not part of NT api
  74. /*** state needed to cache single-contour polygons for renderCache() */
  75. GLboolean emptyCache; /* empty cache on next vertex() call */
  76. int cacheCount; /* number of cached vertices */
  77. CachedVertex cache[TESS_MAX_CACHE]; /* the vertex data */
  78. /*** rendering callbacks that also pass polygon data ***/
  79. void (*callBeginData)( GLenum type, void *polygonData );
  80. void (*callEdgeFlagData)( GLboolean boundaryEdge,
  81. void *polygonData );
  82. void (*callVertexData)( void *data, void *polygonData );
  83. void (*callEndData)( void *polygonData );
  84. void (*callErrorData)( GLenum errno, void *polygonData );
  85. void (*callCombineData)( GLdouble coords[3], void *data[4],
  86. GLfloat weight[4], void **outData,
  87. void *polygonData );
  88. void *polygonData; /* client data for current polygon */
  89. };
  90. void __gl_noBeginData( GLenum type, void *polygonData );
  91. void __gl_noEdgeFlagData( GLboolean boundaryEdge, void *polygonData );
  92. void __gl_noVertexData( void *data, void *polygonData );
  93. void __gl_noEndData( void *polygonData );
  94. void __gl_noErrorData( GLenum errno, void *polygonData );
  95. void __gl_noCombineData( GLdouble coords[3], void *data[4],
  96. GLfloat weight[4], void **outData,
  97. void *polygonData );
  98. #define CALL_BEGIN_OR_BEGIN_DATA(a) \
  99. if (tess->callBeginData != &__gl_noBeginData) \
  100. (*tess->callBeginData)((a),tess->polygonData); \
  101. else (*tess->callBegin)((a));
  102. #define CALL_VERTEX_OR_VERTEX_DATA(a) \
  103. if (tess->callVertexData != &__gl_noVertexData) \
  104. (*tess->callVertexData)((a),tess->polygonData); \
  105. else (*tess->callVertex)((a));
  106. #define CALL_EDGE_FLAG_OR_EDGE_FLAG_DATA(a) \
  107. if (tess->callEdgeFlagData != &__gl_noEdgeFlagData) \
  108. (*tess->callEdgeFlagData)((a),tess->polygonData); \
  109. else (*tess->callEdgeFlag)((a));
  110. #define CALL_END_OR_END_DATA() \
  111. if (tess->callEndData != &__gl_noEndData) \
  112. (*tess->callEndData)(tess->polygonData); \
  113. else (*tess->callEnd)();
  114. #define CALL_COMBINE_OR_COMBINE_DATA(a,b,c,d) \
  115. if (tess->callCombineData != &__gl_noCombineData) \
  116. (*tess->callCombineData)((a),(b),(c),(d),tess->polygonData); \
  117. else (*tess->callCombine)((a),(b),(c),(d));
  118. #define CALL_ERROR_OR_ERROR_DATA(a) \
  119. if (tess->callErrorData != &__gl_noErrorData) \
  120. (*tess->callErrorData)((a),tess->polygonData); \
  121. else (*tess->callError)((a));
  122. #endif