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.

559 lines
16 KiB

  1. #ifndef __glattrib_h_
  2. #define __glattrib_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.14 $
  20. ** $Date: 1993/10/07 18:34:31 $
  21. */
  22. #include "lighting.h"
  23. #include "pixel.h"
  24. #include "texture.h"
  25. #include "eval.h"
  26. #include "vertex.h"
  27. #include "glarray.h"
  28. typedef struct __GLcurrentStateRec {
  29. __GLvertex rasterPos;
  30. /*
  31. ** Raster pos valid bit.
  32. */
  33. GLboolean validRasterPos;
  34. /*
  35. ** Edge tag state.
  36. */
  37. GLboolean edgeTag;
  38. /*
  39. ** Current color and colorIndex. These variables are also used for
  40. ** the current rasterPos color and colorIndex as set by the user.
  41. */
  42. __GLcolor userColor;
  43. __GLfloat userColorIndex;
  44. __GLcoord normal;
  45. __GLcoord texture;
  46. } __GLcurrentState;
  47. /************************************************************************/
  48. typedef struct __GLpointStateRec {
  49. __GLfloat requestedSize;
  50. __GLfloat smoothSize;
  51. GLint aliasedSize;
  52. } __GLpointState;
  53. /************************************************************************/
  54. /*
  55. ** Line state. Contains all the client controllable line state.
  56. */
  57. typedef struct {
  58. __GLfloat requestedWidth;
  59. __GLfloat smoothWidth;
  60. GLint aliasedWidth;
  61. GLushort stipple;
  62. GLshort stippleRepeat;
  63. } __GLlineState;
  64. /************************************************************************/
  65. /*
  66. ** Polygon state. Contains all the user controllable polygon state
  67. ** except for the stipple state.
  68. */
  69. typedef struct __GLpolygonStateRec {
  70. GLenum frontMode;
  71. GLenum backMode;
  72. /*
  73. ** Culling state. Culling can be enabled/disabled and set to cull
  74. ** front or back faces. The FrontFace call determines whether clockwise
  75. ** or counter-clockwise oriented vertices are front facing.
  76. */
  77. GLenum cull;
  78. GLenum frontFaceDirection;
  79. /*
  80. ** Polygon offset state
  81. */
  82. __GLfloat factor;
  83. __GLfloat units;
  84. } __GLpolygonState;
  85. /************************************************************************/
  86. /*
  87. ** Polygon stipple state.
  88. */
  89. typedef struct __GLpolygonStippleStateRec {
  90. GLubyte stipple[4*32];
  91. } __GLpolygonStippleState;
  92. /************************************************************************/
  93. typedef struct __GLfogStateRec {
  94. GLenum mode;
  95. #ifdef NT
  96. GLuint flags;
  97. #endif
  98. __GLcolor color;
  99. #ifdef NT
  100. __GLfloat density2neg;
  101. #endif
  102. __GLfloat density, start, end;
  103. __GLfloat oneOverEMinusS;
  104. __GLfloat index;
  105. } __GLfogState;
  106. // fog flags
  107. // __GL_FOG_GRAY_RGB is set when the clamped and scaled fog color contains
  108. // identical R, G, and B values
  109. #define __GL_FOG_GRAY_RGB 0x0001
  110. /************************************************************************/
  111. /*
  112. ** Depth state. Contains all the user settable depth state.
  113. */
  114. typedef struct __GLdepthStateRec __GLdepthState;
  115. struct __GLdepthStateRec {
  116. /*
  117. ** Depth buffer test function. The z value is compared using zFunction
  118. ** against the current value in the zbuffer. If the comparison
  119. ** succeeds the new z value is written into the z buffer masked
  120. ** by the z write mask.
  121. */
  122. GLenum testFunc;
  123. /*
  124. ** Writemask enable. When GL_TRUE writing to the depth buffer is
  125. ** allowed.
  126. */
  127. GLboolean writeEnable;
  128. /*
  129. ** Value used to clear the z buffer when glClear is called.
  130. */
  131. GLdouble clear;
  132. };
  133. /************************************************************************/
  134. typedef struct __GLaccumStateRec {
  135. __GLcolor clear;
  136. } __GLaccumState;
  137. /************************************************************************/
  138. /*
  139. ** Stencil state. Contains all the user settable stencil state.
  140. */
  141. typedef struct __GLstencilStateRec {
  142. /*
  143. ** Stencil test function. When the stencil is enabled this
  144. ** function is applied to the reference value and the stored stencil
  145. ** value as follows:
  146. ** result = ref comparision (mask & stencilBuffer[x][y])
  147. ** If the test fails then the fail op is applied and rendering of
  148. ** the pixel stops.
  149. */
  150. GLenum testFunc;
  151. /*
  152. ** Stencil clear value. Used by glClear.
  153. */
  154. GLshort clear;
  155. /*
  156. ** Reference stencil value.
  157. */
  158. GLshort reference;
  159. /*
  160. ** Stencil mask. This is anded against the contents of the stencil
  161. ** buffer during comparisons.
  162. */
  163. GLshort mask;
  164. /*
  165. ** Stencil write mask
  166. */
  167. GLshort writeMask;
  168. /*
  169. ** When the stencil comparison fails this operation is applied to
  170. ** the stencil buffer.
  171. */
  172. GLenum fail;
  173. /*
  174. ** When the stencil comparison passes and the depth test
  175. ** fails this operation is applied to the stencil buffer.
  176. */
  177. GLenum depthFail;
  178. /*
  179. ** When both the stencil comparison passes and the depth test
  180. ** passes this operation is applied to the stencil buffer.
  181. */
  182. GLenum depthPass;
  183. } __GLstencilState;
  184. /************************************************************************/
  185. typedef struct __GLviewportRec {
  186. /*
  187. ** Viewport parameters from user, as integers.
  188. */
  189. GLint x, y;
  190. GLsizei width, height;
  191. /*
  192. ** Depthrange parameters from user.
  193. */
  194. GLdouble zNear, zFar;
  195. /*XXX move me */
  196. /*
  197. ** Internal form of viewport and depth range used to compute
  198. ** window coordinates from clip coordinates.
  199. */
  200. __GLfloat xScale, xCenter;
  201. __GLfloat yScale, yCenter;
  202. __GLfloat zScale, zCenter;
  203. } __GLviewport;
  204. /************************************************************************/
  205. typedef struct __GLtransformStateRec {
  206. /*
  207. ** Current mode of the matrix stack. This determines what effect
  208. ** the various matrix operations (load, mult, scale) apply to.
  209. */
  210. GLenum matrixMode;
  211. /*
  212. ** User clipping planes in eye space. These are the user clip planes
  213. ** projected into eye space.
  214. */
  215. /* XXX BUG! stacking of eyeClipPlanes is busted! */
  216. __GLcoord *eyeClipPlanes;
  217. __GLcoord *eyeClipPlanesSet;
  218. } __GLtransformState;
  219. /************************************************************************/
  220. /*
  221. ** Enable structures. Anything that can be glEnable'd or glDisable'd is
  222. ** contained in this structure. The enables are kept as single bits
  223. ** in a couple of bitfields.
  224. */
  225. /* Bits in "general" enable word */
  226. #define __GL_ALPHA_TEST_ENABLE (1 << 0)
  227. #define __GL_BLEND_ENABLE (1 << 1)
  228. #define __GL_INDEX_LOGIC_OP_ENABLE (1 << 2)
  229. #define __GL_DITHER_ENABLE (1 << 3)
  230. #define __GL_DEPTH_TEST_ENABLE (1 << 4)
  231. #define __GL_FOG_ENABLE (1 << 5)
  232. #define __GL_LIGHTING_ENABLE (1 << 6)
  233. #define __GL_COLOR_MATERIAL_ENABLE (1 << 7)
  234. #define __GL_LINE_STIPPLE_ENABLE (1 << 8)
  235. #define __GL_LINE_SMOOTH_ENABLE (1 << 9)
  236. #define __GL_POINT_SMOOTH_ENABLE (1 << 10)
  237. #define __GL_POLYGON_SMOOTH_ENABLE (1 << 11)
  238. #define __GL_CULL_FACE_ENABLE (1 << 12)
  239. #define __GL_POLYGON_STIPPLE_ENABLE (1 << 13)
  240. #define __GL_SCISSOR_TEST_ENABLE (1 << 14)
  241. #define __GL_STENCIL_TEST_ENABLE (1 << 15)
  242. #define __GL_TEXTURE_1D_ENABLE (1 << 16)
  243. #define __GL_TEXTURE_2D_ENABLE (1 << 17)
  244. #define __GL_TEXTURE_GEN_S_ENABLE (1 << 18)
  245. #define __GL_TEXTURE_GEN_T_ENABLE (1 << 19)
  246. #define __GL_TEXTURE_GEN_R_ENABLE (1 << 20)
  247. #define __GL_TEXTURE_GEN_Q_ENABLE (1 << 21)
  248. #define __GL_NORMALIZE_ENABLE (1 << 22)
  249. #define __GL_AUTO_NORMAL_ENABLE (1 << 23)
  250. #define __GL_POLYGON_OFFSET_POINT_ENABLE (1 << 24)
  251. #define __GL_POLYGON_OFFSET_LINE_ENABLE (1 << 25)
  252. #define __GL_POLYGON_OFFSET_FILL_ENABLE (1 << 26)
  253. #define __GL_COLOR_LOGIC_OP_ENABLE (1 << 27)
  254. #ifdef GL_EXT_flat_paletted_lighting
  255. // NOTE: Not currently enabled, can be reused if necessary
  256. #define __GL_PALETTED_LIGHTING_ENABLE (1 << 28)
  257. #endif // GL_EXT_flat_paletted_lighting
  258. #ifdef GL_WIN_specular_fog
  259. #define __GL_FOG_SPEC_TEX_ENABLE (1 << 29)
  260. #endif //GL_WIN_specular_fog
  261. #ifdef GL_WIN_multiple_textures
  262. #define __GL_TEXCOMBINE_CLAMP_ENABLE (1 << 30)
  263. #endif // GL_WIN_multiple_textures
  264. /*
  265. ** Composities of the above bits for each glPushAttrib group that has
  266. ** multiple enables, except for those defined below
  267. */
  268. #define __GL_COLOR_BUFFER_ENABLES \
  269. (__GL_ALPHA_TEST_ENABLE | __GL_BLEND_ENABLE | __GL_INDEX_LOGIC_OP_ENABLE \
  270. | __GL_DITHER_ENABLE | __GL_COLOR_LOGIC_OP_ENABLE)
  271. #define __GL_LIGHTING_ENABLES \
  272. (__GL_LIGHTING_ENABLE | __GL_COLOR_MATERIAL_ENABLE)
  273. #define __GL_LINE_ENABLES \
  274. (__GL_LINE_STIPPLE_ENABLE | __GL_LINE_SMOOTH_ENABLE)
  275. #define __GL_POLYGON_ENABLES \
  276. (__GL_POLYGON_SMOOTH_ENABLE | __GL_CULL_FACE_ENABLE \
  277. | __GL_POLYGON_STIPPLE_ENABLE | __GL_POLYGON_OFFSET_POINT_ENABLE \
  278. | __GL_POLYGON_OFFSET_LINE_ENABLE | __GL_POLYGON_OFFSET_FILL_ENABLE)
  279. #define __GL_TEXTURE_ENABLES \
  280. (__GL_TEXTURE_1D_ENABLE | __GL_TEXTURE_2D_ENABLE \
  281. | __GL_TEXTURE_GEN_S_ENABLE | __GL_TEXTURE_GEN_T_ENABLE \
  282. | __GL_TEXTURE_GEN_R_ENABLE | __GL_TEXTURE_GEN_Q_ENABLE)
  283. /* Bits in "eval1" enable word */
  284. #define __GL_MAP1_VERTEX_3_ENABLE (1 << __GL_V3)
  285. #define __GL_MAP1_VERTEX_4_ENABLE (1 << __GL_V4)
  286. #define __GL_MAP1_COLOR_4_ENABLE (1 << __GL_C4)
  287. #define __GL_MAP1_INDEX_ENABLE (1 << __GL_I)
  288. #define __GL_MAP1_NORMAL_ENABLE (1 << __GL_N3)
  289. #define __GL_MAP1_TEXTURE_COORD_1_ENABLE (1 << __GL_T1)
  290. #define __GL_MAP1_TEXTURE_COORD_2_ENABLE (1 << __GL_T2)
  291. #define __GL_MAP1_TEXTURE_COORD_3_ENABLE (1 << __GL_T3)
  292. #define __GL_MAP1_TEXTURE_COORD_4_ENABLE (1 << __GL_T4)
  293. /* Bits in "eval2" enable word */
  294. #define __GL_MAP2_VERTEX_3_ENABLE (1 << __GL_V3)
  295. #define __GL_MAP2_VERTEX_4_ENABLE (1 << __GL_V4)
  296. #define __GL_MAP2_COLOR_4_ENABLE (1 << __GL_C4)
  297. #define __GL_MAP2_INDEX_ENABLE (1 << __GL_I)
  298. #define __GL_MAP2_NORMAL_ENABLE (1 << __GL_N3)
  299. #define __GL_MAP2_TEXTURE_COORD_1_ENABLE (1 << __GL_T1)
  300. #define __GL_MAP2_TEXTURE_COORD_2_ENABLE (1 << __GL_T2)
  301. #define __GL_MAP2_TEXTURE_COORD_3_ENABLE (1 << __GL_T3)
  302. #define __GL_MAP2_TEXTURE_COORD_4_ENABLE (1 << __GL_T4)
  303. /* Bits in "clipPlanes" enable word */
  304. #define __GL_CLIP_PLANE0_ENABLE (1 << 0)
  305. #define __GL_CLIP_PLANE1_ENABLE (1 << 1)
  306. #define __GL_CLIP_PLANE2_ENABLE (1 << 2)
  307. #define __GL_CLIP_PLANE3_ENABLE (1 << 3)
  308. #define __GL_CLIP_PLANE4_ENABLE (1 << 4)
  309. #define __GL_CLIP_PLANE5_ENABLE (1 << 5)
  310. /* Bits in "lights" enable word */
  311. #define __GL_LIGHT0_ENABLE (1 << 0)
  312. #define __GL_LIGHT1_ENABLE (1 << 1)
  313. #define __GL_LIGHT2_ENABLE (1 << 2)
  314. #define __GL_LIGHT3_ENABLE (1 << 3)
  315. #define __GL_LIGHT4_ENABLE (1 << 4)
  316. #define __GL_LIGHT5_ENABLE (1 << 5)
  317. #define __GL_LIGHT6_ENABLE (1 << 6)
  318. #define __GL_LIGHT7_ENABLE (1 << 7)
  319. typedef struct __GLenableStateRec __GLenableState;
  320. struct __GLenableStateRec {
  321. GLuint general;
  322. GLuint lights;
  323. GLuint clipPlanes;
  324. GLushort eval1, eval2;
  325. };
  326. /************************************************************************/
  327. typedef struct __GLrasterStateRec __GLrasterState;
  328. struct __GLrasterStateRec {
  329. /*
  330. ** Alpha function. The alpha function is applied to the alpha color
  331. ** value and the reference value. If it fails then the pixel is
  332. ** not rendered.
  333. */
  334. GLenum alphaFunction;
  335. __GLfloat alphaReference;
  336. /*
  337. ** Alpha blending source and destination factors.
  338. */
  339. GLenum blendSrc;
  340. GLenum blendDst;
  341. /*
  342. ** Logic op. Logic op is only used during color index mode.
  343. */
  344. GLenum logicOp;
  345. /*
  346. ** Color to fill the color portion of the framebuffer when clear
  347. ** is called.
  348. */
  349. __GLcolor clear;
  350. __GLfloat clearIndex;
  351. /*
  352. ** Color index write mask. The color values are masked with this
  353. ** value when writing to the frame buffer so that only the bits set
  354. ** in the mask are changed in the frame buffer.
  355. */
  356. GLint writeMask;
  357. /*
  358. ** RGB write masks. These booleans enable or disable writing of
  359. ** the r, g, b, and a components.
  360. */
  361. GLboolean rMask, gMask, bMask, aMask;
  362. /*
  363. ** This state variable tracks which buffer(s) is being drawn into.
  364. */
  365. GLenum drawBuffer;
  366. /*
  367. ** Draw buffer specified by user. May be different from drawBuffer
  368. ** above. If the user specifies GL_FRONT_LEFT, for example, then
  369. ** drawBuffer is set to GL_FRONT, and drawBufferReturn to
  370. ** GL_FRONT_LEFT.
  371. */
  372. GLenum drawBufferReturn;
  373. };
  374. /************************************************************************/
  375. /*
  376. ** Hint state. Contains all the user controllable hint state.
  377. */
  378. typedef struct {
  379. GLenum perspectiveCorrection;
  380. GLenum pointSmooth;
  381. GLenum lineSmooth;
  382. GLenum polygonSmooth;
  383. GLenum fog;
  384. #ifdef GL_WIN_phong_shading
  385. GLenum phong;
  386. #endif
  387. } __GLhintState;
  388. /************************************************************************/
  389. /*
  390. ** All stackable list state.
  391. */
  392. typedef struct __GLdlistStateRec {
  393. GLuint listBase;
  394. } __GLdlistState;
  395. /************************************************************************/
  396. /*
  397. ** Scissor state from user.
  398. */
  399. typedef struct __GLscissorRec {
  400. GLint scissorX, scissorY, scissorWidth, scissorHeight;
  401. } __GLscissor;
  402. /************************************************************************/
  403. struct __GLattributeRec {
  404. /*
  405. ** Mask of which fields in this structure are valid.
  406. */
  407. GLuint mask;
  408. __GLcurrentState current;
  409. __GLpointState point;
  410. __GLlineState line;
  411. __GLpolygonState polygon;
  412. __GLpolygonStippleState polygonStipple;
  413. __GLpixelState pixel;
  414. __GLlightState light;
  415. __GLfogState fog;
  416. __GLdepthState depth;
  417. __GLaccumState accum;
  418. __GLstencilState stencil;
  419. __GLviewport viewport;
  420. __GLtransformState transform;
  421. __GLenableState enables;
  422. __GLrasterState raster;
  423. __GLhintState hints;
  424. __GLevaluatorState evaluator;
  425. __GLdlistState list;
  426. __GLtextureState texture;
  427. __GLscissor scissor;
  428. };
  429. /************************************************************************/
  430. /*
  431. ** Attribution machine state. This manages the stack of attributes.
  432. */
  433. typedef struct {
  434. /*
  435. ** Attribute stack. The attribute stack keeps track of the
  436. ** attributes that have been pushed.
  437. */
  438. __GLattribute **stack;
  439. /*
  440. ** Attribute stack pointer.
  441. */
  442. __GLattribute **stackPointer;
  443. } __GLattributeMachine;
  444. extern void FASTCALL __glFreeAttributeState(__GLcontext *gc);
  445. extern GLboolean FASTCALL __glCopyContext(__GLcontext *dst, const __GLcontext *src,
  446. GLuint mask);
  447. extern GLenum __glErrorCheckMaterial(GLenum face, GLenum p, GLfloat pv0);
  448. /************************************************************************/
  449. // Client attribute states.
  450. typedef struct __GLclientAttributeRec {
  451. // Mask of which fields in this structure are valid.
  452. GLbitfield mask;
  453. __GLpixelPackMode pixelPackModes;
  454. __GLpixelUnpackMode pixelUnpackModes;
  455. __GLvertexArray vertexArray;
  456. } __GLclientAttribute;
  457. /*
  458. ** Client attribution machine state. This manages the stack of client
  459. ** attributes.
  460. */
  461. typedef struct {
  462. /*
  463. ** Client attribute stack. The client attribute stack keeps track of the
  464. ** client attributes that have been pushed.
  465. */
  466. __GLclientAttribute **stack;
  467. /*
  468. ** Client attribute stack pointer.
  469. */
  470. __GLclientAttribute **stackPointer;
  471. } __GLclientAttributeMachine;
  472. extern void FASTCALL __glFreeClientAttributeState(__GLcontext *gc);
  473. extern GLuint FASTCALL __glInternalPopAttrib(__GLcontext *, GLboolean);
  474. extern GLuint FASTCALL __glInternalPopClientAttrib(__GLcontext *, GLboolean,
  475. GLboolean);
  476. #endif /* __glattrib_h_ */