Leaked source code of windows server 2003
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.

1274 lines
40 KiB

  1. /*
  2. ** Copyright 1991-1993, Silicon Graphics, Inc.
  3. ** All Rights Reserved.
  4. **
  5. ** This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  6. ** the contents of this file may not be disclosed to third parties, copied or
  7. ** duplicated in any form, in whole or in part, without the prior written
  8. ** permission of Silicon Graphics, Inc.
  9. **
  10. ** RESTRICTED RIGHTS LEGEND:
  11. ** Use, duplication or disclosure by the Government is subject to restrictions
  12. ** as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  13. ** and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  14. ** successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  15. ** rights reserved under the Copyright Laws of the United States.
  16. */
  17. #include "precomp.h"
  18. #pragma hdrstop
  19. #include "texture.h"
  20. /*
  21. ** Determine if the alpha color component is needed. If it's not needed
  22. ** then the renderers can avoid computing it.
  23. */
  24. GLboolean FASTCALL __glNeedAlpha(__GLcontext *gc)
  25. {
  26. if (gc->modes.colorIndexMode) {
  27. return GL_FALSE;
  28. }
  29. if (gc->state.enables.general & __GL_ALPHA_TEST_ENABLE) {
  30. return GL_TRUE;
  31. }
  32. if (gc->modes.alphaBits > 0) {
  33. return GL_TRUE;
  34. }
  35. if (gc->state.enables.general & __GL_BLEND_ENABLE) {
  36. GLint src = gc->state.raster.blendSrc;
  37. GLint dst = gc->state.raster.blendDst;
  38. /*
  39. ** See if one of the source alpha combinations are used.
  40. */
  41. if ((src == GL_SRC_ALPHA) ||
  42. (src == GL_ONE_MINUS_SRC_ALPHA) ||
  43. (src == GL_SRC_ALPHA_SATURATE) ||
  44. (dst == GL_SRC_ALPHA) ||
  45. (dst == GL_ONE_MINUS_SRC_ALPHA)) {
  46. return GL_TRUE;
  47. }
  48. }
  49. return GL_FALSE;
  50. }
  51. /************************************************************************/
  52. /* these are depth test routines for C.. */
  53. GLboolean (FASTCALL *__glCDTPixel[32])(__GLzValue, __GLzValue *) = {
  54. /* unsigned ops, no mask */
  55. __glDT_NEVER,
  56. __glDT_LESS,
  57. __glDT_EQUAL,
  58. __glDT_LEQUAL,
  59. __glDT_GREATER,
  60. __glDT_NOTEQUAL,
  61. __glDT_GEQUAL,
  62. __glDT_ALWAYS,
  63. /* unsigned ops, mask */
  64. __glDT_NEVER,
  65. __glDT_LESS_M,
  66. __glDT_EQUAL_M,
  67. __glDT_LEQUAL_M,
  68. __glDT_GREATER_M,
  69. __glDT_NOTEQUAL_M,
  70. __glDT_GEQUAL_M,
  71. __glDT_ALWAYS_M,
  72. /* unsigned ops, no mask */
  73. __glDT_NEVER,
  74. __glDT16_LESS,
  75. __glDT16_EQUAL,
  76. __glDT16_LEQUAL,
  77. __glDT16_GREATER,
  78. __glDT16_NOTEQUAL,
  79. __glDT16_GEQUAL,
  80. __glDT16_ALWAYS,
  81. /* unsigned ops, mask */
  82. __glDT_NEVER,
  83. __glDT16_LESS_M,
  84. __glDT16_EQUAL_M,
  85. __glDT16_LEQUAL_M,
  86. __glDT16_GREATER_M,
  87. __glDT16_NOTEQUAL_M,
  88. __glDT16_GEQUAL_M,
  89. __glDT16_ALWAYS_M,
  90. };
  91. #ifdef __GL_USEASMCODE
  92. void (*__glSDepthTestPixel[16])(void) = {
  93. NULL,
  94. __glDTS_LESS,
  95. __glDTS_EQUAL,
  96. __glDTS_LEQUAL,
  97. __glDTS_GREATER,
  98. __glDTS_NOTEQUAL,
  99. __glDTS_GEQUAL,
  100. __glDTS_ALWAYS,
  101. NULL,
  102. __glDTS_LESS_M,
  103. __glDTS_EQUAL_M,
  104. __glDTS_LEQUAL_M,
  105. __glDTS_GREATER_M,
  106. __glDTS_NOTEQUAL_M,
  107. __glDTS_GEQUAL_M,
  108. __glDTS_ALWAYS_M,
  109. };
  110. #endif
  111. /************************************************************************/
  112. void FASTCALL __glGenericPickPointProcs(__GLcontext *gc)
  113. {
  114. GLuint modeFlags = gc->polygon.shader.modeFlags;
  115. if (gc->renderMode == GL_FEEDBACK)
  116. {
  117. gc->procs.renderPoint = __glFeedbackPoint;
  118. return;
  119. }
  120. if (gc->renderMode == GL_SELECT)
  121. {
  122. gc->procs.renderPoint = __glSelectPoint;
  123. return;
  124. }
  125. if (gc->state.enables.general & __GL_POINT_SMOOTH_ENABLE)
  126. {
  127. if (gc->modes.colorIndexMode)
  128. {
  129. gc->procs.renderPoint = __glRenderAntiAliasedCIPoint;
  130. }
  131. else
  132. {
  133. gc->procs.renderPoint = __glRenderAntiAliasedRGBPoint;
  134. }
  135. return;
  136. }
  137. else if (gc->state.point.aliasedSize != 1)
  138. {
  139. gc->procs.renderPoint = __glRenderAliasedPointN;
  140. }
  141. else if (gc->texture.textureEnabled)
  142. {
  143. gc->procs.renderPoint = __glRenderAliasedPoint1;
  144. }
  145. else
  146. {
  147. gc->procs.renderPoint = __glRenderAliasedPoint1_NoTex;
  148. }
  149. #ifdef __BUGGY_RENDER_POINT
  150. #ifdef NT
  151. if ((modeFlags & __GL_SHADE_CHEAP_FOG) &&
  152. !(modeFlags & __GL_SHADE_SMOOTH_LIGHT))
  153. {
  154. gc->procs.renderPoint2 = gc->procs.renderPoint;
  155. gc->procs.renderPoint = __glRenderFlatFogPoint;
  156. }
  157. else if (modeFlags & __GL_SHADE_SLOW_FOG)
  158. {
  159. gc->procs.renderPoint2 = gc->procs.renderPoint;
  160. gc->procs.renderPoint = __glRenderFlatFogPointSlow;
  161. }
  162. #else
  163. // SGIBUG the slow fog path does not compute vertex->fog value!
  164. if (((modeFlags & __GL_SHADE_CHEAP_FOG) &&
  165. !(modeFlags & __GL_SHADE_SMOOTH_LIGHT)) ||
  166. (modeFlags & __GL_SHADE_SLOW_FOG)) {
  167. gc->procs.renderPoint2 = gc->procs.renderPoint;
  168. gc->procs.renderPoint = __glRenderFlatFogPoint;
  169. }
  170. #endif
  171. #endif //__BUGGY_RENDER_POINT
  172. }
  173. #ifdef __GL_USEASMCODE
  174. static void (*LDepthTestPixel[16])(void) = {
  175. NULL,
  176. __glDTP_LESS,
  177. __glDTP_EQUAL,
  178. __glDTP_LEQUAL,
  179. __glDTP_GREATER,
  180. __glDTP_NOTEQUAL,
  181. __glDTP_GEQUAL,
  182. __glDTP_ALWAYS,
  183. NULL,
  184. __glDTP_LESS_M,
  185. __glDTP_EQUAL_M,
  186. __glDTP_LEQUAL_M,
  187. __glDTP_GREATER_M,
  188. __glDTP_NOTEQUAL_M,
  189. __glDTP_GEQUAL_M,
  190. __glDTP_ALWAYS_M,
  191. };
  192. #endif
  193. void FASTCALL __glGenericPickRenderBitmapProcs(__GLcontext *gc)
  194. {
  195. gc->procs.renderBitmap = __glRenderBitmap;
  196. }
  197. void FASTCALL __glGenericPickClipProcs(__GLcontext *gc)
  198. {
  199. gc->procs.clipTriangle = __glClipTriangle;
  200. }
  201. void FASTCALL __glGenericPickTextureProcs(__GLcontext *gc)
  202. {
  203. __GLtexture *current;
  204. __GLtextureParamState *params;
  205. #ifdef NT
  206. /* Pick coordinate generation function */
  207. if ((gc->state.enables.general & __GL_TEXTURE_GEN_S_ENABLE) &&
  208. (gc->state.enables.general & __GL_TEXTURE_GEN_T_ENABLE) &&
  209. !(gc->state.enables.general & __GL_TEXTURE_GEN_R_ENABLE) &&
  210. !(gc->state.enables.general & __GL_TEXTURE_GEN_Q_ENABLE) &&
  211. (gc->state.texture.s.mode == gc->state.texture.t.mode))
  212. {
  213. /* Use a special function when both modes are enabled and identical */
  214. if (gc->state.texture.s.mode == GL_SPHERE_MAP)
  215. {
  216. gc->procs.paCalcTexture = PolyArrayCalcSphereMap;
  217. }
  218. else
  219. {
  220. __GLcoord *cs, *ct;
  221. cs = &gc->state.texture.s.eyePlaneEquation;
  222. ct = &gc->state.texture.t.eyePlaneEquation;
  223. if (cs->x == ct->x && cs->y == ct->y
  224. && cs->z == ct->z && cs->w == ct->w)
  225. {
  226. if (gc->state.texture.s.mode == GL_EYE_LINEAR)
  227. gc->procs.paCalcTexture = PolyArrayCalcEyeLinearSameST;
  228. else
  229. gc->procs.paCalcTexture = PolyArrayCalcObjectLinearSameST;
  230. }
  231. else
  232. {
  233. if (gc->state.texture.s.mode == GL_EYE_LINEAR)
  234. gc->procs.paCalcTexture = PolyArrayCalcEyeLinear;
  235. else
  236. gc->procs.paCalcTexture = PolyArrayCalcObjectLinear;
  237. }
  238. }
  239. }
  240. else
  241. {
  242. if (gc->state.enables.general & (__GL_TEXTURE_GEN_S_ENABLE |
  243. __GL_TEXTURE_GEN_T_ENABLE |
  244. __GL_TEXTURE_GEN_R_ENABLE |
  245. __GL_TEXTURE_GEN_Q_ENABLE))
  246. /* Use fast function when both are disabled */
  247. gc->procs.paCalcTexture = PolyArrayCalcMixedTexture;
  248. else
  249. gc->procs.paCalcTexture = PolyArrayCalcTexture;
  250. }
  251. #else
  252. /* Pick coordinate generation function */
  253. if ((gc->state.enables.general & __GL_TEXTURE_GEN_S_ENABLE) &&
  254. (gc->state.enables.general & __GL_TEXTURE_GEN_T_ENABLE) &&
  255. !(gc->state.enables.general & __GL_TEXTURE_GEN_R_ENABLE) &&
  256. !(gc->state.enables.general & __GL_TEXTURE_GEN_Q_ENABLE) &&
  257. (gc->state.texture.s.mode == gc->state.texture.t.mode)) {
  258. /* Use a special function when both modes are enabled and identical */
  259. switch (gc->state.texture.s.mode) {
  260. case GL_EYE_LINEAR:
  261. gc->procs.calcTexture = __glCalcEyeLinear;
  262. break;
  263. case GL_OBJECT_LINEAR:
  264. gc->procs.calcTexture = __glCalcObjectLinear;
  265. break;
  266. case GL_SPHERE_MAP:
  267. gc->procs.calcTexture = __glCalcSphereMap;
  268. break;
  269. }
  270. } else {
  271. if (!(gc->state.enables.general & __GL_TEXTURE_GEN_S_ENABLE) &&
  272. !(gc->state.enables.general & __GL_TEXTURE_GEN_T_ENABLE) &&
  273. !(gc->state.enables.general & __GL_TEXTURE_GEN_R_ENABLE) &&
  274. !(gc->state.enables.general & __GL_TEXTURE_GEN_Q_ENABLE)) {
  275. /* Use fast function when both are disabled */
  276. gc->procs.calcTexture = __glCalcTexture;
  277. } else {
  278. gc->procs.calcTexture = __glCalcMixedTexture;
  279. }
  280. }
  281. #endif // NT
  282. gc->texture.currentTexture = current = 0;
  283. if (gc->state.enables.general & __GL_TEXTURE_2D_ENABLE) {
  284. if (__glIsTextureConsistent(gc, GL_TEXTURE_2D)) {
  285. params = __glLookUpTextureParams(gc, GL_TEXTURE_2D);
  286. gc->texture.currentTexture =
  287. current = __glLookUpTexture(gc, GL_TEXTURE_2D);
  288. }
  289. } else
  290. if (gc->state.enables.general & __GL_TEXTURE_1D_ENABLE) {
  291. if (__glIsTextureConsistent(gc, GL_TEXTURE_1D)) {
  292. params = __glLookUpTextureParams(gc, GL_TEXTURE_1D);
  293. gc->texture.currentTexture =
  294. current = __glLookUpTexture(gc, GL_TEXTURE_1D);
  295. }
  296. } else {
  297. current = NULL;
  298. }
  299. #ifdef _MCD_
  300. MCD_STATE_DIRTY(gc, TEXTURE);
  301. #endif
  302. /* Pick texturing function for the current texture */
  303. if (current) {
  304. GLenum baseFormat;
  305. /* XXX most of this should be bound into the texture param code, right? */
  306. current->params = *params;
  307. /*
  308. ** Figure out if mipmapping is being used. If not, then the
  309. ** rho computations can be avoided as there is only one texture
  310. ** to choose from.
  311. */
  312. gc->procs.calcLineRho = __glComputeLineRho;
  313. gc->procs.calcPolygonRho = __glComputePolygonRho;
  314. if ((current->params.minFilter == GL_LINEAR)
  315. || (current->params.minFilter == GL_NEAREST)) {
  316. /* No mipmapping needed */
  317. if (current->params.minFilter == current->params.magFilter) {
  318. /* No rho needed as min/mag application is identical */
  319. current->textureFunc = __glFastTextureFragment;
  320. gc->procs.calcLineRho = __glNopLineRho;
  321. gc->procs.calcPolygonRho = __glNopPolygonRho;
  322. } else {
  323. current->textureFunc = __glTextureFragment;
  324. /*
  325. ** Pre-calculate min/mag switchover point. The rho calculation
  326. ** doesn't perform a square root (ever). Consequently, these
  327. ** constants are squared.
  328. */
  329. if ((current->params.magFilter == GL_LINEAR) &&
  330. ((current->params.minFilter == GL_NEAREST_MIPMAP_NEAREST) ||
  331. (current->params.minFilter == GL_LINEAR_MIPMAP_NEAREST))) {
  332. current->c = ((__GLfloat) 2.0);
  333. } else {
  334. current->c = __glOne;
  335. }
  336. }
  337. } else {
  338. current->textureFunc = __glMipMapFragment;
  339. /*
  340. ** Pre-calculate min/mag switchover point. The rho
  341. ** calculation doesn't perform a square root (ever).
  342. ** Consequently, these constants are squared.
  343. */
  344. if ((current->params.magFilter == GL_LINEAR) &&
  345. ((current->params.minFilter == GL_NEAREST_MIPMAP_NEAREST) ||
  346. (current->params.minFilter == GL_LINEAR_MIPMAP_NEAREST))) {
  347. current->c = ((__GLfloat) 2.0);
  348. } else {
  349. current->c = __glOne;
  350. }
  351. }
  352. /* Pick environment function */
  353. baseFormat = current->level[0].baseFormat;
  354. switch (gc->state.texture.env[0].mode) {
  355. case GL_MODULATE:
  356. switch (baseFormat) {
  357. case GL_LUMINANCE:
  358. current->env = __glTextureModulateL;
  359. break;
  360. case GL_LUMINANCE_ALPHA:
  361. current->env = __glTextureModulateLA;
  362. break;
  363. case GL_RGB:
  364. current->env = __glTextureModulateRGB;
  365. break;
  366. case GL_RGBA:
  367. current->env = __glTextureModulateRGBA;
  368. break;
  369. case GL_ALPHA:
  370. current->env = __glTextureModulateA;
  371. break;
  372. case GL_INTENSITY:
  373. current->env = __glTextureModulateI;
  374. break;
  375. #ifdef NT
  376. default:
  377. ASSERTOPENGL(FALSE, "Unexpected baseFormat\n");
  378. break;
  379. #endif
  380. }
  381. break;
  382. case GL_DECAL:
  383. switch (baseFormat) {
  384. case GL_LUMINANCE:
  385. current->env = __glNopGCCOLOR;
  386. break;
  387. case GL_LUMINANCE_ALPHA:
  388. current->env = __glNopGCCOLOR;
  389. break;
  390. case GL_RGB:
  391. current->env = __glTextureDecalRGB;
  392. break;
  393. case GL_RGBA:
  394. current->env = __glTextureDecalRGBA;
  395. break;
  396. case GL_ALPHA:
  397. current->env = __glNopGCCOLOR;
  398. break;
  399. case GL_INTENSITY:
  400. current->env = __glNopGCCOLOR;
  401. break;
  402. #ifdef NT
  403. default:
  404. ASSERTOPENGL(FALSE, "Unexpected baseFormat\n");
  405. break;
  406. #endif
  407. }
  408. break;
  409. case GL_BLEND:
  410. switch (baseFormat) {
  411. case GL_LUMINANCE:
  412. current->env = __glTextureBlendL;
  413. break;
  414. case GL_LUMINANCE_ALPHA:
  415. current->env = __glTextureBlendLA;
  416. break;
  417. case GL_RGB:
  418. current->env = __glTextureBlendRGB;
  419. break;
  420. case GL_RGBA:
  421. current->env = __glTextureBlendRGBA;
  422. break;
  423. case GL_ALPHA:
  424. current->env = __glTextureBlendA;
  425. break;
  426. case GL_INTENSITY:
  427. current->env = __glTextureBlendI;
  428. break;
  429. #ifdef NT
  430. default:
  431. ASSERTOPENGL(FALSE, "Unexpected baseFormat\n");
  432. break;
  433. #endif
  434. }
  435. break;
  436. case GL_REPLACE:
  437. switch (baseFormat) {
  438. case GL_LUMINANCE:
  439. current->env = __glTextureReplaceL;
  440. break;
  441. case GL_LUMINANCE_ALPHA:
  442. current->env = __glTextureReplaceLA;
  443. break;
  444. case GL_RGB:
  445. current->env = __glTextureReplaceRGB;
  446. break;
  447. case GL_RGBA:
  448. current->env = __glTextureReplaceRGBA;
  449. break;
  450. case GL_ALPHA:
  451. current->env = __glTextureReplaceA;
  452. break;
  453. case GL_INTENSITY:
  454. current->env = __glTextureReplaceI;
  455. break;
  456. #ifdef NT
  457. default:
  458. ASSERTOPENGL(FALSE, "Unexpected baseFormat\n");
  459. break;
  460. #endif
  461. }
  462. break;
  463. #ifdef NT
  464. default:
  465. ASSERTOPENGL(FALSE, "Unexpected texture mode\n");
  466. break;
  467. #endif
  468. }
  469. /* Pick mag/min functions */
  470. switch (current->dim) {
  471. case 1:
  472. current->nearest = __glNearestFilter1;
  473. current->linear = __glLinearFilter1;
  474. break;
  475. case 2:
  476. current->nearest = __glNearestFilter2;
  477. current->linear = __glLinearFilter2;
  478. // Accelerate BGR{A}8 case when wrap modes are both REPEAT
  479. if( (current->params.sWrapMode == GL_REPEAT) &&
  480. (current->params.tWrapMode == GL_REPEAT)
  481. )
  482. {
  483. __GLmipMapLevel *lp = &current->level[0];
  484. if( lp->extract == __glExtractTexelBGR8 )
  485. current->linear = __glLinearFilter2_BGR8Repeat;
  486. else if( lp->extract == __glExtractTexelBGRA8 )
  487. current->linear = __glLinearFilter2_BGRA8Repeat;
  488. }
  489. break;
  490. }
  491. /* set mag filter function */
  492. switch (current->params.magFilter) {
  493. case GL_LINEAR:
  494. current->magnify = __glLinearFilter;
  495. break;
  496. case GL_NEAREST:
  497. current->magnify = __glNearestFilter;
  498. break;
  499. }
  500. /* set min filter function */
  501. switch (current->params.minFilter) {
  502. case GL_LINEAR:
  503. current->minnify = __glLinearFilter;
  504. break;
  505. case GL_NEAREST:
  506. current->minnify = __glNearestFilter;
  507. break;
  508. case GL_NEAREST_MIPMAP_NEAREST:
  509. current->minnify = __glNMNFilter;
  510. break;
  511. case GL_LINEAR_MIPMAP_NEAREST:
  512. current->minnify = __glLMNFilter;
  513. break;
  514. case GL_NEAREST_MIPMAP_LINEAR:
  515. current->minnify = __glNMLFilter;
  516. break;
  517. case GL_LINEAR_MIPMAP_LINEAR:
  518. current->minnify = __glLMLFilter;
  519. break;
  520. }
  521. gc->procs.texture = current->textureFunc;
  522. } else {
  523. gc->procs.texture = 0;
  524. }
  525. }
  526. void FASTCALL __glGenericPickFogProcs(__GLcontext *gc)
  527. {
  528. #ifdef GL_WIN_specular_fog
  529. /*
  530. ** If specular shading is on, coerce the fog sub-system to go through
  531. ** DONT_CARE path. Disregard the GL_NICEST hint!!!
  532. */
  533. #endif //GL_WIN_specular_fog
  534. if ((gc->state.enables.general & __GL_FOG_ENABLE)
  535. #ifdef GL_WIN_specular_fog
  536. || (gc->polygon.shader.modeFlags & __GL_SHADE_SPEC_FOG)
  537. #endif //GL_WIN_specular_fog
  538. )
  539. {
  540. if ((gc->state.hints.fog == GL_NICEST)
  541. #ifdef GL_WIN_specular_fog
  542. && !(gc->polygon.shader.modeFlags & __GL_SHADE_SPEC_FOG)
  543. #endif //GL_WIN_specular_fog
  544. )
  545. {
  546. gc->procs.fogVertex = 0; /* Better not be called */
  547. }
  548. else
  549. {
  550. if (gc->state.fog.mode == GL_LINEAR)
  551. gc->procs.fogVertex = __glFogVertexLinear;
  552. else
  553. gc->procs.fogVertex = __glFogVertex;
  554. }
  555. gc->procs.fogPoint = __glFogFragmentSlow;
  556. gc->procs.fogColor = __glFogColorSlow;
  557. }
  558. else
  559. {
  560. gc->procs.fogVertex = 0;
  561. gc->procs.fogPoint = 0;
  562. gc->procs.fogColor = 0;
  563. }
  564. }
  565. void FASTCALL __glGenericPickBufferProcs(__GLcontext *gc)
  566. {
  567. GLint i;
  568. __GLbufferMachine *buffers;
  569. buffers = &gc->buffers;
  570. buffers->doubleStore = GL_FALSE;
  571. /* Set draw buffer pointer */
  572. switch (gc->state.raster.drawBuffer) {
  573. case GL_FRONT:
  574. gc->drawBuffer = gc->front;
  575. break;
  576. case GL_FRONT_AND_BACK:
  577. if (gc->modes.doubleBufferMode) {
  578. gc->drawBuffer = gc->back;
  579. buffers->doubleStore = GL_TRUE;
  580. } else {
  581. gc->drawBuffer = gc->front;
  582. }
  583. break;
  584. case GL_BACK:
  585. gc->drawBuffer = gc->back;
  586. break;
  587. case GL_AUX0:
  588. case GL_AUX1:
  589. case GL_AUX2:
  590. case GL_AUX3:
  591. i = gc->state.raster.drawBuffer - GL_AUX0;
  592. #if __GL_NUMBER_OF_AUX_BUFFERS > 0
  593. gc->drawBuffer = &gc->auxBuffer[i];
  594. #endif
  595. break;
  596. }
  597. }
  598. void FASTCALL __glGenericPickPixelProcs(__GLcontext *gc)
  599. {
  600. __GLpixelTransferMode *tm;
  601. __GLpixelMachine *pm;
  602. GLboolean mapColor;
  603. GLfloat red, green, blue, alpha;
  604. GLint entry;
  605. GLuint enables = gc->state.enables.general;
  606. __GLpixelMapHead *pmap;
  607. GLint i;
  608. /* Set read buffer pointer */
  609. switch (gc->state.pixel.readBuffer) {
  610. case GL_FRONT:
  611. gc->readBuffer = gc->front;
  612. break;
  613. case GL_BACK:
  614. gc->readBuffer = gc->back;
  615. break;
  616. case GL_AUX0:
  617. case GL_AUX1:
  618. case GL_AUX2:
  619. case GL_AUX3:
  620. i = gc->state.pixel.readBuffer - GL_AUX0;
  621. #if __GL_NUMBER_OF_AUX_BUFFERS > 0
  622. gc->readBuffer = &gc->auxBuffer[i];
  623. #endif
  624. break;
  625. }
  626. if (gc->texture.textureEnabled
  627. || (gc->polygon.shader.modeFlags & __GL_SHADE_SLOW_FOG)) {
  628. gc->procs.pxStore = __glSlowDrawPixelsStore;
  629. } else {
  630. gc->procs.pxStore = gc->procs.store;
  631. }
  632. tm = &gc->state.pixel.transferMode;
  633. pm = &(gc->pixel);
  634. mapColor = tm->mapColor;
  635. if (mapColor || gc->modes.rgbMode || tm->indexShift || tm->indexOffset) {
  636. pm->iToICurrent = GL_FALSE;
  637. pm->iToRGBACurrent = GL_FALSE;
  638. pm->modifyCI = GL_TRUE;
  639. } else {
  640. pm->modifyCI = GL_FALSE;
  641. }
  642. if (tm->mapStencil || tm->indexShift || tm->indexOffset) {
  643. pm->modifyStencil = GL_TRUE;
  644. } else {
  645. pm->modifyStencil = GL_FALSE;
  646. }
  647. if (tm->d_scale != __glOne || tm->d_bias) {
  648. pm->modifyDepth = GL_TRUE;
  649. } else {
  650. pm->modifyDepth = GL_FALSE;
  651. }
  652. if (mapColor || tm->r_bias || tm->g_bias || tm->b_bias || tm->a_bias ||
  653. tm->r_scale != __glOne || tm->g_scale != __glOne ||
  654. tm->b_scale != __glOne || tm->a_scale != __glOne) {
  655. pm->modifyRGBA = GL_TRUE;
  656. pm->rgbaCurrent = GL_FALSE;
  657. } else {
  658. pm->modifyRGBA = GL_FALSE;
  659. }
  660. if (pm->modifyRGBA) {
  661. /* Compute default values for red, green, blue, alpha */
  662. red = gc->state.pixel.transferMode.r_bias;
  663. green = gc->state.pixel.transferMode.g_bias;
  664. blue = gc->state.pixel.transferMode.b_bias;
  665. alpha = gc->state.pixel.transferMode.a_scale +
  666. gc->state.pixel.transferMode.a_bias;
  667. if (mapColor) {
  668. pmap =
  669. &gc->state.pixel.pixelMap[__GL_PIXEL_MAP_R_TO_R];
  670. entry = (GLint)(red * pmap->size);
  671. if (entry < 0) entry = 0;
  672. else if (entry > pmap->size-1) entry = pmap->size-1;
  673. red = pmap->base.mapF[entry];
  674. pmap =
  675. &gc->state.pixel.pixelMap[__GL_PIXEL_MAP_G_TO_G];
  676. entry = (GLint)(green * pmap->size);
  677. if (entry < 0) entry = 0;
  678. else if (entry > pmap->size-1) entry = pmap->size-1;
  679. green = pmap->base.mapF[entry];
  680. pmap =
  681. &gc->state.pixel.pixelMap[__GL_PIXEL_MAP_B_TO_B];
  682. entry = (GLint)(blue * pmap->size);
  683. if (entry < 0) entry = 0;
  684. else if (entry > pmap->size-1) entry = pmap->size-1;
  685. blue = pmap->base.mapF[entry];
  686. pmap =
  687. &gc->state.pixel.pixelMap[__GL_PIXEL_MAP_A_TO_A];
  688. entry = (GLint)(alpha * pmap->size);
  689. if (entry < 0) entry = 0;
  690. else if (entry > pmap->size-1) entry = pmap->size-1;
  691. alpha = pmap->base.mapF[entry];
  692. } else {
  693. if (red > __glOne) red = __glOne;
  694. else if (red < 0) red = 0;
  695. if (green > __glOne) green = __glOne;
  696. else if (green < 0) green = 0;
  697. if (blue > __glOne) blue = __glOne;
  698. else if (blue < 0) blue = 0;
  699. if (alpha > __glOne) alpha = __glOne;
  700. else if (alpha < 0) alpha = 0;
  701. }
  702. pm->red0Mod = red * gc->frontBuffer.redScale;
  703. pm->green0Mod = green * gc->frontBuffer.greenScale;
  704. pm->blue0Mod = blue * gc->frontBuffer.blueScale;
  705. pm->alpha1Mod = alpha * gc->frontBuffer.alphaScale;
  706. } else {
  707. pm->red0Mod = __glZero;
  708. pm->green0Mod = __glZero;
  709. pm->blue0Mod = __glZero;
  710. pm->alpha1Mod = gc->frontBuffer.alphaScale;
  711. }
  712. gc->procs.drawPixels = __glSlowPickDrawPixels;
  713. gc->procs.readPixels = __glSlowPickReadPixels;
  714. gc->procs.copyPixels = __glSlowPickCopyPixels;
  715. }
  716. /*
  717. ** pick the depth function pointers
  718. */
  719. int FASTCALL __glGenericPickDepthProcs(__GLcontext *gc)
  720. {
  721. GLint depthIndex;
  722. depthIndex = gc->state.depth.testFunc - GL_NEVER;
  723. if (gc->modes.depthBits && gc->modes.haveDepthBuffer) {
  724. if (gc->state.depth.writeEnable == GL_FALSE)
  725. depthIndex += 8;
  726. if (gc->depthBuffer.buf.elementSize == 2)
  727. depthIndex += 16;
  728. } else {
  729. /*
  730. ** No depthBits so force StoreALWAYS_W, _glDT_ALWAYS_M, etc.
  731. */
  732. depthIndex = (GL_ALWAYS - GL_NEVER) + 8;
  733. }
  734. (*gc->depthBuffer.pick)(gc, &gc->depthBuffer, depthIndex);
  735. gc->procs.DTPixel = __glCDTPixel[depthIndex];
  736. #ifdef __GL_USEASMCODE
  737. gc->procs.span.depthTestPixel = __glSDepthTestPixel[depthIndex];
  738. gc->procs.line.depthTestPixel = __glPDepthTestPixel[depthIndex];
  739. if( gc->procs.line.depthTestLine ) {
  740. if( __glDTLine[depthIndex] ) {
  741. *(gc->procs.line.depthTestLine) = __glDTLine[depthIndex];
  742. } else {
  743. /*
  744. ** If this happens, it may mean one of two things:
  745. ** (a) __glDTLine is malformed
  746. ** (b) A device-dependent line picker was a bit careless.
  747. ** This will probably happen if that implementation is
  748. ** not using the slow path.
  749. ** Eg: For NEWPORT, AA depth lines go through slow path,
  750. ** but non-AA depth lines have a fast path. When switching
  751. ** to a non-AA path, we may end up here, but that's ok, since
  752. ** we are not using the slow path. If that is about to happen,
  753. ** the line picker will be reinvoked.
  754. */
  755. /*
  756. ** use some generic function here that will work
  757. */
  758. *(gc->procs.line.depthTestLine) = __glDepthTestLine_asm;
  759. }
  760. }
  761. #endif
  762. return depthIndex;
  763. }
  764. void FASTCALL __glGenericValidate(__GLcontext *gc)
  765. {
  766. (*gc->procs.pickAllProcs)(gc);
  767. }
  768. void FASTCALL __glGenericPickAllProcs(__GLcontext *gc)
  769. {
  770. GLuint enables = gc->state.enables.general;
  771. GLuint modeFlags = 0;
  772. if (gc->dirtyMask & (__GL_DIRTY_TEXTURE | __GL_DIRTY_GENERIC)) {
  773. /*
  774. ** Set textureEnabled flag early on, so we can set modeFlags
  775. ** based upon it.
  776. */
  777. (*gc->procs.pickTextureProcs)(gc);
  778. gc->texture.textureEnabled = gc->modes.rgbMode
  779. && gc->texture.currentTexture;
  780. }
  781. if (gc->dirtyMask & (__GL_DIRTY_GENERIC | __GL_DIRTY_LIGHTING)) {
  782. #ifdef _MCD_
  783. MCD_STATE_DIRTY(gc, ENABLES);
  784. #endif
  785. // Check and see whether the current texturing settings will
  786. // completely replace the polygon color
  787. if (gc->texture.textureEnabled &&
  788. #ifdef GL_EXT_flat_paletted_lighting
  789. (enables & __GL_PALETTED_LIGHTING_ENABLE) == 0 &&
  790. #endif
  791. gc->state.texture.env[0].mode == GL_REPLACE &&
  792. (gc->texture.currentTexture->level[0].baseFormat == GL_RGBA ||
  793. gc->texture.currentTexture->level[0].baseFormat == GL_INTENSITY ||
  794. gc->texture.currentTexture->level[0].baseFormat ==
  795. GL_LUMINANCE_ALPHA ||
  796. ((enables & __GL_BLEND_ENABLE) == 0 &&
  797. (gc->texture.currentTexture->level[0].baseFormat ==
  798. GL_LUMINANCE ||
  799. gc->texture.currentTexture->level[0].baseFormat == GL_RGB))))
  800. {
  801. modeFlags |= __GL_SHADE_FULL_REPLACE_TEXTURE;
  802. }
  803. }
  804. /* Compute shading mode flags before triangle, span, and line picker */
  805. if (gc->modes.rgbMode) {
  806. modeFlags |= __GL_SHADE_RGB;
  807. if (gc->texture.textureEnabled) {
  808. modeFlags |= __GL_SHADE_TEXTURE;
  809. }
  810. if (enables & __GL_BLEND_ENABLE) {
  811. modeFlags |= __GL_SHADE_BLEND;
  812. }
  813. if (enables & __GL_ALPHA_TEST_ENABLE) {
  814. modeFlags |= __GL_SHADE_ALPHA_TEST;
  815. }
  816. if (enables & __GL_COLOR_LOGIC_OP_ENABLE) {
  817. modeFlags |= __GL_SHADE_LOGICOP;
  818. }
  819. if (!gc->state.raster.rMask ||
  820. !gc->state.raster.gMask ||
  821. !gc->state.raster.bMask
  822. #ifndef NT
  823. // NT doesn't support destination alpha so there's no point
  824. // in worrying about the alpha mask since we'll never write
  825. // alpha values anyway
  826. || !gc->state.raster.aMask
  827. #endif
  828. )
  829. {
  830. modeFlags |= __GL_SHADE_MASK;
  831. }
  832. } else {
  833. if (enables & __GL_INDEX_LOGIC_OP_ENABLE) {
  834. modeFlags |= __GL_SHADE_LOGICOP;
  835. }
  836. if (gc->state.raster.writeMask != __GL_MASK_INDEXI(gc, ~0)) {
  837. modeFlags |= __GL_SHADE_MASK;
  838. }
  839. }
  840. if (gc->state.light.shadingModel == GL_SMOOTH) {
  841. modeFlags |= __GL_SHADE_SMOOTH | __GL_SHADE_SMOOTH_LIGHT;
  842. #ifdef GL_WIN_phong_shading
  843. } else if (gc->state.light.shadingModel == GL_PHONG_WIN) {
  844. if (enables & __GL_LIGHTING_ENABLE)
  845. modeFlags |= __GL_SHADE_PHONG;
  846. else
  847. modeFlags |= __GL_SHADE_SMOOTH | __GL_SHADE_SMOOTH_LIGHT;
  848. #endif //GL_WIN_phong_shading
  849. }
  850. if ((enables & __GL_DEPTH_TEST_ENABLE) &&
  851. gc->modes.haveDepthBuffer) {
  852. modeFlags |= ( __GL_SHADE_DEPTH_TEST | __GL_SHADE_DEPTH_ITER );
  853. }
  854. if (enables & __GL_CULL_FACE_ENABLE) {
  855. modeFlags |= __GL_SHADE_CULL_FACE;
  856. }
  857. if (enables & __GL_DITHER_ENABLE) {
  858. modeFlags |= __GL_SHADE_DITHER;
  859. }
  860. if (enables & __GL_POLYGON_STIPPLE_ENABLE) {
  861. modeFlags |= __GL_SHADE_STIPPLE;
  862. }
  863. if (enables & __GL_LINE_STIPPLE_ENABLE) {
  864. modeFlags |= __GL_SHADE_LINE_STIPPLE;
  865. }
  866. if ((enables & __GL_STENCIL_TEST_ENABLE) &&
  867. gc->modes.haveStencilBuffer) {
  868. modeFlags |= __GL_SHADE_STENCIL_TEST;
  869. }
  870. if ((enables & __GL_LIGHTING_ENABLE) &&
  871. gc->state.light.model.twoSided) {
  872. modeFlags |= __GL_SHADE_TWOSIDED;
  873. }
  874. #ifdef GL_WIN_specular_fog
  875. /*
  876. ** Specularly lit textures using fog only if:
  877. ** -- Lighting is enabled
  878. ** -- Texturing is enabled
  879. ** -- Texturing mode is GL_MODULATE
  880. ** -- Lighting calculation is not skipped
  881. ** -- No two sided lighting
  882. */
  883. if (
  884. (gc->state.texture.env[0].mode == GL_MODULATE) &&
  885. (enables & __GL_FOG_SPEC_TEX_ENABLE) &&
  886. (enables & __GL_LIGHTING_ENABLE) &&
  887. !(modeFlags & __GL_SHADE_TWOSIDED) &&
  888. (modeFlags & __GL_SHADE_TEXTURE) &&
  889. !(
  890. (modeFlags & __GL_SHADE_FULL_REPLACE_TEXTURE) &&
  891. (gc->renderMode == GL_RENDER)
  892. )
  893. )
  894. {
  895. modeFlags |= __GL_SHADE_SPEC_FOG;
  896. modeFlags |= __GL_SHADE_INTERP_FOG;
  897. }
  898. #endif //GL_WIN_specular_fog
  899. if (enables & __GL_FOG_ENABLE)
  900. {
  901. /* Figure out type of fogging to do. Try to do cheap fog */
  902. if (!(modeFlags & __GL_SHADE_TEXTURE) &&
  903. #ifdef GL_WIN_phong_shading
  904. !(modeFlags & __GL_SHADE_PHONG) &&
  905. #endif //GL_WIN_phong_shading
  906. (gc->state.hints.fog != GL_NICEST)) {
  907. /*
  908. #ifdef NT
  909. ** Cheap fog can be done. Now figure out which kind we
  910. ** will do. If smooth shading, its easy - just update
  911. ** the color in DrawPolyArray. Otherwise, set has flag
  912. ** later on to use smooth shading to do flat shaded fogging.
  913. #else
  914. ** Cheap fog can be done. Now figure out which kind we
  915. ** will do. If smooth shading, its easy - just change
  916. ** the calcColor proc (let the color proc picker do it).
  917. ** Otherwise, set has flag later on to use smooth shading
  918. ** to do flat shaded fogging.
  919. #endif
  920. */
  921. modeFlags |= __GL_SHADE_CHEAP_FOG | __GL_SHADE_SMOOTH;
  922. } else {
  923. /* Use slowest fog mode */
  924. modeFlags |= __GL_SHADE_SLOW_FOG;
  925. if ((gc->state.hints.fog == GL_NICEST)
  926. #ifdef GL_WIN_specular_fog
  927. && (!(modeFlags & __GL_SHADE_SPEC_FOG))
  928. #endif //GL_WIN_specular_fog
  929. )
  930. {
  931. modeFlags |= __GL_SHADE_COMPUTE_FOG;
  932. }
  933. else
  934. {
  935. modeFlags |= __GL_SHADE_INTERP_FOG;
  936. }
  937. }
  938. }
  939. gc->polygon.shader.modeFlags = modeFlags;
  940. if (gc->dirtyMask & (__GL_DIRTY_GENERIC | __GL_DIRTY_LIGHTING)) {
  941. (*gc->front->pick)(gc, gc->front);
  942. if (gc->modes.doubleBufferMode) {
  943. (*gc->back->pick)(gc, gc->back);
  944. }
  945. #if __GL_NUMBER_OF_AUX_BUFFERS > 0
  946. {
  947. GLint i;
  948. for (i = 0; i < gc->modes.maxAuxBuffers; i++) {
  949. (*gc->auxBuffer[i].pick)(gc, &gc->auxBuffer[i]);
  950. }
  951. }
  952. #endif
  953. if (gc->modes.haveStencilBuffer) {
  954. (*gc->stencilBuffer.pick)(gc, &gc->stencilBuffer);
  955. }
  956. (*gc->procs.pickBufferProcs)(gc);
  957. /*
  958. ** Note: Must call gc->front->pick and gc->back->pick before calling
  959. ** pickStoreProcs. This also must be called prior to line, point,
  960. ** polygon, clipping, or bitmap pickers. The LIGHT implementation
  961. ** depends upon it.
  962. */
  963. (*gc->procs.pickStoreProcs)(gc);
  964. #ifdef NT
  965. /*
  966. ** Compute the color material change bits before lighting since
  967. ** __glValidateLighting calls ComputeMaterialState.
  968. */
  969. ComputeColorMaterialChange(gc);
  970. #endif
  971. __glValidateLighting(gc);
  972. /*
  973. ** Note: pickColorMaterialProcs is called frequently outside of this
  974. ** generic picking routine.
  975. */
  976. (*gc->procs.pickColorMaterialProcs)(gc);
  977. (*gc->procs.pickBlendProcs)(gc);
  978. (*gc->procs.pickFogProcs)(gc);
  979. (*gc->procs.pickParameterClipProcs)(gc);
  980. (*gc->procs.pickClipProcs)(gc);
  981. /*
  982. ** Needs to be done after pickStoreProcs.
  983. */
  984. (*gc->procs.pickRenderBitmapProcs)(gc);
  985. if (gc->validateMask & __GL_VALIDATE_ALPHA_FUNC) {
  986. __glValidateAlphaTest(gc);
  987. }
  988. }
  989. #ifdef NT
  990. // Compute paNeeds flags PANEEDS_TEXCOORD, PANEEDS_NORMAL,
  991. // PANEEDS_RASTERPOS_NORMAL, PANEEDS_CLIP_ONLY, and PANEEDS_SKIP_LIGHTING.
  992. if (gc->dirtyMask & (__GL_DIRTY_GENERIC | __GL_DIRTY_LIGHTING))
  993. {
  994. GLuint paNeeds;
  995. paNeeds = gc->vertex.paNeeds;
  996. paNeeds &= ~(PANEEDS_TEXCOORD | PANEEDS_NORMAL |
  997. PANEEDS_RASTERPOS_NORMAL | PANEEDS_CLIP_ONLY |
  998. PANEEDS_SKIP_LIGHTING);
  999. // Compute PANEEDS_SKIP_LIGHTING flag.
  1000. // If we're rendering with a replace mode texture which fills all
  1001. // the color components then lighting is unnecessary in most cases.
  1002. if ((modeFlags & __GL_SHADE_FULL_REPLACE_TEXTURE) &&
  1003. (gc->renderMode == GL_RENDER))
  1004. paNeeds |= PANEEDS_SKIP_LIGHTING;
  1005. // Compute PANEEDS_TEXCOORD.
  1006. // Feedback needs texture coordinates when the feedback type is
  1007. // GL_3D_COLOR_TEXTURE or GL_4D_COLOR_TEXTURE whether or not it is
  1008. // enabled.
  1009. if (gc->texture.textureEnabled || gc->renderMode == GL_FEEDBACK)
  1010. paNeeds |= PANEEDS_TEXCOORD;
  1011. // Compute PANEEDS_NORMAL.
  1012. #ifdef NEW_NORMAL_PROCESSING
  1013. if(enables & __GL_LIGHTING_ENABLE &&
  1014. !(paNeeds & PANEEDS_SKIP_LIGHTING)) // uses PANEEDS_SKIP_LIGHTING computed above
  1015. paNeeds |= PANEEDS_NORMAL;
  1016. if (
  1017. ((paNeeds & PANEEDS_TEXCOORD) // uses PANEEDS_TEXCOORD computed above!
  1018. && (enables & __GL_TEXTURE_GEN_S_ENABLE)
  1019. && (gc->state.texture.s.mode == GL_SPHERE_MAP))
  1020. ||
  1021. ((paNeeds & PANEEDS_TEXCOORD) // uses PANEEDS_TEXCOORD computed above!
  1022. && (enables & __GL_TEXTURE_GEN_T_ENABLE)
  1023. && (gc->state.texture.t.mode == GL_SPHERE_MAP))
  1024. )
  1025. paNeeds |= PANEEDS_NORMAL_FOR_TEXTURE;
  1026. #else
  1027. if
  1028. (
  1029. ((enables & __GL_LIGHTING_ENABLE)
  1030. && !(paNeeds & PANEEDS_SKIP_LIGHTING)) // uses PANEEDS_SKIP_LIGHTING computed above
  1031. ||
  1032. ((paNeeds & PANEEDS_TEXCOORD) // uses PANEEDS_TEXCOORD computed above!
  1033. && (enables & __GL_TEXTURE_GEN_S_ENABLE)
  1034. && (gc->state.texture.s.mode == GL_SPHERE_MAP))
  1035. ||
  1036. ((paNeeds & PANEEDS_TEXCOORD) // uses PANEEDS_TEXCOORD computed above!
  1037. && (enables & __GL_TEXTURE_GEN_T_ENABLE)
  1038. && (gc->state.texture.t.mode == GL_SPHERE_MAP))
  1039. )
  1040. paNeeds |= PANEEDS_NORMAL | PANEEDS_NORMAL_FOR_TEXTURE;
  1041. #endif
  1042. // Compute PANEEDS_RASTERPOS_NORMAL.
  1043. #ifdef NEW_NORMAL_PROCESSING
  1044. if (enables & __GL_LIGHTING_ENABLE)
  1045. paNeeds |= PANEEDS_RASTERPOS_NORMAL;
  1046. if ((enables & __GL_TEXTURE_GEN_S_ENABLE && gc->state.texture.s.mode == GL_SPHERE_MAP)
  1047. ||
  1048. (enables & __GL_TEXTURE_GEN_T_ENABLE && gc->state.texture.t.mode == GL_SPHERE_MAP))
  1049. paNeeds |= PANEEDS_RASTERPOS_NORMAL_FOR_TEXTURE;
  1050. #else
  1051. if
  1052. (
  1053. (enables & __GL_LIGHTING_ENABLE)
  1054. ||
  1055. ((enables & __GL_TEXTURE_GEN_S_ENABLE)
  1056. && (gc->state.texture.s.mode == GL_SPHERE_MAP))
  1057. ||
  1058. ((enables & __GL_TEXTURE_GEN_T_ENABLE)
  1059. && (gc->state.texture.t.mode == GL_SPHERE_MAP))
  1060. )
  1061. paNeeds |= PANEEDS_RASTERPOS_NORMAL;
  1062. #endif
  1063. // Compute PANEEDS_CLIP_ONLY.
  1064. // It is set in selection mode to take a fast path in DrawPolyArray.
  1065. // It must be cleared by RasterPos before calling DrawPolyArray!
  1066. if (gc->renderMode == GL_SELECT)
  1067. {
  1068. paNeeds |= PANEEDS_CLIP_ONLY;
  1069. paNeeds &= ~PANEEDS_NORMAL;
  1070. }
  1071. gc->vertex.paNeeds = paNeeds;
  1072. }
  1073. // Compute PANEEDS_EDGEFLAG flag
  1074. // __GL_DIRTY_POLYGON test is probably sufficient.
  1075. if (gc->dirtyMask & (__GL_DIRTY_GENERIC | __GL_DIRTY_POLYGON))
  1076. {
  1077. if (gc->state.polygon.frontMode != GL_FILL
  1078. || gc->state.polygon.backMode != GL_FILL)
  1079. gc->vertex.paNeeds |= PANEEDS_EDGEFLAG;
  1080. else
  1081. gc->vertex.paNeeds &= ~PANEEDS_EDGEFLAG;
  1082. }
  1083. #endif // NT
  1084. if (gc->dirtyMask & __GL_DIRTY_POLYGON_STIPPLE) {
  1085. /*
  1086. ** Usually, the polygon stipple is converted immediately after
  1087. ** it is changed. However, if the polygon stipple was changed
  1088. ** when this context was the destination of a CopyContext, then
  1089. ** the polygon stipple will be converted here.
  1090. */
  1091. (*gc->procs.convertPolygonStipple)(gc);
  1092. }
  1093. // Compute paNeeds flags PANEEDS_FRONT_COLOR and PANEEDS_BACK_COLOR
  1094. if (gc->dirtyMask & (__GL_DIRTY_GENERIC | __GL_DIRTY_POLYGON |
  1095. __GL_DIRTY_LIGHTING | __GL_DIRTY_DEPTH))
  1096. {
  1097. GLuint paNeeds;
  1098. /*
  1099. ** May be used for picking Rect() procs, need to check polygon
  1100. ** bit. Must also be called after gc->vertex.needs is set.!!!
  1101. ** Needs to be called prior to point, line, and triangle pickers.
  1102. ** Also needs to be called after the store procs picker is called.
  1103. */
  1104. (*gc->procs.pickVertexProcs)(gc);
  1105. (*gc->procs.pickSpanProcs)(gc);
  1106. (*gc->procs.pickTriangleProcs)(gc);
  1107. #ifdef NT
  1108. // Compute front and back color needs for polygons.
  1109. // Points and lines always use the front color.
  1110. // Unlit primitives always use the front color.
  1111. //
  1112. // Cull enable? Two sided? Cull face Color needs
  1113. // N N BACK FRONT
  1114. // N N FRONT FRONT
  1115. // N N FRONT_AND_BACK FRONT
  1116. // N Y BACK FRONT/BACK
  1117. // N Y FRONT FRONT/BACK
  1118. // N Y FRONT_AND_BACK FRONT/BACK
  1119. // Y N BACK FRONT
  1120. // Y N FRONT FRONT
  1121. // Y N FRONT_AND_BACK None
  1122. // Y Y BACK FRONT
  1123. // Y Y FRONT BACK
  1124. // Y Y FRONT_AND_BACK None
  1125. paNeeds = gc->vertex.paNeeds;
  1126. paNeeds &= ~(PANEEDS_FRONT_COLOR | PANEEDS_BACK_COLOR);
  1127. if (enables & __GL_LIGHTING_ENABLE)
  1128. {
  1129. if (!(enables & __GL_CULL_FACE_ENABLE))
  1130. {
  1131. if (gc->state.light.model.twoSided)
  1132. paNeeds |= PANEEDS_FRONT_COLOR | PANEEDS_BACK_COLOR;
  1133. else
  1134. paNeeds |= PANEEDS_FRONT_COLOR;
  1135. }
  1136. else
  1137. {
  1138. if (!(gc->state.polygon.cull == GL_FRONT_AND_BACK))
  1139. {
  1140. if (gc->state.polygon.cull == GL_FRONT
  1141. && gc->state.light.model.twoSided)
  1142. paNeeds |= PANEEDS_BACK_COLOR;
  1143. else
  1144. paNeeds |= PANEEDS_FRONT_COLOR;
  1145. }
  1146. }
  1147. }
  1148. else
  1149. paNeeds |= PANEEDS_FRONT_COLOR;
  1150. gc->vertex.paNeeds = paNeeds;
  1151. #endif
  1152. }
  1153. if (gc->dirtyMask & (__GL_DIRTY_GENERIC | __GL_DIRTY_POINT |
  1154. __GL_DIRTY_LIGHTING | __GL_DIRTY_DEPTH)) {
  1155. (*gc->procs.pickPointProcs)(gc);
  1156. }
  1157. if (gc->dirtyMask & (__GL_DIRTY_GENERIC | __GL_DIRTY_LINE |
  1158. __GL_DIRTY_LIGHTING | __GL_DIRTY_DEPTH)) {
  1159. (*gc->procs.pickLineProcs)(gc);
  1160. }
  1161. if (gc->dirtyMask & (__GL_DIRTY_GENERIC | __GL_DIRTY_PIXEL |
  1162. __GL_DIRTY_LIGHTING | __GL_DIRTY_DEPTH)) {
  1163. (*gc->procs.pickPixelProcs)(gc);
  1164. }
  1165. /*
  1166. ** deal with the depth function pointers last. This has to be done last.
  1167. */
  1168. if (gc->dirtyMask & (__GL_DIRTY_GENERIC | __GL_DIRTY_DEPTH)) {
  1169. (*gc->procs.pickDepthProcs)(gc);
  1170. }
  1171. gc->validateMask = 0;
  1172. gc->dirtyMask = 0;
  1173. }