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.

781 lines
27 KiB

  1. #ifndef __glrender_h_
  2. #define __glrender_h_
  3. /*
  4. ** Copyright 1991-1993, 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. #include "types.h"
  20. #include "constant.h"
  21. #include "cpu.h"
  22. #ifdef GL_WIN_phong_shading
  23. #include "phong.h"
  24. #endif //GL_WIN_phong_shading
  25. /*
  26. ** used to approximate zero (and avoid divide by zero errors)
  27. ** when doing polygon offset with dzdx = 0.
  28. */
  29. #define __GL_PGON_OFFSET_NEAR_ZERO .00001
  30. /*
  31. ** Epsilon value for detecting non-scaling transformation matrices:
  32. */
  33. #define __GL_MATRIX_UNITY_SCALE_EPSILON ((__GLfloat)0.0001)
  34. typedef GLuint __GLstippleWord;
  35. /*
  36. ** A fragment is a collection of all the data needed after rasterization
  37. ** of a primitive has occured, but before the data is entered into various
  38. ** framebuffers. The data contained in the fragment has been normalized
  39. ** into a form for immediate storage into the framebuffer.
  40. */
  41. struct __GLfragmentRec {
  42. /* Screen x, y */
  43. GLint x, y;
  44. /* Z coordinate in form used by depth buffer */
  45. __GLzValue z;
  46. /*
  47. ** Color of the fragment. When in colorIndexMode only the r component
  48. ** is valid.
  49. */
  50. __GLcolor color;
  51. /* Texture information for the fragment */
  52. __GLfloat s, t, qw;
  53. /* Fog information for the fragment */
  54. __GLfloat f;
  55. };
  56. /************************************************************************/
  57. /*
  58. ** Shader record for iterated objects (lines/triangles). This keeps
  59. ** track of all the various deltas needed to rasterize a triangle.
  60. */
  61. struct __GLshadeRec {
  62. GLint dxLeftLittle, dxLeftBig;
  63. GLint dxLeftFrac;
  64. GLint ixLeft, ixLeftFrac;
  65. GLint dxRightLittle, dxRightBig;
  66. GLint dxRightFrac;
  67. GLint ixRight, ixRightFrac;
  68. __GLfloat area;
  69. __GLfloat dxAC, dxBC, dyAC, dyBC;
  70. __GLfragment frag;
  71. GLint length;
  72. /* Color */
  73. __GLfloat rLittle, gLittle, bLittle, aLittle;
  74. __GLfloat rBig, gBig, bBig, aBig;
  75. __GLfloat drdx, dgdx, dbdx, dadx;
  76. __GLfloat drdy, dgdy, dbdy, dady;
  77. /* Depth */
  78. GLint zLittle, zBig;
  79. GLint dzdx;
  80. __GLfloat dzdyf, dzdxf;
  81. /* Texture */
  82. __GLfloat sLittle, tLittle, qwLittle;
  83. __GLfloat sBig, tBig, qwBig;
  84. __GLfloat dsdx, dtdx, dqwdx;
  85. __GLfloat dsdy, dtdy, dqwdy;
  86. __GLfloat fLittle, fBig;
  87. __GLfloat dfdy, dfdx;
  88. GLuint modeFlags;
  89. __GLzValue *zbuf;
  90. GLint zbufBig, zbufLittle;
  91. __GLstencilCell *sbuf;
  92. GLint sbufBig, sbufLittle;
  93. __GLcolor *colors;
  94. __GLcolor *fbcolors;
  95. __GLstippleWord *stipplePat;
  96. GLboolean done;
  97. __GLcolorBuffer *cfb;
  98. #ifdef GL_WIN_phong_shading
  99. __GLphongShade phong;
  100. #endif //GL_WIN_phong_shading
  101. };
  102. /*
  103. ** The distinction between __GL_SHADE_SMOOTH and __GL_SHADE_SMOOTH_LIGHT is
  104. ** simple. __GL_SHADE_SMOOTH indicates if the polygon will be smoothly
  105. ** shaded, and __GL_SHADE_SMOOTH_LIGHT indicates if the polygon will be
  106. ** lit at each vertex. Note that __GL_SHADE_SMOOTH might be set while
  107. ** __GL_SHADE_SMOOTH_LIGHT is not set if the lighting model is GL_FLAT, but
  108. ** the polygons are fogged.
  109. */
  110. #define __GL_SHADE_RGB 0x0001
  111. #define __GL_SHADE_SMOOTH 0x0002 /* smooth shaded polygons */
  112. #define __GL_SHADE_DEPTH_TEST 0x0004
  113. #define __GL_SHADE_TEXTURE 0x0008
  114. #define __GL_SHADE_STIPPLE 0x0010 /* polygon stipple */
  115. #define __GL_SHADE_STENCIL_TEST 0x0020
  116. #define __GL_SHADE_DITHER 0x0040
  117. #define __GL_SHADE_LOGICOP 0x0080
  118. #define __GL_SHADE_BLEND 0x0100
  119. #define __GL_SHADE_ALPHA_TEST 0x0200
  120. #define __GL_SHADE_TWOSIDED 0x0400
  121. #define __GL_SHADE_MASK 0x0800
  122. /* Two kinds of fog... */
  123. #define __GL_SHADE_SLOW_FOG 0x1000
  124. #define __GL_SHADE_CHEAP_FOG 0x2000
  125. /* do we iterate depth values in software */
  126. #define __GL_SHADE_DEPTH_ITER 0x4000
  127. #define __GL_SHADE_LINE_STIPPLE 0x8000
  128. #define __GL_SHADE_CULL_FACE 0x00010000
  129. #define __GL_SHADE_SMOOTH_LIGHT 0x00020000 /* smoothly lit polygons */
  130. // Set when the texture mode makes polygon color irrelevant
  131. #define __GL_SHADE_FULL_REPLACE_TEXTURE 0x00040000
  132. #ifdef GL_WIN_phong_shading
  133. /*
  134. ** This is set when shade-model is GL_PHONG_EXT and Lighting is ON
  135. ** otherwise use smooth shading.
  136. ** Used in place of __GL_SHADE_SMOOTH_LIGHT when ShadeModel is
  137. ** GL_PHONG_EXT.
  138. */
  139. #define __GL_SHADE_PHONG 0x00100000
  140. #endif //GL_WIN_phong_shading
  141. // Set when the current sub-triangle is the last (or only) subtriangle
  142. #define __GL_SHADE_LAST_SUBTRI 0x00080000
  143. #ifdef GL_WIN_specular_fog
  144. // Set when the specularly-lit textures are needed using fog.
  145. #define __GL_SHADE_SPEC_FOG 0x00200000
  146. #endif //GL_WIN_specular_fog
  147. #define __GL_SHADE_COMPUTE_FOG 0x00400000
  148. #define __GL_SHADE_INTERP_FOG 0x00800000
  149. /************************************************************************/
  150. /*
  151. ** __GL_STIPPLE_COUNT_BITS is the number of bits needed to represent a
  152. ** stipple count (5 bits).
  153. **
  154. ** __GL_STIPPLE_BITS is the number of bits in a stipple word (32 bits).
  155. */
  156. #define __GL_STIPPLE_COUNT_BITS 5
  157. #define __GL_STIPPLE_BITS (1 << __GL_STIPPLE_COUNT_BITS)
  158. #ifdef __GL_STIPPLE_MSB
  159. #define __GL_STIPPLE_SHIFT(i) (1 << (__GL_STIPPLE_BITS - 1 - (i)))
  160. #else
  161. #define __GL_STIPPLE_SHIFT(i) (1 << (i))
  162. #endif
  163. #define __GL_MAX_STIPPLE_WORDS \
  164. ((__GL_MAX_MAX_VIEWPORT + __GL_STIPPLE_BITS - 1) / __GL_STIPPLE_BITS)
  165. #ifdef NT
  166. // Allow 256 bytes of stipple on the stack. This may seem small but
  167. // stipples are consumed a bit at a time so this is good enough for
  168. // 2048 stipple bits
  169. #define __GL_MAX_STACK_STIPPLE_BITS \
  170. 2048
  171. #define __GL_MAX_STACK_STIPPLE_WORDS \
  172. ((__GL_MAX_STACK_STIPPLE_BITS+__GL_STIPPLE_BITS-1)/__GL_STIPPLE_BITS)
  173. #endif
  174. /************************************************************************/
  175. /*
  176. ** Accumulation buffer cells for each color component. Note that these
  177. ** items needs to be at least 2 bits bigger than the color components
  178. ** that drive them, with 2 times being ideal. This declaration assumes
  179. ** that the underlying color components are no more than 14 bits and
  180. ** hopefully 8.
  181. */
  182. typedef struct __GLaccumCellRec {
  183. __GLaccumCellElement r, g, b, a;
  184. } __GLaccumCell;
  185. /************************************************************************/
  186. struct __GLbitmapRec {
  187. GLsizei width;
  188. GLsizei height;
  189. GLfloat xorig;
  190. GLfloat yorig;
  191. GLfloat xmove;
  192. GLfloat ymove;
  193. GLint imageSize; /* An optimization */
  194. /* bitmap */
  195. };
  196. extern void __glDrawBitmap(__GLcontext *gc, GLsizei width, GLsizei height,
  197. GLfloat xOrig, GLfloat yOrig,
  198. GLfloat xMove, GLfloat yMove,
  199. const GLubyte bits[]);
  200. extern __GLbitmap *__glAllocBitmap(__GLcontext *gc,
  201. GLsizei width, GLsizei height,
  202. GLfloat xOrig, GLfloat yOrig,
  203. GLfloat xMove, GLfloat yMove);
  204. extern void FASTCALL __glRenderBitmap(__GLcontext *gc, const __GLbitmap *bitmap,
  205. const GLubyte *bits);
  206. /************************************************************************/
  207. /* New AA line algorithm supports widths one or more. Until that changes,
  208. ** don't change this minimum!
  209. */
  210. #define __GL_POINT_SIZE_MINIMUM ((__GLfloat) 1.0)
  211. #define __GL_POINT_SIZE_MAXIMUM ((__GLfloat) 10.0)
  212. #define __GL_POINT_SIZE_GRANULARITY ((__GLfloat) 0.125)
  213. extern void FASTCALL __glBeginPoints(__GLcontext *gc);
  214. extern void FASTCALL __glEndPoints(__GLcontext *gc);
  215. extern void FASTCALL __glPoint(__GLcontext *gc, __GLvertex *vx);
  216. extern void FASTCALL __glPointFast(__GLcontext *gc, __GLvertex *vx);
  217. /* Various point rendering implementations */
  218. void FASTCALL __glRenderAliasedPointN(__GLcontext *gc, __GLvertex *v);
  219. void FASTCALL __glRenderAliasedPoint1(__GLcontext *gc, __GLvertex *v);
  220. void FASTCALL __glRenderAliasedPoint1_NoTex(__GLcontext *gc, __GLvertex *v);
  221. #ifdef __BUGGY_RENDER_POINT
  222. void FASTCALL __glRenderFlatFogPoint(__GLcontext *gc, __GLvertex *v);
  223. #ifdef NT
  224. void FASTCALL __glRenderFlatFogPointSlow(__GLcontext *gc, __GLvertex *v);
  225. #endif
  226. #endif //__BUGGY_RENDER_POINT
  227. void FASTCALL __glRenderAntiAliasedRGBPoint(__GLcontext *gc, __GLvertex *v);
  228. void FASTCALL __glRenderAntiAliasedCIPoint(__GLcontext *gc, __GLvertex *v);
  229. /************************************************************************/
  230. #define __GL_LINE_WIDTH_MINIMUM ((__GLfloat) 0.5)
  231. #define __GL_LINE_WIDTH_MAXIMUM ((__GLfloat) 10.0)
  232. #define __GL_LINE_WIDTH_GRANULARITY ((__GLfloat) 0.125)
  233. /*
  234. ** Don't change these constants without fixing LIGHT/rex_linespan.ma which
  235. ** currently assumes that __GL_X_MAJOR is 0.
  236. */
  237. #define __GL_X_MAJOR 0
  238. #define __GL_Y_MAJOR 1
  239. /*
  240. ** Use a fixed point notation of 15.17
  241. **
  242. ** This should support screen sizes up to 4K x 4K, with 5 subpixel bits
  243. ** for 4K x 4K screens.
  244. */
  245. #define __GL_LINE_FRACBITS 17
  246. #define __GL_LINE_INT_TO_FIXED(x) ((x) << __GL_LINE_FRACBITS)
  247. #define __GL_LINE_FLOAT_TO_FIXED(x) ((x) * (1 << __GL_LINE_FRACBITS))
  248. #define __GL_LINE_FIXED_ONE (1 << __GL_LINE_FRACBITS)
  249. #define __GL_LINE_FIXED_HALF (1 << (__GL_LINE_FRACBITS-1))
  250. #define __GL_LINE_FIXED_TO_FLOAT(x) (((GLfloat) (x)) / __GL_LINE_FIXED_ONE)
  251. #define __GL_LINE_FIXED_TO_INT(x) (((unsigned int) (x)) >> __GL_LINE_FRACBITS)
  252. /*
  253. ** Contains variables needed to draw all line options.
  254. */
  255. struct __GLlineOptionsRec {
  256. GLint axis, numPixels;
  257. __GLfloat offset, length, oneOverLength;
  258. GLint xStart, yStart;
  259. GLint xLittle, xBig, yLittle, yBig;
  260. GLint fraction, dfraction;
  261. __GLfloat curF, curR, curG, curB, curA, curS, curT, curQW;
  262. __GLzValue curZ;
  263. __GLfloat antiAliasPercent;
  264. __GLfloat f0;
  265. GLint width;
  266. const __GLvertex *v0, *v1;
  267. /* Anti-aliased line only info */
  268. __GLfloat realLength;
  269. __GLfloat dldx, dldy;
  270. __GLfloat dddx, dddy;
  271. __GLfloat dlLittle, dlBig;
  272. __GLfloat ddLittle, ddBig;
  273. __GLfloat plength, pwidth;
  274. /* Anti-aliased stippled lines only */
  275. __GLfloat stippleOffset;
  276. __GLfloat oneOverStippleRepeat;
  277. };
  278. /*
  279. ** Line state. Contains all the line specific state, as well as
  280. ** procedure pointers used during rendering operations.
  281. */
  282. typedef struct {
  283. /*
  284. ** stipplePosition indicates which bit in mask is being examined
  285. ** for the next pixel in the line to be rendered. It is also used
  286. ** by feedback lines to determine if they are the first of a connected
  287. ** loop.
  288. */
  289. GLint stipplePosition;
  290. /*
  291. ** Repeat factor. After repeat is reduced to zero the
  292. ** stipplePosition is updated.
  293. */
  294. GLint repeat;
  295. /*
  296. ** Set to FALSE when the stipple needs to be reset.
  297. */
  298. GLboolean notResetStipple;
  299. __GLlineOptions options;
  300. } __GLlineMachine;
  301. #ifdef NT
  302. // renderLine flags
  303. #define __GL_LVERT_FIRST 0x0001
  304. #endif
  305. void FASTCALL __glBeginLStrip(__GLcontext *gc);
  306. void FASTCALL __glEndLStrip(__GLcontext *gc);
  307. void FASTCALL __glBeginLLoop(__GLcontext *gc);
  308. void FASTCALL __glEndLLoop(__GLcontext *gc);
  309. void FASTCALL __glBeginLines(__GLcontext *gc);
  310. void FASTCALL __glEndLines(__GLcontext *gc);
  311. #ifdef NT
  312. void FASTCALL __glClipLine(__GLcontext *gc, __GLvertex *v0, __GLvertex *v1,
  313. GLuint flags);
  314. void FASTCALL __glNopLineBegin(__GLcontext *gc);
  315. void FASTCALL __glNopLineEnd(__GLcontext *gc);
  316. #else
  317. void FASTCALL __glClipLine(__GLcontext *gc, __GLvertex *v0, __GLvertex *v1);
  318. #endif
  319. #ifdef NT
  320. void FASTCALL __glRenderAliasLine(__GLcontext *gc, __GLvertex *v0,
  321. __GLvertex *v1, GLuint flags);
  322. void FASTCALL __glRenderFlatFogLine(__GLcontext *gc, __GLvertex *v0,
  323. __GLvertex *v1, GLuint flags);
  324. void FASTCALL __glRenderAntiAliasLine(__GLcontext *gc, __GLvertex *v0,
  325. __GLvertex *v1, GLuint flags);
  326. BOOL FASTCALL __glInitLineData(__GLcontext *gc, __GLvertex *v0, __GLvertex *v1);
  327. #else
  328. void FASTCALL __glRenderAliasLine(__GLcontext *gc, __GLvertex *v0, __GLvertex *v1);
  329. void FASTCALL __glRenderFlatFogLine(__GLcontext *gc, __GLvertex *v0,
  330. __GLvertex *v1);
  331. void FASTCALL __glRenderAntiAliasLine(__GLcontext *gc, __GLvertex *v0, __GLvertex *v1);
  332. void FASTCALL __glInitLineData(__GLcontext *gc, __GLvertex *v0, __GLvertex *v1);
  333. #endif
  334. /*
  335. ** Line procs
  336. */
  337. GLboolean FASTCALL __glProcessLine(__GLcontext *);
  338. GLboolean FASTCALL __glProcessLine3NW(__GLcontext *);
  339. GLboolean FASTCALL __glWideLineRep(__GLcontext *);
  340. GLboolean FASTCALL __glDrawBothLine(__GLcontext *);
  341. GLboolean FASTCALL __glScissorLine(__GLcontext *);
  342. GLboolean FASTCALL __glStippleLine(__GLcontext *);
  343. GLboolean FASTCALL __glStencilTestLine(__GLcontext *);
  344. #ifdef NT
  345. GLboolean FASTCALL __glDepth16TestStencilLine(__GLcontext *);
  346. #endif
  347. GLboolean FASTCALL __glDepthTestStencilLine(__GLcontext *);
  348. GLboolean FASTCALL __glDepthPassLine(__GLcontext *);
  349. GLboolean FASTCALL __glDitherCILine(__GLcontext *);
  350. GLboolean FASTCALL __glDitherRGBALine(__GLcontext *);
  351. GLboolean FASTCALL __glStoreLine(__GLcontext *);
  352. GLboolean FASTCALL __glAntiAliasLine(__GLcontext *);
  353. #ifdef __GL_USEASMCODE
  354. GLboolean FASTCALL __glDepthTestLine_asm(__GLcontext *gc);
  355. /*
  356. ** A LEQUAL specific line depth tester because LEQUAL is the method of
  357. ** choice. :)
  358. */
  359. GLboolean FASTCALL __glDepthTestLine_LEQ_asm(__GLcontext *gc);
  360. /* Assembly routines */
  361. void __glDTP_LEQUAL(void);
  362. void __glDTP_EQUAL(void);
  363. void __glDTP_GREATER(void);
  364. void __glDTP_NOTEQUAL(void);
  365. void __glDTP_GEQUAL(void);
  366. void __glDTP_ALWAYS(void);
  367. void __glDTP_LESS(void);
  368. void __glDTP_LEQUAL_M(void);
  369. void __glDTP_EQUAL_M(void);
  370. void __glDTP_GREATER_M(void);
  371. void __glDTP_NOTEQUAL_M(void);
  372. void __glDTP_GEQUAL_M(void);
  373. void __glDTP_ALWAYS_M(void);
  374. void __glDTP_LESS_M(void);
  375. #else
  376. #ifdef NT
  377. GLboolean FASTCALL __glDepth16TestLine(__GLcontext *);
  378. #endif
  379. GLboolean FASTCALL __glDepthTestLine(__GLcontext *);
  380. #endif
  381. /*
  382. ** Line stippled procs
  383. */
  384. GLboolean FASTCALL __glScissorStippledLine(__GLcontext *);
  385. GLboolean FASTCALL __glWideStippleLineRep(__GLcontext *);
  386. GLboolean FASTCALL __glDrawBothStippledLine(__GLcontext *);
  387. GLboolean FASTCALL __glStencilTestStippledLine(__GLcontext *);
  388. #ifdef NT
  389. GLboolean FASTCALL __glDepth16TestStippledLine(__GLcontext *);
  390. GLboolean FASTCALL __glDepth16TestStencilStippledLine(__GLcontext *);
  391. #endif
  392. GLboolean FASTCALL __glDepthTestStippledLine(__GLcontext *);
  393. GLboolean FASTCALL __glDepthTestStencilStippledLine(__GLcontext *);
  394. GLboolean FASTCALL __glDepthPassStippledLine(__GLcontext *);
  395. GLboolean FASTCALL __glDitherCIStippledLine(__GLcontext *);
  396. GLboolean FASTCALL __glDitherRGBAStippledLine(__GLcontext *);
  397. GLboolean FASTCALL __glStoreStippledLine(__GLcontext *);
  398. GLboolean FASTCALL __glAntiAliasStippledLine(__GLcontext *);
  399. /*
  400. ** C depth-test routines
  401. */
  402. GLboolean FASTCALL __glDT_NEVER( __GLzValue, __GLzValue * );
  403. GLboolean FASTCALL __glDT_LEQUAL( __GLzValue, __GLzValue * );
  404. GLboolean FASTCALL __glDT_LESS( __GLzValue, __GLzValue * );
  405. GLboolean FASTCALL __glDT_EQUAL( __GLzValue, __GLzValue * );
  406. GLboolean FASTCALL __glDT_GREATER( __GLzValue, __GLzValue * );
  407. GLboolean FASTCALL __glDT_NOTEQUAL( __GLzValue, __GLzValue * );
  408. GLboolean FASTCALL __glDT_GEQUAL( __GLzValue, __GLzValue * );
  409. GLboolean FASTCALL __glDT_ALWAYS( __GLzValue, __GLzValue * );
  410. GLboolean FASTCALL __glDT_LEQUAL_M( __GLzValue, __GLzValue * );
  411. GLboolean FASTCALL __glDT_LESS_M( __GLzValue, __GLzValue * );
  412. GLboolean FASTCALL __glDT_EQUAL_M( __GLzValue, __GLzValue * );
  413. GLboolean FASTCALL __glDT_GREATER_M( __GLzValue, __GLzValue * );
  414. GLboolean FASTCALL __glDT_NOTEQUAL_M( __GLzValue, __GLzValue * );
  415. GLboolean FASTCALL __glDT_GEQUAL_M( __GLzValue, __GLzValue * );
  416. GLboolean FASTCALL __glDT_ALWAYS_M( __GLzValue, __GLzValue * );
  417. GLboolean FASTCALL __glDT16_LEQUAL( __GLzValue, __GLzValue * );
  418. GLboolean FASTCALL __glDT16_LESS( __GLzValue, __GLzValue * );
  419. GLboolean FASTCALL __glDT16_EQUAL( __GLzValue, __GLzValue * );
  420. GLboolean FASTCALL __glDT16_GREATER( __GLzValue, __GLzValue * );
  421. GLboolean FASTCALL __glDT16_NOTEQUAL( __GLzValue, __GLzValue * );
  422. GLboolean FASTCALL __glDT16_GEQUAL( __GLzValue, __GLzValue * );
  423. GLboolean FASTCALL __glDT16_ALWAYS( __GLzValue, __GLzValue * );
  424. GLboolean FASTCALL __glDT16_LEQUAL_M( __GLzValue, __GLzValue * );
  425. GLboolean FASTCALL __glDT16_LESS_M( __GLzValue, __GLzValue * );
  426. GLboolean FASTCALL __glDT16_EQUAL_M( __GLzValue, __GLzValue * );
  427. GLboolean FASTCALL __glDT16_GREATER_M( __GLzValue, __GLzValue * );
  428. GLboolean FASTCALL __glDT16_NOTEQUAL_M( __GLzValue, __GLzValue * );
  429. GLboolean FASTCALL __glDT16_GEQUAL_M( __GLzValue, __GLzValue * );
  430. GLboolean FASTCALL __glDT16_ALWAYS_M( __GLzValue, __GLzValue * );
  431. extern GLboolean (FASTCALL *__glCDTPixel[32])(__GLzValue, __GLzValue * );
  432. /************************************************************************/
  433. /*
  434. ** Polygon machine state. Contains all the polygon specific state,
  435. ** as well as procedure pointers used during rendering operations.
  436. */
  437. typedef struct __GLpolygonMachineRec {
  438. /*
  439. ** Internal form of users stipple. Users stipple is always
  440. ** normalized to stippleWord sized with the LSB of each word mapping
  441. ** to the left x coordinate.
  442. */
  443. __GLstippleWord stipple[32];
  444. /*
  445. ** Polygon (triangle really) shading state. Used by polygon fillers
  446. ** and span routines.
  447. */
  448. __GLshade shader;
  449. /*
  450. ** Lookup table that returns the face (0=front, 1=back) when indexed
  451. ** by a flag which is zero for CW and 1 for CCW. If FrontFace is CW:
  452. ** face[0] = 0
  453. ** face[1] = 1
  454. ** else
  455. ** face[0] = 1
  456. ** face[1] = 0
  457. */
  458. GLubyte face[2];
  459. /*
  460. ** Internal form of polygon mode for each face
  461. */
  462. GLubyte mode[2];
  463. /*
  464. ** Culling flag. 0 when culling the front face, 1 when culling the
  465. ** back face and 2 when not culling.
  466. */
  467. GLubyte cullFace;
  468. } __GLpolygonMachine;
  469. /* defines for above cullFlag */
  470. #define __GL_CULL_FLAG_FRONT __GL_FRONTFACE
  471. #define __GL_CULL_FLAG_BACK __GL_BACKFACE
  472. #define __GL_CULL_FLAG_DONT 2
  473. /* Indicies for face[] array in polygonMachine above */
  474. #define __GL_CW 0
  475. #define __GL_CCW 1
  476. /* Internal numbering for polymode values */
  477. #define __GL_POLYGON_MODE_FILL (GL_FILL & 0xf)
  478. #define __GL_POLYGON_MODE_LINE (GL_LINE & 0xf)
  479. #define __GL_POLYGON_MODE_POINT (GL_POINT & 0xf)
  480. extern void FASTCALL __glBeginPolygon(__GLcontext *gc);
  481. extern void FASTCALL __glBeginQStrip(__GLcontext *gc);
  482. extern void FASTCALL __glBeginQuads(__GLcontext *gc);
  483. extern void FASTCALL __glBeginTFan(__GLcontext *gc);
  484. extern void FASTCALL __glBeginTriangles(__GLcontext *gc);
  485. extern void FASTCALL __glBeginTStrip(__GLcontext *gc);
  486. extern void FASTCALL __glClipTriangle(__GLcontext *gc, __GLvertex *a, __GLvertex *b,
  487. __GLvertex *c, GLuint orClipCodes);
  488. extern void FASTCALL __glClipPolygon(__GLcontext *gc, __GLvertex *v0, GLint nv);
  489. extern void __glDoPolygonClip(__GLcontext *gc, __GLvertex **vp, GLint nv,
  490. GLuint orClipCodes);
  491. extern void FASTCALL __glFrustumClipPolygon(__GLcontext *gc, __GLvertex *v0, GLint nv);
  492. extern void FASTCALL __glConvertStipple(__GLcontext *gc);
  493. /* Rectangle processing proc */
  494. extern void __glRect(__GLcontext *gc, __GLfloat x0, __GLfloat y0,
  495. __GLfloat x1, __GLfloat y1);
  496. /*
  497. ** Triangle render proc that handles culling, twosided lighting and
  498. ** polygon mode.
  499. */
  500. extern void FASTCALL __glRenderTriangle(__GLcontext *gc, __GLvertex *a,
  501. __GLvertex *b, __GLvertex *c);
  502. extern void FASTCALL __glRenderFlatTriangle(__GLcontext *gc, __GLvertex *a,
  503. __GLvertex *b, __GLvertex *c);
  504. extern void FASTCALL __glRenderSmoothTriangle(__GLcontext *gc, __GLvertex *a,
  505. __GLvertex *b, __GLvertex *c);
  506. #ifdef GL_WIN_phong_shading
  507. extern void FASTCALL __glRenderPhongTriangle(__GLcontext *gc, __GLvertex *a,
  508. __GLvertex *b, __GLvertex *c);
  509. #endif //GL_WIN_phong_shading
  510. extern void FASTCALL __glDontRenderTriangle(__GLcontext *gc, __GLvertex *a,
  511. __GLvertex *b, __GLvertex *c);
  512. /*
  513. ** Triangle filling procs for each polygon smooth mode
  514. */
  515. void FASTCALL __glFillTriangle(__GLcontext *gc, __GLvertex *a,
  516. __GLvertex *b, __GLvertex *c, GLboolean ccw);
  517. #ifdef GL_WIN_phong_shading
  518. extern void FASTCALL __glFillPhongTriangle(__GLcontext *gc, __GLvertex *a,
  519. __GLvertex *b, __GLvertex *c, GLboolean ccw);
  520. extern void FASTCALL __glFillAntiAliasedPhongTriangle(__GLcontext *gc,
  521. __GLvertex *a,
  522. __GLvertex *b,
  523. __GLvertex *c,
  524. GLboolean ccw);
  525. #endif //GL_WIN_phong_shading
  526. void FASTCALL __glFillFlatFogTriangle(__GLcontext *gc, __GLvertex *a,
  527. __GLvertex *b, __GLvertex *c,
  528. GLboolean ccw);
  529. void FASTCALL __glFillAntiAliasedTriangle(__GLcontext *gc, __GLvertex *a,
  530. __GLvertex *b, __GLvertex *c,
  531. GLboolean ccw);
  532. #ifdef GL_WIN_specular_fog
  533. void FASTCALL __glFillFlatSpecFogTriangle(__GLcontext *gc, __GLvertex *a,
  534. __GLvertex *b, __GLvertex *c,
  535. GLboolean ccw);
  536. #endif //GL_WIN_specular_fog
  537. /*
  538. ** Polygon offset calc
  539. */
  540. extern __GLfloat __glPolygonOffsetZ(__GLcontext *gc );
  541. /*
  542. ** Span procs
  543. */
  544. extern GLboolean FASTCALL __glProcessSpan(__GLcontext *);
  545. extern GLboolean FASTCALL __glProcessReplicateSpan(__GLcontext *);
  546. extern GLboolean FASTCALL __glClipSpan(__GLcontext *);
  547. extern GLboolean FASTCALL __glStippleSpan(__GLcontext *);
  548. extern GLboolean FASTCALL __glAlphaTestSpan(__GLcontext *);
  549. #ifdef __GL_USEASMCODE
  550. /* Assembly routines */
  551. void FASTCALL __glDTS_LEQUAL(void);
  552. void FASTCALL __glDTS_EQUAL(void);
  553. void FASTCALL __glDTS_GREATER(void);
  554. void FASTCALL __glDTS_NOTEQUAL(void);
  555. void FASTCALL __glDTS_GEQUAL(void);
  556. void FASTCALL __glDTS_ALWAYS(void);
  557. void FASTCALL __glDTS_LESS(void);
  558. void FASTCALL __glDTS_LEQUAL_M(void);
  559. void FASTCALL __glDTS_EQUAL_M(void);
  560. void FASTCALL __glDTS_GREATER_M(void);
  561. void FASTCALL __glDTS_NOTEQUAL_M(void);
  562. void FASTCALL __glDTS_GEQUAL_M(void);
  563. void FASTCALL __glDTS_ALWAYS_M(void);
  564. void FASTCALL __glDTS_LESS_M(void);
  565. extern GLboolean FASTCALL __glStencilTestSpan_asm(__GLcontext *);
  566. extern GLboolean FASTCALL __glDepthTestSpan_asm(__GLcontext *);
  567. extern void (*__glSDepthTestPixel[16])(void);
  568. #else
  569. extern GLboolean FASTCALL __glStencilTestSpan(__GLcontext *);
  570. #ifdef NT
  571. extern GLboolean FASTCALL __glDepth16TestSpan(__GLcontext *);
  572. #endif
  573. extern GLboolean FASTCALL __glDepthTestSpan(__GLcontext *);
  574. #endif
  575. #ifdef NT
  576. extern GLboolean FASTCALL __glDepth16TestStencilSpan(__GLcontext *);
  577. #endif
  578. extern GLboolean FASTCALL __glDepthTestStencilSpan(__GLcontext *);
  579. extern GLboolean FASTCALL __glDepthPassSpan(__GLcontext *);
  580. extern GLboolean FASTCALL __glColorSpan1(__GLcontext *);
  581. extern GLboolean FASTCALL __glColorSpan2(__GLcontext *);
  582. extern GLboolean FASTCALL __glColorSpan3(__GLcontext *);
  583. extern GLboolean FASTCALL __glFlatRGBASpan(__GLcontext *);
  584. extern GLboolean FASTCALL __glShadeRGBASpan(__GLcontext *);
  585. #ifdef GL_WIN_phong_shading
  586. extern GLboolean FASTCALL __glPhongRGBASpan(__GLcontext *);
  587. extern GLboolean FASTCALL __glPhongCISpan(__GLcontext *);
  588. extern GLboolean FASTCALL __glPhongRGBALineSpan(__GLcontext *);
  589. extern GLboolean FASTCALL __glPhongCILineSpan(__GLcontext *);
  590. #endif //GL_WIN_phong_shading
  591. extern GLboolean FASTCALL __glFlatCISpan(__GLcontext *);
  592. extern GLboolean FASTCALL __glShadeCISpan(__GLcontext *);
  593. extern GLboolean FASTCALL __glTextureSpan(__GLcontext *);
  594. extern GLboolean FASTCALL __glFogSpan(__GLcontext *);
  595. extern GLboolean FASTCALL __glFogSpanSlow(__GLcontext *);
  596. extern GLboolean FASTCALL __glDrawBothSpan(__GLcontext *);
  597. extern GLboolean FASTCALL __glIntegrateSpan1(__GLcontext *);
  598. extern GLboolean FASTCALL __glIntegrateSpan2(__GLcontext *);
  599. extern GLboolean FASTCALL __glIntegrateSpan3(__GLcontext *);
  600. extern GLboolean FASTCALL __glIntegrateSpan4(__GLcontext *);
  601. extern GLboolean FASTCALL __glDitherRGBASpan(__GLcontext *);
  602. extern GLboolean FASTCALL __glDitherCISpan(__GLcontext *);
  603. extern GLboolean FASTCALL __glRoundRGBASpan(__GLcontext *);
  604. extern GLboolean FASTCALL __glRoundCISpan(__GLcontext*);
  605. extern GLboolean FASTCALL __glLogicOpSpan(__GLcontext *);
  606. extern GLboolean FASTCALL __glMaskRGBASpan(__GLcontext *);
  607. extern GLboolean FASTCALL __glMaskCISpan(__GLcontext *);
  608. /*
  609. ** Stippled span procs
  610. */
  611. extern GLboolean FASTCALL __glStippleStippledSpan(__GLcontext *);
  612. extern GLboolean FASTCALL __glAlphaTestStippledSpan(__GLcontext *);
  613. extern GLboolean FASTCALL __glStencilTestStippledSpan(__GLcontext *);
  614. #ifdef NT
  615. extern GLboolean FASTCALL __glDepth16TestStippledSpan(__GLcontext *);
  616. extern GLboolean FASTCALL __glDepth16TestStencilStippledSpan(__GLcontext *);
  617. #endif
  618. extern GLboolean FASTCALL __glDepthTestStippledSpan(__GLcontext *);
  619. extern GLboolean FASTCALL __glDepthTestStencilStippledSpan(__GLcontext *);
  620. extern GLboolean FASTCALL __glDepthPassStippledSpan(__GLcontext *);
  621. extern GLboolean FASTCALL __glColorStippledSpan1(__GLcontext *);
  622. extern GLboolean FASTCALL __glColorStippledSpan2(__GLcontext *);
  623. extern GLboolean FASTCALL __glColorStippledSpan3(__GLcontext *);
  624. extern GLboolean FASTCALL __glTextureStippledSpan(__GLcontext *);
  625. extern GLboolean FASTCALL __glFogStippledSpan(__GLcontext *);
  626. extern GLboolean FASTCALL __glFogStippledSpanSlow(__GLcontext *);
  627. extern GLboolean FASTCALL __glDrawBothStippledSpan(__GLcontext *);
  628. extern GLboolean FASTCALL __glIntegrateStippledSpan1(__GLcontext *);
  629. extern GLboolean FASTCALL __glIntegrateStippledSpan2(__GLcontext *);
  630. extern GLboolean FASTCALL __glIntegrateStippledSpan3(__GLcontext *);
  631. extern GLboolean FASTCALL __glIntegrateStippledSpan4(__GLcontext *);
  632. extern GLboolean FASTCALL __glBlendStippledSpan(__GLcontext *);
  633. extern GLboolean FASTCALL __glDitherRGBAStippledSpan(__GLcontext *);
  634. extern GLboolean FASTCALL __glDitherCIStippledSpan(__GLcontext *);
  635. extern GLboolean FASTCALL __glRoundRGBAStippledSpan(__GLcontext *);
  636. extern GLboolean FASTCALL __glRoundCIStippledSpan(__GLcontext *);
  637. extern GLboolean FASTCALL __glLogicOpStippledSpan(__GLcontext *);
  638. /************************************************************************/
  639. extern void FASTCALL __glValidateAlphaTest(__GLcontext *gc);
  640. /************************************************************************/
  641. extern void FASTCALL __glValidateStencil(__GLcontext *gc, __GLstencilBuffer *sfb);
  642. #define __GL_STENCIL_RANGE (1 << (sizeof(__GLstencilCell) * 8))/*XXX*/
  643. #define __GL_MAX_STENCIL_VALUE (__GL_STENCIL_RANGE - 1)
  644. /************************************************************************/
  645. void __glFogFragmentSlow(__GLcontext *gc, __GLfragment *fr, __GLfloat f);
  646. __GLfloat FASTCALL __glFogVertex(__GLcontext *gc, __GLvertex *fr);
  647. __GLfloat FASTCALL __glFogVertexLinear(__GLcontext *gc, __GLvertex *fr);
  648. void __glFogColorSlow(__GLcontext *gc, __GLcolor *out, __GLcolor *in,
  649. __GLfloat fog);
  650. /************************************************************************/
  651. /* color index anti-alias support function */
  652. extern __GLfloat __glBuildAntiAliasIndex(__GLfloat idx,
  653. __GLfloat antiAliasPercent);
  654. /************************************************************************/
  655. /*
  656. ** Dithering implementation stuff.
  657. */
  658. #define __GL_DITHER_BITS 4
  659. #define __GL_DITHER_PRECISION (1 << __GL_DITHER_BITS)
  660. #define __GL_DITHER_INDEX(x,y) (((x) & 3) + (((y) & 3) << 2))
  661. extern GLbyte __glDitherTable[16];
  662. #endif /* __glrender_h_ */