Source code of Windows XP (NT5)
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.

303 lines
8.6 KiB

  1. #ifndef __glvertex_h_
  2. #define __glvertex_h_
  3. /*
  4. ** Copyright 1991, 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. ** $Revision: 1.16 $
  20. ** $Date: 1993/12/08 06:29:30 $
  21. */
  22. #include "types.h"
  23. #include "parray.h"
  24. /*
  25. ** Vertex structure. Each vertex contains enough state to properly
  26. ** render the active primitive. It is used by the front-end geometry
  27. ** and back-end rasterization pipelines.
  28. **
  29. ** NOTE: Same as the POLYDATA structure!
  30. **
  31. ** To minimize storage requirement, some front-end storage (e.g. obj and normal)
  32. ** is shared with back-end storage.
  33. */
  34. struct __GLvertexRec {
  35. /*
  36. ** Keep this data structure aligned: have all vectors start on
  37. ** 4-word boundary, and sizeof this struct should be kept at
  38. ** a multiple of 4 words. Also helps to bunch together most
  39. ** frequently used items, helps cache.
  40. */
  41. /*
  42. ** Bits are set in this indicating which fields of the vertex are
  43. ** valid. This field is shared with the front-end flags field!
  44. */
  45. GLuint has;
  46. /*
  47. ** Moved up here to keep GLcoords aligned.
  48. */
  49. __GLcolor *color;
  50. /*
  51. ** Clipping code mask. One bit is set for each clipping plane that
  52. ** the vertex is out on.
  53. */
  54. GLuint clipCode;
  55. /*
  56. ** Fog value for the vertex. This is only filled when doing cheap
  57. ** fogging.
  58. */
  59. __GLfloat fog;
  60. /*
  61. ** Projected eye coodinate. This field is filled in when the users
  62. ** eye coordinate has been multiplied by the projection matrix.
  63. */
  64. __GLcoord clip;
  65. /*
  66. ** Window coordinate. This field is filled in when the eye coordinate
  67. ** is converted to a drawing surface relative "window" coordinate.
  68. ** NOTE: the window.w coordinate contains 1/clip.w.
  69. */
  70. __GLcoord window;
  71. __GLcoord texture;
  72. __GLcoord normal;
  73. /*
  74. ** Colors. colors[0] is the "front" color, colors[1] is the "back" color.
  75. ** The color pointer points to which color is current for this
  76. ** vertex. Verticies can have more than one color when two sided
  77. ** lighting is enabled. (note color pointer moved up top).
  78. */
  79. __GLcolor colors[2];
  80. /*
  81. ** Eye coordinate. This field is filled in when the object coordinate
  82. ** has been multiplied by the model-view matrix. If no eye coordinate
  83. ** was needed then this field contains undefined values.
  84. */
  85. __GLfloat eyeX;
  86. __GLfloat eyeY;
  87. __GLfloat eyeZ;
  88. union
  89. {
  90. __GLfloat eyeW; //Used by the phong-shader
  91. __GLcolor *lastColor; // eyeW is not used in rasterization
  92. };
  93. /*
  94. ** On Win64 the POLYARRAY structure is larger than the __GLvertex
  95. ** structure since the former contains several pointers which are
  96. ** 8 bytes on the 64-bit system. Therefore, this structure must
  97. ** be padded to be the same size as the POLYARRAY structure.
  98. **
  99. ** N.B. Since the structure must be the same size as the POLYDATA
  100. ** structure that structure must also be padded.
  101. **
  102. */
  103. #if defined(_WIN64)
  104. PVOID Filler[7];
  105. #endif
  106. };
  107. /* Indicies for colors[] array in vertex */
  108. #define __GL_FRONTFACE 0
  109. #define __GL_BACKFACE 1
  110. /* Bits for clipCode (NOTE: MAX of 26 user clip planes) */
  111. #define __GL_CLIP_LEFT 0x00000001
  112. #define __GL_CLIP_RIGHT 0x00000002
  113. #define __GL_CLIP_BOTTOM 0x00000004
  114. #define __GL_CLIP_TOP 0x00000008
  115. #define __GL_CLIP_NEAR 0x00000010
  116. #define __GL_CLIP_FAR 0x00000020
  117. #define __GL_FRUSTUM_CLIP_MASK 0x0000003f
  118. #define __GL_CLIP_USER0 0x00000040
  119. /* Bits for has */
  120. #ifdef NT
  121. // These has bits are shared with POLYDATA flags!
  122. #define __GL_HAS_EDGEFLAG_BOUNDARY 0x00000001 // must be 1, same as
  123. // POLYDATA_EDGEFLAG_BOUNDARY
  124. #define __GL_HAS_FOG 0x00004000 // same as POLYDATA_FOG_VALID
  125. #define __GL_HAS_FIXEDPT 0x00008000
  126. #else
  127. #define __GL_HAS_FRONT_COLOR 0x0001
  128. #define __GL_HAS_BACK_COLOR 0x0002
  129. /* for poly clipping */
  130. #define __GL_HAS_BOTH (__GL_HAS_FRONT_COLOR | __GL_HAS_BACK_COLOR)
  131. #define __GL_HAS_TEXTURE 0x0004
  132. #define __GL_HAS_NORMAL 0x0008
  133. #define __GL_HAS_EYE 0x0010
  134. #define __GL_HAS_CLIP 0x0020
  135. #define __GL_HAS_FOG 0x0040
  136. #define __GL_HAS_LIGHTING (__GL_HAS_EYE | __GL_HAS_NORMAL)
  137. #endif /* NT */
  138. #ifdef NT
  139. /*
  140. ** Poly array needs
  141. */
  142. // front/back color needs for lit polygons or unlit primitives
  143. #define PANEEDS_FRONT_COLOR 0x0001
  144. #define PANEEDS_BACK_COLOR 0x0002
  145. // normal need
  146. #define PANEEDS_NORMAL 0x0004
  147. #define PANEEDS_NORMAL_FOR_TEXTURE 0x0100
  148. #define PANEEDS_RASTERPOS_NORMAL_FOR_TEXTURE 0x0200
  149. // normal need for RasterPos
  150. #define PANEEDS_RASTERPOS_NORMAL 0x0008
  151. // texture coord need, set by RasterPos too!
  152. #define PANEEDS_TEXCOORD 0x0010
  153. // edge flag need
  154. #define PANEEDS_EDGEFLAG 0x0020
  155. // set in selection mode but cleared by RasterPos!
  156. #define PANEEDS_CLIP_ONLY 0x0040
  157. // skip lighting calculation optimiztaion
  158. #define PANEEDS_SKIP_LIGHTING 0x0080
  159. #endif
  160. /*
  161. ** NOTE: may need to change the raster pos handler if more bits are added
  162. ** to the above constants
  163. */
  164. /************************************************************************/
  165. /*
  166. ** Total number of clipping planes supported by this gl. This includes
  167. ** the frustum's six clipping planes.
  168. */
  169. /*#define __GL_TOTAL_CLIP_PLANES (6 + __GL_NUMBER_OF_CLIP_PLANES)*/
  170. #ifndef NT
  171. /*
  172. ** Number of static verticies in the context. Polygon's larger than
  173. ** this number will be decomposed.
  174. */
  175. #define __GL_NVBUF 100
  176. #endif
  177. #define NEW_PARTIAL_PRIM // New processing of partial primitives
  178. #ifdef NEW_PARTIAL_PRIM
  179. // Structure to save shared vertices of partial primitives
  180. //
  181. typedef struct _SAVEREGION
  182. {
  183. POLYDATA pd;
  184. __GLmatChange front, back;
  185. } SAVEREGION;
  186. #endif // NEW_PARTIAL_PRIM
  187. /*
  188. ** State for managing the vertex machinery.
  189. */
  190. typedef struct __GLvertexMachineRec {
  191. #ifdef NT
  192. /*
  193. ** Saved vertices of a decomposed polygon.
  194. */
  195. #ifdef NEW_PARTIAL_PRIM
  196. SAVEREGION regSaved; // Saved data for partial line loop
  197. #else
  198. POLYDATA pdSaved[3];
  199. #endif // NEW_PARTIAL_PRIM
  200. /*
  201. ** The polyarray vertex buffer. The last vertex is reserved by the
  202. ** polyarray code.
  203. ** Note that pdBuf has (pdBufSize + 1) entries. Only pdBufSize
  204. ** entries are available for use. The last entry is reserved by
  205. ** polyarray code.
  206. */
  207. POLYDATA *pdBuf;
  208. GLuint pdBufSize;
  209. GLuint pdBufSizeBytes;
  210. #else
  211. /*
  212. ** Vertex pointers. v0 always points to the next slot in vbuf to
  213. ** be filled in when a new vertex arrives. v1, v2 and v3 are
  214. ** used by the per-primitive vertex handlers.
  215. */
  216. __GLvertex *v0;
  217. __GLvertex *v1;
  218. __GLvertex *v2;
  219. __GLvertex *v3;
  220. __GLvertex vbuf[__GL_NVBUF];
  221. #endif
  222. /*
  223. ** Provoking vertex. For flat shaded primitives the triangle
  224. ** renderer needs to know which vertex provoked the primitive to
  225. ** properly assign the color during scan conversion. This is kept
  226. ** around as its a big pain to remember which vertex was provoking
  227. ** during clipping (and to keep its parameters right).
  228. */
  229. __GLvertex *provoking;
  230. #ifdef NT
  231. /*
  232. ** Poly array needs
  233. */
  234. GLuint paNeeds;
  235. #else
  236. /*
  237. ** needs is a bit field that keeps track of what kind of information
  238. ** is needed in the verticies. See the vertex->has bits define for
  239. ** the definition of the bits used here.
  240. **
  241. ** frontNeeds is what the front faces need, and backNeeds is what
  242. ** the back faces need.
  243. */
  244. GLuint needs;
  245. /*
  246. ** frontNeeds and backNeeds are the needs
  247. */
  248. GLuint faceNeeds[2];
  249. /*
  250. ** materialNeeds is a bit field indicating what kind of information is
  251. ** needed in the vertices if the material is going to change.
  252. */
  253. GLuint materialNeeds;
  254. #endif
  255. } __GLvertexMachine;
  256. /************************************************************************/
  257. void APIPRIVATE __glim_NoXFVertex2fv(const GLfloat v[2]);
  258. void APIPRIVATE __glim_NoXFVertex3fv(const GLfloat v[3]);
  259. void APIPRIVATE __glim_NoXFVertex4fv(const GLfloat v[4]);
  260. #endif /* __glvertex_h_ */