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.

2238 lines
75 KiB

  1. /*
  2. ** Copyright 1991, 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. ** Transformation procedures.
  18. **
  19. ** $Revision: 1.38 $
  20. ** $Date: 1993/11/29 20:34:48 $
  21. */
  22. #include "precomp.h"
  23. #pragma hdrstop
  24. #define __glGenericPickIdentityMatrixProcs(gc, m) \
  25. { \
  26. (m)->xf1 = __glXForm1_2DNRW; \
  27. (m)->xf2 = __glXForm2_2DNRW; \
  28. (m)->xf3 = __glXForm3_2DNRW; \
  29. (m)->xf4 = __glXForm4_2DNRW; \
  30. (m)->xfNorm = __glXForm3_2DNRW; \
  31. (m)->xf1Batch = __glXForm1_2DNRWBatch; \
  32. (m)->xf2Batch = __glXForm2_2DNRWBatch; \
  33. (m)->xf3Batch = __glXForm3_2DNRWBatch; \
  34. (m)->xf4Batch = __glXForm4_2DNRWBatch; \
  35. (m)->xfNormBatch = __glXForm3_2DNRWBatchNormal; \
  36. (m)->xfNormBatchN = __glXForm3_2DNRWBatchNormalN; \
  37. }
  38. void FASTCALL __glScaleMatrix(__GLcontext *gc, __GLmatrix *m, void *data);
  39. void FASTCALL __glTranslateMatrix(__GLcontext *gc, __GLmatrix *m, void *data);
  40. void FASTCALL __glMultiplyMatrix(__GLcontext *gc, __GLmatrix *m, void *data);
  41. // Bit flags that identify matrix entries that contain 0 or 1.
  42. #define _M00_0 0x00000001
  43. #define _M01_0 0x00000002
  44. #define _M02_0 0x00000004
  45. #define _M03_0 0x00000008
  46. #define _M10_0 0x00000010
  47. #define _M11_0 0x00000020
  48. #define _M12_0 0x00000040
  49. #define _M13_0 0x00000080
  50. #define _M20_0 0x00000100
  51. #define _M21_0 0x00000200
  52. #define _M22_0 0x00000400
  53. #define _M23_0 0x00000800
  54. #define _M30_0 0x00001000
  55. #define _M31_0 0x00002000
  56. #define _M32_0 0x00004000
  57. #define _M33_0 0x00008000
  58. #define _M00_1 0x00010000
  59. #define _M01_1 0x00020000
  60. #define _M02_1 0x00040000
  61. #define _M03_1 0x00080000
  62. #define _M10_1 0x00100000
  63. #define _M11_1 0x00200000
  64. #define _M12_1 0x00400000
  65. #define _M13_1 0x00800000
  66. #define _M20_1 0x01000000
  67. #define _M21_1 0x02000000
  68. #define _M22_1 0x04000000
  69. #define _M23_1 0x08000000
  70. #define _M30_1 0x10000000
  71. #define _M31_1 0x20000000
  72. #define _M32_1 0x40000000
  73. #define _M33_1 0x80000000
  74. // Pre-defined matrix types.
  75. #define _MT_IDENTITY \
  76. (_M00_1 | _M01_0 | _M02_0 | _M03_0 | \
  77. _M10_0 | _M11_1 | _M12_0 | _M13_0 | \
  78. _M20_0 | _M21_0 | _M22_1 | _M23_0 | \
  79. _M30_0 | _M31_0 | _M32_0 | _M33_1)
  80. #define _MT_IS2DNR \
  81. ( _M01_0 | _M02_0 | _M03_0 | \
  82. _M10_0 | _M12_0 | _M13_0 | \
  83. _M20_0 | _M21_0 | _M23_0 | \
  84. _M33_1)
  85. #define _MT_IS2D \
  86. ( _M02_0 | _M03_0 | \
  87. _M12_0 | _M13_0 | \
  88. _M20_0 | _M21_0 | _M23_0 | \
  89. _M33_1)
  90. #define _MT_W0001 \
  91. ( _M03_0 | \
  92. _M13_0 | \
  93. _M23_0 | \
  94. _M33_1)
  95. #define GET_MATRIX_MASK(m,i,j) \
  96. if ((m)->matrix[i][j] == zer) rowMask |= _M##i##j##_0; \
  97. else if ((m)->matrix[i][j] == one) rowMask |= _M##i##j##_1;
  98. // Note: If you are adding a new type, make sure all functions
  99. // using matrixType are correct! (__glScaleMatrix, __glTranslateMatrix,
  100. // __glInvertTransposeMatrix, and __glGenericPickVertexProcs)
  101. void FASTCALL __glUpdateMatrixType(__GLmatrix *m)
  102. {
  103. register __GLfloat zer = __glZero;
  104. register __GLfloat one = __glOne;
  105. DWORD rowMask = 0; // identifies 0 and 1 entries
  106. GET_MATRIX_MASK(m,0,0);
  107. GET_MATRIX_MASK(m,0,1);
  108. GET_MATRIX_MASK(m,0,2);
  109. GET_MATRIX_MASK(m,0,3);
  110. GET_MATRIX_MASK(m,1,0);
  111. GET_MATRIX_MASK(m,1,1);
  112. GET_MATRIX_MASK(m,1,2);
  113. GET_MATRIX_MASK(m,1,3);
  114. GET_MATRIX_MASK(m,2,0);
  115. GET_MATRIX_MASK(m,2,1);
  116. GET_MATRIX_MASK(m,2,2);
  117. GET_MATRIX_MASK(m,2,3);
  118. GET_MATRIX_MASK(m,3,0);
  119. GET_MATRIX_MASK(m,3,1);
  120. GET_MATRIX_MASK(m,3,2);
  121. GET_MATRIX_MASK(m,3,3);
  122. // Some common cases.
  123. // Order of finding matrix type is important!
  124. if ((rowMask & _MT_IDENTITY) == _MT_IDENTITY)
  125. m->matrixType = __GL_MT_IDENTITY;
  126. else if ((rowMask & _MT_IS2DNR) == _MT_IS2DNR)
  127. m->matrixType = __GL_MT_IS2DNR;
  128. else if ((rowMask & _MT_IS2D) == _MT_IS2D)
  129. m->matrixType = __GL_MT_IS2D;
  130. else if ((rowMask & _MT_W0001) == _MT_W0001)
  131. m->matrixType = __GL_MT_W0001;
  132. else
  133. m->matrixType = __GL_MT_GENERAL;
  134. }
  135. static void SetDepthRange(__GLcontext *gc, double zNear, double zFar)
  136. {
  137. __GLviewport *vp = &gc->state.viewport;
  138. double scale, zero = __glZero, one = __glOne;
  139. /* Clamp depth range to legal values */
  140. if (zNear < zero) zNear = zero;
  141. if (zNear > one) zNear = one;
  142. if (zFar < zero) zFar = zero;
  143. if (zFar > one) zFar = one;
  144. vp->zNear = zNear;
  145. vp->zFar = zFar;
  146. /* Compute viewport values for the new depth range */
  147. if (((__GLGENcontext *)gc)->pMcdState)
  148. scale = GENACCEL(gc).zDevScale * __glHalf;
  149. else
  150. scale = gc->depthBuffer.scale * __glHalf;
  151. gc->state.viewport.zScale = (zFar - zNear) * scale;
  152. gc->state.viewport.zCenter = (zFar + zNear) * scale;
  153. #ifdef _MCD_
  154. MCD_STATE_DIRTY(gc, VIEWPORT);
  155. #endif
  156. }
  157. void FASTCALL __glInitTransformState(__GLcontext *gc)
  158. {
  159. GLint i, numClipPlanes, numClipTemp;
  160. __GLtransform *tr;
  161. __GLtransformP *ptr;
  162. __GLtransformT *ttr;
  163. __GLvertex *vx;
  164. /* Allocate memory for clip planes */
  165. numClipPlanes = gc->constants.numberOfClipPlanes;
  166. numClipTemp = (numClipPlanes + 6) * 2;
  167. gc->state.transform.eyeClipPlanes = (__GLcoord *)
  168. GCALLOCZ(gc, 2 * numClipPlanes * sizeof(__GLcoord));
  169. #ifdef NT
  170. if (NULL == gc->state.transform.eyeClipPlanes)
  171. return;
  172. #endif
  173. gc->state.transform.eyeClipPlanesSet =
  174. gc->state.transform.eyeClipPlanes + numClipPlanes;
  175. /* Allocate memory for matrix stacks */
  176. gc->transform.modelViewStack = (__GLtransform*)
  177. GCALLOCZ(gc, __GL_WGL_MAX_MODELVIEW_STACK_DEPTH*sizeof(__GLtransform));
  178. #ifdef NT
  179. if (NULL == gc->transform.modelViewStack)
  180. return;
  181. #endif
  182. gc->transform.projectionStack = (__GLtransformP*)
  183. GCALLOCZ(gc, __GL_WGL_MAX_PROJECTION_STACK_DEPTH*
  184. sizeof(__GLtransformP));
  185. #ifdef NT
  186. if (NULL == gc->transform.projectionStack)
  187. return;
  188. #endif
  189. gc->transform.textureStack = (__GLtransformT*)
  190. GCALLOCZ(gc, __GL_WGL_MAX_TEXTURE_STACK_DEPTH*
  191. sizeof(__GLtransformT));
  192. #ifdef NT
  193. if (NULL == gc->transform.textureStack)
  194. return;
  195. #endif
  196. /* Allocate memory for clipping temporaries */
  197. gc->transform.clipTemp = (__GLvertex*)
  198. GCALLOCZ(gc, numClipTemp * sizeof(__GLvertex));
  199. #ifdef NT
  200. if (NULL == gc->transform.clipTemp)
  201. return;
  202. #endif
  203. gc->state.transform.matrixMode = GL_MODELVIEW;
  204. SetDepthRange(gc, __glZero, __glOne);
  205. gc->transform.modelView = tr = &gc->transform.modelViewStack[0];
  206. __glMakeIdentity(&tr->matrix);
  207. __glGenericPickIdentityMatrixProcs(gc, &tr->matrix);
  208. __glMakeIdentity(&tr->inverseTranspose);
  209. __glGenericPickIdentityMatrixProcs(gc, &tr->inverseTranspose);
  210. tr->flags = XFORM_CHANGED;
  211. __glMakeIdentity(&tr->mvp);
  212. gc->transform.projection = ptr = &gc->transform.projectionStack[0];
  213. __glMakeIdentity((__GLmatrix *) &ptr->matrix);
  214. __glGenericPickMvpMatrixProcs(gc, &tr->mvp);
  215. gc->transform.texture = ttr = &gc->transform.textureStack[0];
  216. __glMakeIdentity(&ttr->matrix);
  217. __glGenericPickIdentityMatrixProcs(gc, &ttr->matrix);
  218. vx = &gc->transform.clipTemp[0];
  219. for (i = 0; i < numClipTemp; i++, vx++) {/*XXX*/
  220. vx->color = &vx->colors[__GL_FRONTFACE];
  221. }
  222. gc->state.current.normal.z = __glOne;
  223. }
  224. /************************************************************************/
  225. void APIPRIVATE __glim_MatrixMode(GLenum mode)
  226. {
  227. __GL_SETUP_NOT_IN_BEGIN();
  228. switch (mode) {
  229. case GL_MODELVIEW:
  230. case GL_PROJECTION:
  231. case GL_TEXTURE:
  232. break;
  233. default:
  234. __glSetError(GL_INVALID_ENUM);
  235. return;
  236. }
  237. gc->state.transform.matrixMode = mode;
  238. }
  239. void APIPRIVATE __glim_LoadIdentity(void)
  240. {
  241. __GL_SETUP_NOT_IN_BEGIN();
  242. __glDoLoadMatrix(gc, NULL, TRUE);
  243. }
  244. void APIPRIVATE __glim_LoadMatrixf(const GLfloat m[16])
  245. {
  246. __GL_SETUP_NOT_IN_BEGIN();
  247. __glDoLoadMatrix(gc, (__GLfloat (*)[4])m, FALSE);
  248. }
  249. void APIPRIVATE __glim_MultMatrixf(const GLfloat m[16])
  250. {
  251. __GL_SETUP_NOT_IN_BEGIN();
  252. __glDoMultMatrix(gc, (void *) m, __glMultiplyMatrix);
  253. }
  254. void APIPRIVATE __glim_Rotatef(GLfloat angle, GLfloat ax, GLfloat ay, GLfloat az)
  255. {
  256. __GLmatrix m;
  257. __GLfloat radians, sine, cosine, ab, bc, ca, t;
  258. __GLfloat av[4], axis[4];
  259. __GL_SETUP_NOT_IN_BEGIN();
  260. av[0] = ax;
  261. av[1] = ay;
  262. av[2] = az;
  263. av[3] = 0;
  264. __glNormalize(axis, av);
  265. radians = angle * __glDegreesToRadians;
  266. sine = __GL_SINF(radians);
  267. cosine = __GL_COSF(radians);
  268. ab = axis[0] * axis[1] * (1 - cosine);
  269. bc = axis[1] * axis[2] * (1 - cosine);
  270. ca = axis[2] * axis[0] * (1 - cosine);
  271. #ifdef NT
  272. m.matrix[0][3] = __glZero;
  273. m.matrix[1][3] = __glZero;
  274. m.matrix[2][3] = __glZero;
  275. m.matrix[3][0] = __glZero;
  276. m.matrix[3][1] = __glZero;
  277. m.matrix[3][2] = __glZero;
  278. m.matrix[3][3] = __glOne;
  279. #else
  280. __glMakeIdentity(&m);
  281. #endif // NT
  282. t = axis[0] * axis[0];
  283. m.matrix[0][0] = t + cosine * (1 - t);
  284. m.matrix[2][1] = bc - axis[0] * sine;
  285. m.matrix[1][2] = bc + axis[0] * sine;
  286. t = axis[1] * axis[1];
  287. m.matrix[1][1] = t + cosine * (1 - t);
  288. m.matrix[2][0] = ca + axis[1] * sine;
  289. m.matrix[0][2] = ca - axis[1] * sine;
  290. t = axis[2] * axis[2];
  291. m.matrix[2][2] = t + cosine * (1 - t);
  292. m.matrix[1][0] = ab - axis[2] * sine;
  293. m.matrix[0][1] = ab + axis[2] * sine;
  294. __glDoMultMatrix(gc, &m, __glMultiplyMatrix);
  295. }
  296. struct __glScaleRec {
  297. __GLfloat x,y,z;
  298. };
  299. void APIPRIVATE __glim_Scalef(GLfloat x, GLfloat y, GLfloat z)
  300. {
  301. struct __glScaleRec scale;
  302. __GL_SETUP_NOT_IN_BEGIN();
  303. scale.x = x;
  304. scale.y = y;
  305. scale.z = z;
  306. __glDoMultMatrix(gc, &scale, __glScaleMatrix);
  307. }
  308. struct __glTranslationRec {
  309. __GLfloat x,y,z;
  310. };
  311. void APIPRIVATE __glim_Translatef(GLfloat x, GLfloat y, GLfloat z)
  312. {
  313. struct __glTranslationRec trans;
  314. __GL_SETUP_NOT_IN_BEGIN();
  315. trans.x = x;
  316. trans.y = y;
  317. trans.z = z;
  318. __glDoMultMatrix(gc, &trans, __glTranslateMatrix);
  319. }
  320. void APIPRIVATE __glim_PushMatrix(void)
  321. {
  322. #ifdef NT
  323. __GL_SETUP_NOT_IN_BEGIN(); // no need to validate
  324. switch (gc->state.transform.matrixMode)
  325. {
  326. case GL_MODELVIEW:
  327. __glPushModelViewMatrix(gc);
  328. break;
  329. case GL_PROJECTION:
  330. __glPushProjectionMatrix(gc);
  331. break;
  332. case GL_TEXTURE:
  333. __glPushTextureMatrix(gc);
  334. break;
  335. }
  336. #else
  337. __GL_SETUP_NOT_IN_BEGIN_VALIDATE();
  338. (*gc->procs.pushMatrix)(gc);
  339. #endif
  340. }
  341. void APIPRIVATE __glim_PopMatrix(void)
  342. {
  343. #ifdef NT
  344. __GL_SETUP_NOT_IN_BEGIN(); // no need to validate
  345. switch (gc->state.transform.matrixMode)
  346. {
  347. case GL_MODELVIEW:
  348. __glPopModelViewMatrix(gc);
  349. break;
  350. case GL_PROJECTION:
  351. __glPopProjectionMatrix(gc);
  352. break;
  353. case GL_TEXTURE:
  354. __glPopTextureMatrix(gc);
  355. break;
  356. }
  357. #else
  358. __GL_SETUP_NOT_IN_BEGIN_VALIDATE();
  359. (*gc->procs.popMatrix)(gc);
  360. #endif
  361. }
  362. void APIPRIVATE __glim_Frustum(GLdouble left, GLdouble right,
  363. GLdouble bottom, GLdouble top,
  364. GLdouble zNear, GLdouble zFar)
  365. {
  366. __GLmatrix m;
  367. __GLfloat deltaX, deltaY, deltaZ;
  368. __GL_SETUP_NOT_IN_BEGIN();
  369. deltaX = right - left;
  370. deltaY = top - bottom;
  371. deltaZ = zFar - zNear;
  372. if ((zNear <= (GLdouble) __glZero) || (zFar <= (GLdouble) __glZero) || (deltaX == __glZero) ||
  373. (deltaY == __glZero) || (deltaZ == __glZero)) {
  374. __glSetError(GL_INVALID_VALUE);
  375. return;
  376. }
  377. #ifdef NT
  378. m.matrix[0][1] = __glZero;
  379. m.matrix[0][2] = __glZero;
  380. m.matrix[0][3] = __glZero;
  381. m.matrix[1][0] = __glZero;
  382. m.matrix[1][2] = __glZero;
  383. m.matrix[1][3] = __glZero;
  384. m.matrix[3][0] = __glZero;
  385. m.matrix[3][1] = __glZero;
  386. #else
  387. __glMakeIdentity(&m);
  388. #endif
  389. m.matrix[0][0] = zNear * __glDoubleTwo / deltaX;
  390. m.matrix[1][1] = zNear * __glDoubleTwo / deltaY;
  391. m.matrix[2][0] = (right + left) / deltaX;
  392. m.matrix[2][1] = (top + bottom) / deltaY;
  393. m.matrix[2][2] = -(zFar + zNear) / deltaZ;
  394. m.matrix[2][3] = __glMinusOne;
  395. m.matrix[3][2] = __glDoubleMinusTwo * zNear * zFar / deltaZ;
  396. m.matrix[3][3] = __glZero;
  397. __glDoMultMatrix(gc, &m, __glMultiplyMatrix);
  398. }
  399. void APIPRIVATE __glim_Ortho(GLdouble left, GLdouble right, GLdouble bottom,
  400. GLdouble top, GLdouble zNear, GLdouble zFar)
  401. {
  402. __GLmatrix m;
  403. GLdouble deltax, deltay, deltaz;
  404. __GL_SETUP_NOT_IN_BEGIN();
  405. deltax = right - left;
  406. deltay = top - bottom;
  407. deltaz = zFar - zNear;
  408. if ((deltax == (GLdouble) __glZero) || (deltay == (GLdouble) __glZero) || (deltaz == (GLdouble) __glZero)) {
  409. __glSetError(GL_INVALID_VALUE);
  410. return;
  411. }
  412. #ifdef NT
  413. m.matrix[0][1] = __glZero;
  414. m.matrix[0][2] = __glZero;
  415. m.matrix[0][3] = __glZero;
  416. m.matrix[1][0] = __glZero;
  417. m.matrix[1][2] = __glZero;
  418. m.matrix[1][3] = __glZero;
  419. m.matrix[2][0] = __glZero;
  420. m.matrix[2][1] = __glZero;
  421. m.matrix[2][3] = __glZero;
  422. m.matrix[3][3] = __glOne;
  423. #else
  424. __glMakeIdentity(&m);
  425. #endif
  426. m.matrix[0][0] = __glDoubleTwo / deltax;
  427. m.matrix[3][0] = -(right + left) / deltax;
  428. m.matrix[1][1] = __glDoubleTwo / deltay;
  429. m.matrix[3][1] = -(top + bottom) / deltay;
  430. m.matrix[2][2] = __glDoubleMinusTwo / deltaz;
  431. m.matrix[3][2] = -(zFar + zNear) / deltaz;
  432. __glDoMultMatrix(gc, &m, __glMultiplyMatrix);
  433. }
  434. void FASTCALL __glUpdateViewport(__GLcontext *gc)
  435. {
  436. __GLfloat ww, hh, w2, h2;
  437. /* Compute operational viewport values */
  438. w2 = gc->state.viewport.width * __glHalf;
  439. h2 = gc->state.viewport.height * __glHalf;
  440. ww = w2 - gc->constants.viewportEpsilon;
  441. hh = h2 - gc->constants.viewportEpsilon;
  442. gc->state.viewport.xScale = ww;
  443. gc->state.viewport.xCenter = gc->state.viewport.x + w2 +
  444. gc->constants.fviewportXAdjust;
  445. if (gc->constants.yInverted) {
  446. gc->state.viewport.yScale = -hh;
  447. gc->state.viewport.yCenter =
  448. gc->constants.height - (gc->state.viewport.y + h2) +
  449. gc->constants.fviewportYAdjust;
  450. #if 0
  451. DbgPrint("UV ys %.3lf, yc %.3lf (%.3lf)\n",
  452. -hh, gc->state.viewport.yCenter,
  453. gc->constants.height - (gc->state.viewport.y + h2));
  454. #endif
  455. } else {
  456. gc->state.viewport.yScale = hh;
  457. gc->state.viewport.yCenter = gc->state.viewport.y + h2 +
  458. gc->constants.fviewportYAdjust;
  459. }
  460. }
  461. void FASTCALL __glUpdateViewportDependents(__GLcontext *gc)
  462. {
  463. /*
  464. ** Now that the implementation may have found us a new window size,
  465. ** we compute these offsets...
  466. */
  467. gc->transform.minx = gc->state.viewport.x + gc->constants.viewportXAdjust;
  468. gc->transform.maxx = gc->transform.minx + gc->state.viewport.width;
  469. gc->transform.fminx = gc->transform.minx;
  470. gc->transform.fmaxx = gc->transform.maxx;
  471. gc->transform.miny =
  472. (gc->constants.height -
  473. (gc->state.viewport.y + gc->state.viewport.height)) +
  474. gc->constants.viewportYAdjust;
  475. gc->transform.maxy = gc->transform.miny + gc->state.viewport.height;
  476. gc->transform.fminy = gc->transform.miny;
  477. gc->transform.fmaxy = gc->transform.maxy;
  478. }
  479. void APIPRIVATE __glim_Viewport(GLint x, GLint y, GLsizei w, GLsizei h)
  480. {
  481. __GLfloat ww, hh;
  482. __GL_SETUP_NOT_IN_BEGIN();
  483. if ((w < 0) || (h < 0)) {
  484. __glSetError(GL_INVALID_VALUE);
  485. return;
  486. }
  487. if ((gc->state.viewport.x == x) && (gc->state.viewport.y == y) &&
  488. (gc->state.viewport.width == w) && (gc->state.viewport.height == h))
  489. return;
  490. if (h > gc->constants.maxViewportHeight) {
  491. h = gc->constants.maxViewportHeight;
  492. }
  493. if (w > gc->constants.maxViewportWidth) {
  494. w = gc->constants.maxViewportWidth;
  495. }
  496. gc->state.viewport.x = x;
  497. gc->state.viewport.y = y;
  498. gc->state.viewport.width = w;
  499. gc->state.viewport.height = h;
  500. __glUpdateViewport(gc);
  501. (*gc->procs.applyViewport)(gc);
  502. __glUpdateViewportDependents(gc);
  503. /*
  504. ** Pickers that notice when the transformation matches the viewport
  505. ** exactly need to be revalidated. Ugh.
  506. */
  507. __GL_DELAY_VALIDATE(gc);
  508. }
  509. void APIPRIVATE __glim_DepthRange(GLdouble zNear, GLdouble zFar)
  510. {
  511. __GL_SETUP_NOT_IN_BEGIN();
  512. SetDepthRange(gc, zNear, zFar);
  513. __GL_DELAY_VALIDATE_MASK(gc, __GL_DIRTY_DEPTH);
  514. }
  515. void APIPRIVATE __glim_Scissor(GLint x, GLint y, GLsizei w, GLsizei h)
  516. {
  517. __GL_SETUP_NOT_IN_BEGIN();
  518. if ((w < 0) || (h < 0)) {
  519. __glSetError(GL_INVALID_VALUE);
  520. return;
  521. }
  522. gc->state.scissor.scissorX = x;
  523. gc->state.scissor.scissorY = y;
  524. gc->state.scissor.scissorWidth = w;
  525. gc->state.scissor.scissorHeight = h;
  526. #ifdef NT
  527. #ifdef _MCD_
  528. MCD_STATE_DIRTY(gc, SCISSOR);
  529. #endif
  530. // applyViewport does both
  531. (*gc->procs.applyViewport)(gc);
  532. #else
  533. (*gc->procs.applyScissor)(gc);
  534. (*gc->procs.computeClipBox)(gc);
  535. #endif
  536. }
  537. void APIPRIVATE __glim_ClipPlane(GLenum pi, const GLdouble pv[])
  538. {
  539. __GLtransform *tr;
  540. __GL_SETUP_NOT_IN_BEGIN();
  541. pi -= GL_CLIP_PLANE0;
  542. #ifdef NT
  543. // pi is unsigned!
  544. if (pi >= (GLenum) gc->constants.numberOfClipPlanes) {
  545. #else
  546. if ((pi < 0) || (pi >= gc->constants.numberOfClipPlanes)) {
  547. #endif // NT
  548. __glSetError(GL_INVALID_ENUM);
  549. return;
  550. }
  551. gc->state.transform.eyeClipPlanesSet[pi].x = pv[0];
  552. gc->state.transform.eyeClipPlanesSet[pi].y = pv[1];
  553. gc->state.transform.eyeClipPlanesSet[pi].z = pv[2];
  554. gc->state.transform.eyeClipPlanesSet[pi].w = pv[3];
  555. /*
  556. ** Project user clip plane into eye space.
  557. */
  558. tr = gc->transform.modelView;
  559. if (tr->flags & XFORM_UPDATE_INVERSE) {
  560. __glComputeInverseTranspose(gc, tr);
  561. }
  562. (*tr->inverseTranspose.xf4)(&gc->state.transform.eyeClipPlanes[pi],
  563. &gc->state.transform.eyeClipPlanesSet[pi].x,
  564. &tr->inverseTranspose);
  565. __GL_DELAY_VALIDATE(gc);
  566. #ifdef _MCD_
  567. MCD_STATE_DIRTY(gc, CLIPCTRL);
  568. #endif
  569. }
  570. /************************************************************************/
  571. void FASTCALL __glPushModelViewMatrix(__GLcontext *gc)
  572. {
  573. __GLtransform **trp, *tr, *stack;
  574. trp = &gc->transform.modelView;
  575. stack = gc->transform.modelViewStack;
  576. tr = *trp;
  577. if (tr < &stack[__GL_WGL_MAX_MODELVIEW_STACK_DEPTH-1]) {
  578. tr[1] = tr[0];
  579. *trp = tr + 1;
  580. } else {
  581. __glSetError(GL_STACK_OVERFLOW);
  582. }
  583. }
  584. void FASTCALL __glPopModelViewMatrix(__GLcontext *gc)
  585. {
  586. __GLtransform **trp, *tr, *stack, *mvtr;
  587. __GLtransformP *ptr;
  588. trp = &gc->transform.modelView;
  589. stack = gc->transform.modelViewStack;
  590. tr = *trp;
  591. if (tr > &stack[0]) {
  592. *trp = tr - 1;
  593. /*
  594. ** See if sequence number of modelView matrix is the same as the
  595. ** sequence number of the projection matrix. If not, then
  596. ** recompute the mvp matrix.
  597. */
  598. mvtr = gc->transform.modelView;
  599. ptr = gc->transform.projection;
  600. if (mvtr->sequence != ptr->sequence) {
  601. mvtr->sequence = ptr->sequence;
  602. __glMultMatrix(&mvtr->mvp, &mvtr->matrix, (__GLmatrix *) &ptr->matrix);
  603. __glUpdateMatrixType(&mvtr->mvp);
  604. }
  605. __glGenericPickMvpMatrixProcs(gc, &mvtr->mvp);
  606. } else {
  607. __glSetError(GL_STACK_UNDERFLOW);
  608. return;
  609. }
  610. }
  611. void FASTCALL __glComputeInverseTranspose(__GLcontext *gc, __GLtransform *tr)
  612. {
  613. __GLmatrix inv;
  614. __glInvertTransposeMatrix(&tr->inverseTranspose, &tr->matrix);
  615. __glUpdateMatrixType(&tr->inverseTranspose);
  616. __glGenericPickMatrixProcs(gc, &tr->inverseTranspose);
  617. tr->flags &= ~XFORM_UPDATE_INVERSE;
  618. }
  619. /************************************************************************/
  620. void FASTCALL __glPushProjectionMatrix(__GLcontext *gc)
  621. {
  622. __GLtransformP **trp, *tr, *stack;
  623. trp = &gc->transform.projection;
  624. stack = gc->transform.projectionStack;
  625. tr = *trp;
  626. if (tr < &stack[__GL_WGL_MAX_PROJECTION_STACK_DEPTH-1]) {
  627. tr[1] = tr[0];
  628. *trp = tr + 1;
  629. } else {
  630. __glSetError(GL_STACK_OVERFLOW);
  631. }
  632. }
  633. void FASTCALL __glPopProjectionMatrix(__GLcontext *gc)
  634. {
  635. __GLtransform *mvtr;
  636. __GLtransformP **trp, *tr, *stack, *ptr;
  637. trp = &gc->transform.projection;
  638. stack = gc->transform.projectionStack;
  639. tr = *trp;
  640. if (tr > &stack[0]) {
  641. *trp = tr - 1;
  642. /*
  643. ** See if sequence number of modelView matrix is the same as the
  644. ** sequence number of the projection matrix. If not, then
  645. ** recompute the mvp matrix.
  646. */
  647. mvtr = gc->transform.modelView;
  648. ptr = gc->transform.projection;
  649. if (mvtr->sequence != ptr->sequence) {
  650. mvtr->sequence = ptr->sequence;
  651. __glMultMatrix(&mvtr->mvp, &mvtr->matrix, (__GLmatrix *) &ptr->matrix);
  652. __glUpdateMatrixType(&mvtr->mvp);
  653. }
  654. __glGenericPickMvpMatrixProcs(gc, &mvtr->mvp);
  655. } else {
  656. __glSetError(GL_STACK_UNDERFLOW);
  657. return;
  658. }
  659. }
  660. /************************************************************************/
  661. void FASTCALL __glPushTextureMatrix(__GLcontext *gc)
  662. {
  663. __GLtransformT **trp, *tr, *stack;
  664. trp = &gc->transform.texture;
  665. stack = gc->transform.textureStack;
  666. tr = *trp;
  667. if (tr < &stack[__GL_WGL_MAX_TEXTURE_STACK_DEPTH-1]) {
  668. tr[1] = tr[0];
  669. *trp = tr + 1;
  670. } else {
  671. __glSetError(GL_STACK_OVERFLOW);
  672. }
  673. }
  674. void FASTCALL __glPopTextureMatrix(__GLcontext *gc)
  675. {
  676. __GLtransformT **trp, *tr, *stack;
  677. trp = &gc->transform.texture;
  678. stack = gc->transform.textureStack;
  679. tr = *trp;
  680. if (tr > &stack[0]) {
  681. *trp = tr - 1;
  682. MCD_STATE_DIRTY(gc, TEXTRANSFORM);
  683. } else {
  684. __glSetError(GL_STACK_UNDERFLOW);
  685. return;
  686. }
  687. }
  688. /************************************************************************/
  689. void FASTCALL __glDoLoadMatrix(__GLcontext *gc, const __GLfloat m[4][4], BOOL bIsIdentity)
  690. {
  691. __GLtransform *mvtr;
  692. __GLtransformP *ptr;
  693. __GLtransformT *ttr;
  694. switch (gc->state.transform.matrixMode) {
  695. case GL_MODELVIEW:
  696. mvtr = gc->transform.modelView;
  697. if (bIsIdentity)
  698. {
  699. __glMakeIdentity(&mvtr->matrix);
  700. __glGenericPickIdentityMatrixProcs(gc, &mvtr->matrix);
  701. __glMakeIdentity(&mvtr->inverseTranspose);
  702. __glGenericPickIdentityMatrixProcs(gc, &mvtr->inverseTranspose);
  703. mvtr->flags = XFORM_CHANGED;
  704. }
  705. else
  706. {
  707. *(__GLmatrixBase *)mvtr->matrix.matrix = *(__GLmatrixBase *)m;
  708. __glUpdateMatrixType(&mvtr->matrix);
  709. __glGenericPickMatrixProcs(gc, &mvtr->matrix);
  710. mvtr->flags = XFORM_CHANGED | XFORM_UPDATE_INVERSE;
  711. }
  712. /* Update mvp matrix */
  713. ptr = gc->transform.projection;
  714. ASSERTOPENGL(mvtr->sequence == ptr->sequence,
  715. "__glDoLoadMatrix: bad projection sequence\n");
  716. if (bIsIdentity)
  717. {
  718. *(__GLmatrixBase *)mvtr->mvp.matrix = *(__GLmatrixBase *)ptr->matrix.matrix;
  719. mvtr->mvp.matrixType = ptr->matrix.matrixType;
  720. }
  721. else
  722. {
  723. __glMultMatrix(&mvtr->mvp, &mvtr->matrix, (__GLmatrix *) &ptr->matrix);
  724. __glUpdateMatrixType(&mvtr->mvp);
  725. }
  726. __glGenericPickMvpMatrixProcs(gc, &mvtr->mvp);
  727. break;
  728. case GL_PROJECTION:
  729. ptr = gc->transform.projection;
  730. if (bIsIdentity)
  731. {
  732. __glMakeIdentity((__GLmatrix *) &ptr->matrix);
  733. }
  734. else
  735. {
  736. *(__GLmatrixBase *)ptr->matrix.matrix = *(__GLmatrixBase *)m;
  737. __glUpdateMatrixType((__GLmatrix *) &ptr->matrix);
  738. }
  739. #ifdef NT
  740. ptr->sequence = ++gc->transform.projectionSequence;
  741. #else
  742. if (++gc->transform.projectionSequence == 0) {
  743. __glInvalidateSequenceNumbers(gc);
  744. } else {
  745. ptr->sequence = gc->transform.projectionSequence;
  746. }
  747. #endif // NT
  748. /* Update mvp matrix */
  749. mvtr = gc->transform.modelView;
  750. mvtr->sequence = ptr->sequence;
  751. mvtr->flags |= XFORM_CHANGED;
  752. if (bIsIdentity)
  753. {
  754. *(__GLmatrixBase *)mvtr->mvp.matrix = *(__GLmatrixBase *)mvtr->matrix.matrix;
  755. mvtr->mvp.matrixType = mvtr->matrix.matrixType;
  756. }
  757. else
  758. {
  759. __glMultMatrix(&mvtr->mvp, &mvtr->matrix, (__GLmatrix *) &ptr->matrix);
  760. __glUpdateMatrixType(&mvtr->mvp);
  761. }
  762. __glGenericPickMvpMatrixProcs(gc, &mvtr->mvp);
  763. break;
  764. case GL_TEXTURE:
  765. ttr = gc->transform.texture;
  766. if (bIsIdentity)
  767. {
  768. __glMakeIdentity(&ttr->matrix);
  769. __glGenericPickIdentityMatrixProcs(gc, &ttr->matrix);
  770. }
  771. else
  772. {
  773. *(__GLmatrixBase *)ttr->matrix.matrix = *(__GLmatrixBase *)m;
  774. __glUpdateMatrixType(&ttr->matrix);
  775. __glGenericPickMatrixProcs(gc, &ttr->matrix);
  776. }
  777. MCD_STATE_DIRTY(gc, TEXTRANSFORM);
  778. break;
  779. }
  780. }
  781. void FASTCALL __glDoMultMatrix(__GLcontext *gc, void *data,
  782. void (FASTCALL *multiply)(__GLcontext *gc, __GLmatrix *m, void *data))
  783. {
  784. __GLtransform *mvtr;
  785. __GLtransformT *ttr;
  786. __GLtransformP *ptr;
  787. switch (gc->state.transform.matrixMode) {
  788. case GL_MODELVIEW:
  789. mvtr = gc->transform.modelView;
  790. (*multiply)(gc, &mvtr->matrix, data);
  791. mvtr->flags = XFORM_CHANGED | XFORM_UPDATE_INVERSE;
  792. __glGenericPickMatrixProcs(gc, &mvtr->matrix);
  793. /* Update mvp matrix */
  794. ASSERTOPENGL(mvtr->sequence == gc->transform.projection->sequence,
  795. "__glDoMultMatrix: bad projection sequence\n");
  796. (*multiply)(gc, &mvtr->mvp, data);
  797. __glGenericPickMvpMatrixProcs(gc, &mvtr->mvp);
  798. break;
  799. case GL_PROJECTION:
  800. ptr = gc->transform.projection;
  801. (*multiply)(gc, (__GLmatrix *) &ptr->matrix, data);
  802. #ifdef NT
  803. ptr->sequence = ++gc->transform.projectionSequence;
  804. #else
  805. if (++gc->transform.projectionSequence == 0) {
  806. __glInvalidateSequenceNumbers(gc);
  807. } else {
  808. ptr->sequence = gc->transform.projectionSequence;
  809. }
  810. #endif
  811. /* Update mvp matrix */
  812. mvtr = gc->transform.modelView;
  813. mvtr->sequence = ptr->sequence;
  814. mvtr->flags |= XFORM_CHANGED;
  815. __glMultMatrix(&mvtr->mvp, &mvtr->matrix, (__GLmatrix *) &ptr->matrix);
  816. __glUpdateMatrixType(&mvtr->mvp);
  817. __glGenericPickMvpMatrixProcs(gc, &mvtr->mvp);
  818. break;
  819. case GL_TEXTURE:
  820. ttr = gc->transform.texture;
  821. (*multiply)(gc, &ttr->matrix, data);
  822. __glGenericPickMatrixProcs(gc, &ttr->matrix);
  823. MCD_STATE_DIRTY(gc, TEXTRANSFORM);
  824. break;
  825. }
  826. }
  827. /************************************************************************/
  828. /*
  829. ** Muliply the first matrix by the second one keeping track of the matrix
  830. ** type of the newly combined matrix.
  831. */
  832. void FASTCALL __glMultiplyMatrix(__GLcontext *gc, __GLmatrix *m, void *data)
  833. {
  834. __GLmatrix *tm;
  835. tm = data;
  836. __glMultMatrix(m, tm, m);
  837. __glUpdateMatrixType(m);
  838. }
  839. void FASTCALL __glScaleMatrix(__GLcontext *gc, __GLmatrix *m, void *data)
  840. {
  841. struct __glScaleRec *scale;
  842. __GLfloat x,y,z;
  843. __GLfloat M0, M1, M2, M3;
  844. if (m->matrixType > __GL_MT_IS2DNR) {
  845. m->matrixType = __GL_MT_IS2DNR;
  846. }
  847. scale = data;
  848. x = scale->x;
  849. y = scale->y;
  850. z = scale->z;
  851. M0 = x * m->matrix[0][0];
  852. M1 = x * m->matrix[0][1];
  853. M2 = x * m->matrix[0][2];
  854. M3 = x * m->matrix[0][3];
  855. m->matrix[0][0] = M0;
  856. m->matrix[0][1] = M1;
  857. m->matrix[0][2] = M2;
  858. m->matrix[0][3] = M3;
  859. M0 = y * m->matrix[1][0];
  860. M1 = y * m->matrix[1][1];
  861. M2 = y * m->matrix[1][2];
  862. M3 = y * m->matrix[1][3];
  863. m->matrix[1][0] = M0;
  864. m->matrix[1][1] = M1;
  865. m->matrix[1][2] = M2;
  866. m->matrix[1][3] = M3;
  867. M0 = z * m->matrix[2][0];
  868. M1 = z * m->matrix[2][1];
  869. M2 = z * m->matrix[2][2];
  870. M3 = z * m->matrix[2][3];
  871. m->matrix[2][0] = M0;
  872. m->matrix[2][1] = M1;
  873. m->matrix[2][2] = M2;
  874. m->matrix[2][3] = M3;
  875. }
  876. /*
  877. ** Matrix type of m stays the same.
  878. */
  879. void FASTCALL __glTranslateMatrix(__GLcontext *gc, __GLmatrix *m, void *data)
  880. {
  881. struct __glTranslationRec *trans;
  882. __GLfloat x,y,z;
  883. __GLfloat M30, M31, M32, M33;
  884. if (m->matrixType > __GL_MT_IS2DNR) {
  885. m->matrixType = __GL_MT_IS2DNR;
  886. }
  887. trans = data;
  888. x = trans->x;
  889. y = trans->y;
  890. z = trans->z;
  891. M30 = x * m->matrix[0][0] + y * m->matrix[1][0] + z * m->matrix[2][0] +
  892. m->matrix[3][0];
  893. M31 = x * m->matrix[0][1] + y * m->matrix[1][1] + z * m->matrix[2][1] +
  894. m->matrix[3][1];
  895. M32 = x * m->matrix[0][2] + y * m->matrix[1][2] + z * m->matrix[2][2] +
  896. m->matrix[3][2];
  897. M33 = x * m->matrix[0][3] + y * m->matrix[1][3] + z * m->matrix[2][3] +
  898. m->matrix[3][3];
  899. m->matrix[3][0] = M30;
  900. m->matrix[3][1] = M31;
  901. m->matrix[3][2] = M32;
  902. m->matrix[3][3] = M33;
  903. }
  904. /************************************************************************/
  905. #define __GLXFORM1_INIT(v) \
  906. __GLfloat x = (v)[0]; \
  907. __GLfloat mat00, mat01, mat02, mat03; \
  908. __GLfloat mat30, mat31, mat32, mat33; \
  909. __GLfloat a0, a1, a2, a3; \
  910. \
  911. mat00 = m->matrix[0][0]; \
  912. mat01 = m->matrix[0][1]; \
  913. mat02 = m->matrix[0][2]; \
  914. mat03 = m->matrix[0][3]; \
  915. \
  916. mat30 = m->matrix[3][0]; \
  917. mat31 = m->matrix[3][1]; \
  918. mat32 = m->matrix[3][2]; \
  919. mat33 = m->matrix[3][3];
  920. #define __GLXFORM1_CONT(v) \
  921. x = (v)[0];
  922. #define __GLXFORM1(res) \
  923. a0 = x * mat00; \
  924. a1 = x * mat01; \
  925. a2 = x * mat02; \
  926. a3 = x * mat03; \
  927. \
  928. res->x = a0 + mat30; \
  929. res->y = a1 + mat31; \
  930. res->z = a2 + mat32; \
  931. res->w = a3 + mat33;
  932. #define __GLXFORM1_W_INIT(v) \
  933. __GLfloat x = (v)[0]; \
  934. __GLfloat mat00, mat01, mat02; \
  935. __GLfloat mat30, mat31, mat32; \
  936. __GLfloat a0, a1, a2; \
  937. \
  938. mat00 = m->matrix[0][0]; \
  939. mat01 = m->matrix[0][1]; \
  940. mat02 = m->matrix[0][2]; \
  941. \
  942. mat30 = m->matrix[3][0]; \
  943. mat31 = m->matrix[3][1]; \
  944. mat32 = m->matrix[3][2];
  945. #define __GLXFORM1_W(res) \
  946. a0 = x * mat00; \
  947. a1 = x * mat01; \
  948. a2 = x * mat02; \
  949. \
  950. res->x = a0 + mat30; \
  951. res->y = a1 + mat31; \
  952. res->z = a2 + mat32; \
  953. res->w = ((__GLfloat) 1.0);
  954. #define __GLXFORM1_2DW_INIT(v) \
  955. __GLfloat x = (v)[0]; \
  956. __GLfloat mat00, mat01; \
  957. __GLfloat mat30, mat31, mat32; \
  958. __GLfloat a0, a1; \
  959. \
  960. mat00 = m->matrix[0][0]; \
  961. mat01 = m->matrix[0][1]; \
  962. \
  963. mat30 = m->matrix[3][0]; \
  964. mat31 = m->matrix[3][1]; \
  965. \
  966. mat32 = m->matrix[3][2];
  967. #define __GLXFORM1_2DW(res) \
  968. a0 = x * mat00; \
  969. a1 = x * mat01; \
  970. \
  971. res->x = a0 + mat30; \
  972. res->y = a1 + mat31; \
  973. res->z = mat32; \
  974. res->w = ((__GLfloat) 1.0);
  975. #define __GLXFORM1_2DNRW_INIT(v) \
  976. __GLfloat x = (v)[0]; \
  977. __GLfloat mat00, mat01; \
  978. __GLfloat mat30, mat31, mat32; \
  979. __GLfloat a0; \
  980. \
  981. mat00 = m->matrix[0][0]; \
  982. mat01 = m->matrix[0][1]; \
  983. \
  984. mat30 = m->matrix[3][0]; \
  985. mat31 = m->matrix[3][1]; \
  986. \
  987. mat32 = m->matrix[3][2];
  988. #define __GLXFORM1_2DNRW(res) \
  989. a0 = x * mat00; \
  990. \
  991. res->x = a0 + mat30; \
  992. res->y = mat31; \
  993. res->z = mat32; \
  994. res->w = ((__GLfloat) 1.0);
  995. #define __GLXFORM2_INIT(v) \
  996. __GLfloat x = (v)[0]; \
  997. __GLfloat y = (v)[1]; \
  998. __GLfloat mat00, mat01, mat02, mat03; \
  999. __GLfloat mat10, mat11, mat12, mat13; \
  1000. __GLfloat mat30, mat31, mat32, mat33; \
  1001. __GLfloat a0, a1, a2, a3; \
  1002. __GLfloat b0, b1, b2, b3; \
  1003. \
  1004. mat00 = m->matrix[0][0]; \
  1005. mat01 = m->matrix[0][1]; \
  1006. mat02 = m->matrix[0][2]; \
  1007. mat03 = m->matrix[0][3]; \
  1008. \
  1009. mat10 = m->matrix[1][0]; \
  1010. mat11 = m->matrix[1][1]; \
  1011. mat12 = m->matrix[1][2]; \
  1012. mat13 = m->matrix[1][3]; \
  1013. \
  1014. mat30 = m->matrix[3][0]; \
  1015. mat31 = m->matrix[3][1]; \
  1016. mat32 = m->matrix[3][2]; \
  1017. mat33 = m->matrix[3][3];
  1018. #define __GLXFORM2_CONT(v) \
  1019. x = (v)[0]; \
  1020. y = (v)[1];
  1021. #define __GLXFORM2(res) \
  1022. a0 = x * mat00; \
  1023. a1 = x * mat01; \
  1024. a2 = x * mat02; \
  1025. a3 = x * mat03; \
  1026. \
  1027. b0 = y * mat10; \
  1028. b1 = y * mat11; \
  1029. b2 = y * mat12; \
  1030. b3 = y * mat13; \
  1031. \
  1032. a0 += mat30; \
  1033. a1 += mat31; \
  1034. a2 += mat32; \
  1035. a3 += mat33; \
  1036. \
  1037. res->x = a0 + b0; \
  1038. res->y = a1 + b1; \
  1039. res->z = a2 + b2; \
  1040. res->w = a3 + b3;
  1041. #define __GLXFORM2_W_INIT(v) \
  1042. __GLfloat x = (v)[0]; \
  1043. __GLfloat y = (v)[1]; \
  1044. __GLfloat mat00, mat01, mat02; \
  1045. __GLfloat mat10, mat11, mat12; \
  1046. __GLfloat mat30, mat31, mat32; \
  1047. __GLfloat a0, a1, a2; \
  1048. __GLfloat b0, b1, b2; \
  1049. \
  1050. mat00 = m->matrix[0][0]; \
  1051. mat01 = m->matrix[0][1]; \
  1052. mat02 = m->matrix[0][2]; \
  1053. \
  1054. mat10 = m->matrix[1][0]; \
  1055. mat11 = m->matrix[1][1]; \
  1056. mat12 = m->matrix[1][2]; \
  1057. \
  1058. mat30 = m->matrix[3][0]; \
  1059. mat31 = m->matrix[3][1]; \
  1060. mat32 = m->matrix[3][2];
  1061. #define __GLXFORM2_W(res) \
  1062. a0 = x * mat00; \
  1063. a1 = x * mat01; \
  1064. a2 = x * mat02; \
  1065. \
  1066. b0 = y * mat10; \
  1067. b1 = y * mat11; \
  1068. b2 = y * mat12; \
  1069. \
  1070. a0 += mat30; \
  1071. a1 += mat31; \
  1072. a2 += mat32; \
  1073. \
  1074. res->x = a0 + b0; \
  1075. res->y = a1 + b1; \
  1076. res->z = a2 + b2; \
  1077. res->w = ((__GLfloat) 1.0);
  1078. #define __GLXFORM2_2DW_INIT(v) \
  1079. __GLfloat x = (v)[0]; \
  1080. __GLfloat y = (v)[1]; \
  1081. __GLfloat mat00, mat01; \
  1082. __GLfloat mat10, mat11; \
  1083. __GLfloat mat30, mat31, mat32; \
  1084. __GLfloat a0, a1; \
  1085. __GLfloat b0, b1; \
  1086. \
  1087. mat00 = m->matrix[0][0]; \
  1088. mat01 = m->matrix[0][1]; \
  1089. \
  1090. mat10 = m->matrix[1][0]; \
  1091. mat11 = m->matrix[1][1]; \
  1092. \
  1093. mat30 = m->matrix[3][0]; \
  1094. mat31 = m->matrix[3][1]; \
  1095. mat32 = m->matrix[3][2];
  1096. #define __GLXFORM2_2DW(res) \
  1097. a0 = x * mat00; \
  1098. a1 = x * mat01; \
  1099. \
  1100. b0 = y * mat10; \
  1101. b1 = y * mat11; \
  1102. \
  1103. a0 += mat30; \
  1104. a1 += mat31; \
  1105. \
  1106. res->x = a0 + b0; \
  1107. res->y = a1 + b1; \
  1108. res->z = mat32; \
  1109. res->w = ((__GLfloat) 1.0);
  1110. #define __GLXFORM2_2DNRW_INIT(v) \
  1111. __GLfloat x = (v)[0]; \
  1112. __GLfloat y = (v)[1]; \
  1113. __GLfloat mat00; \
  1114. __GLfloat mat11; \
  1115. __GLfloat mat30, mat31, mat32; \
  1116. __GLfloat a0, b0; \
  1117. \
  1118. mat00 = m->matrix[0][0]; \
  1119. \
  1120. mat11 = m->matrix[1][1]; \
  1121. \
  1122. mat30 = m->matrix[3][0]; \
  1123. mat31 = m->matrix[3][1]; \
  1124. mat32 = m->matrix[3][2];
  1125. #define __GLXFORM2_2DNRW(res) \
  1126. a0 = x * mat00; \
  1127. \
  1128. b0 = y * mat11; \
  1129. \
  1130. res->x = a0 + mat30; \
  1131. res->y = b0 + mat31; \
  1132. res->z = mat32; \
  1133. res->w = ((__GLfloat) 1.0);
  1134. #define __GLXFORM3_INIT(v) \
  1135. __GLfloat x = (v)[0]; \
  1136. __GLfloat y = (v)[1]; \
  1137. __GLfloat z = (v)[2]; \
  1138. __GLfloat mat00, mat01, mat02, mat03; \
  1139. __GLfloat mat10, mat11, mat12, mat13; \
  1140. __GLfloat mat20, mat21, mat22, mat23; \
  1141. __GLfloat mat30, mat31, mat32, mat33; \
  1142. __GLfloat a0, a1, a2, a3; \
  1143. __GLfloat b0, b1, b2, b3; \
  1144. __GLfloat c0, c1, c2, c3; \
  1145. \
  1146. mat00 = m->matrix[0][0]; \
  1147. mat01 = m->matrix[0][1]; \
  1148. mat02 = m->matrix[0][2]; \
  1149. mat03 = m->matrix[0][3]; \
  1150. \
  1151. mat10 = m->matrix[1][0]; \
  1152. mat11 = m->matrix[1][1]; \
  1153. mat12 = m->matrix[1][2]; \
  1154. mat13 = m->matrix[1][3]; \
  1155. \
  1156. mat20 = m->matrix[2][0]; \
  1157. mat21 = m->matrix[2][1]; \
  1158. mat22 = m->matrix[2][2]; \
  1159. mat23 = m->matrix[2][3]; \
  1160. \
  1161. mat30 = m->matrix[3][0]; \
  1162. mat31 = m->matrix[3][1]; \
  1163. mat32 = m->matrix[3][2]; \
  1164. mat33 = m->matrix[3][3];
  1165. #define __GLXFORM3_CONT(v) \
  1166. x = (v)[0]; \
  1167. y = (v)[1]; \
  1168. z = (v)[2];
  1169. #define __GLXFORM3(res) \
  1170. a0 = mat00 * x; \
  1171. a1 = mat01 * x; \
  1172. a2 = mat02 * x; \
  1173. a3 = mat03 * x; \
  1174. \
  1175. b0 = mat10 * y; \
  1176. b1 = mat11 * y; \
  1177. b2 = mat12 * y; \
  1178. b3 = mat13 * y; \
  1179. \
  1180. c0 = mat20 * z; \
  1181. c1 = mat21 * z; \
  1182. c2 = mat22 * z; \
  1183. c3 = mat23 * z; \
  1184. \
  1185. a0 += mat30; \
  1186. a1 += mat31; \
  1187. a2 += mat32; \
  1188. a3 += mat33; \
  1189. \
  1190. a0 += b0; \
  1191. a1 += b1; \
  1192. a2 += b2; \
  1193. a3 += b3; \
  1194. \
  1195. res->x = a0 + c0; \
  1196. res->y = a1 + c1; \
  1197. res->z = a2 + c2; \
  1198. res->w = a3 + c3;
  1199. #define __GLXFORM3_W_INIT(v) \
  1200. __GLfloat x = (v)[0]; \
  1201. __GLfloat y = (v)[1]; \
  1202. __GLfloat z = (v)[2]; \
  1203. __GLfloat mat00, mat01, mat02; \
  1204. __GLfloat mat10, mat11, mat12; \
  1205. __GLfloat mat20, mat21, mat22; \
  1206. __GLfloat mat30, mat31, mat32; \
  1207. __GLfloat a0, a1, a2; \
  1208. __GLfloat b0, b1, b2; \
  1209. __GLfloat c0, c1, c2; \
  1210. \
  1211. mat00 = m->matrix[0][0]; \
  1212. mat01 = m->matrix[0][1]; \
  1213. mat02 = m->matrix[0][2]; \
  1214. \
  1215. mat10 = m->matrix[1][0]; \
  1216. mat11 = m->matrix[1][1]; \
  1217. mat12 = m->matrix[1][2]; \
  1218. \
  1219. mat20 = m->matrix[2][0]; \
  1220. mat21 = m->matrix[2][1]; \
  1221. mat22 = m->matrix[2][2]; \
  1222. \
  1223. mat30 = m->matrix[3][0]; \
  1224. mat31 = m->matrix[3][1]; \
  1225. mat32 = m->matrix[3][2];
  1226. #define __GLXFORM3x3_INIT(v) \
  1227. __GLfloat x = (v)[0]; \
  1228. __GLfloat y = (v)[1]; \
  1229. __GLfloat z = (v)[2]; \
  1230. __GLfloat mat00, mat01, mat02; \
  1231. __GLfloat mat10, mat11, mat12; \
  1232. __GLfloat mat20, mat21, mat22; \
  1233. __GLfloat a0, a1, a2; \
  1234. __GLfloat b0, b1, b2; \
  1235. __GLfloat c0, c1, c2; \
  1236. \
  1237. mat00 = m->matrix[0][0]; \
  1238. mat01 = m->matrix[0][1]; \
  1239. mat02 = m->matrix[0][2]; \
  1240. \
  1241. mat10 = m->matrix[1][0]; \
  1242. mat11 = m->matrix[1][1]; \
  1243. mat12 = m->matrix[1][2]; \
  1244. \
  1245. mat20 = m->matrix[2][0]; \
  1246. mat21 = m->matrix[2][1]; \
  1247. mat22 = m->matrix[2][2]; \
  1248. \
  1249. #define __GLXFORM3x3(res) \
  1250. a0 = mat00 * x; \
  1251. a1 = mat01 * x; \
  1252. a2 = mat02 * x; \
  1253. \
  1254. b0 = mat10 * y; \
  1255. b1 = mat11 * y; \
  1256. b2 = mat12 * y; \
  1257. \
  1258. c0 = mat20 * z; \
  1259. c1 = mat21 * z; \
  1260. c2 = mat22 * z; \
  1261. \
  1262. a0 += b0; \
  1263. a1 += b1; \
  1264. a2 += b2; \
  1265. \
  1266. res->x = a0 + c0; \
  1267. res->y = a1 + c1; \
  1268. res->z = a2 + c2;
  1269. #define __GLXFORM3_W(res) \
  1270. a0 = mat00 * x; \
  1271. a1 = mat01 * x; \
  1272. a2 = mat02 * x; \
  1273. \
  1274. b0 = mat10 * y; \
  1275. b1 = mat11 * y; \
  1276. b2 = mat12 * y; \
  1277. \
  1278. c0 = mat20 * z; \
  1279. c1 = mat21 * z; \
  1280. c2 = mat22 * z; \
  1281. \
  1282. a0 += mat30; \
  1283. a1 += mat31; \
  1284. a2 += mat32; \
  1285. \
  1286. a0 += b0; \
  1287. a1 += b1; \
  1288. a2 += b2; \
  1289. \
  1290. res->x = a0 + c0; \
  1291. res->y = a1 + c1; \
  1292. res->z = a2 + c2; \
  1293. res->w = ((__GLfloat) 1.0);
  1294. #define __GLXFORM3_2DW_INIT(v) \
  1295. __GLfloat x = (v)[0]; \
  1296. __GLfloat y = (v)[1]; \
  1297. __GLfloat z = (v)[2]; \
  1298. __GLfloat mat00, mat01; \
  1299. __GLfloat mat10, mat11; \
  1300. __GLfloat mat22; \
  1301. __GLfloat mat30, mat31, mat32; \
  1302. __GLfloat a0, a1; \
  1303. __GLfloat b0, b1; \
  1304. __GLfloat c0; \
  1305. \
  1306. mat00 = m->matrix[0][0]; \
  1307. mat01 = m->matrix[0][1]; \
  1308. mat22 = m->matrix[2][2]; \
  1309. \
  1310. mat10 = m->matrix[1][0]; \
  1311. mat11 = m->matrix[1][1]; \
  1312. \
  1313. mat30 = m->matrix[3][0]; \
  1314. mat31 = m->matrix[3][1]; \
  1315. mat32 = m->matrix[3][2];
  1316. #define __GLXFORM3_2DW(res) \
  1317. a0 = mat00 * x; \
  1318. a1 = mat01 * x; \
  1319. \
  1320. c0 = mat22 * z; \
  1321. \
  1322. b0 = mat10 * y; \
  1323. b1 = mat11 * y; \
  1324. \
  1325. a0 += mat30; \
  1326. a1 += mat31; \
  1327. \
  1328. res->x = a0 + b0; \
  1329. res->y = a1 + b1; \
  1330. res->z = c0 + mat32; \
  1331. res->w = ((__GLfloat) 1.0);
  1332. #define __GLXFORM3_2DNRW_INIT(v) \
  1333. __GLfloat x = (v)[0]; \
  1334. __GLfloat y = (v)[1]; \
  1335. __GLfloat z = (v)[2]; \
  1336. __GLfloat mat00, mat11, mat22; \
  1337. __GLfloat mat30, mat31, mat32; \
  1338. __GLfloat a0; \
  1339. __GLfloat b0; \
  1340. __GLfloat c0; \
  1341. \
  1342. mat00 = m->matrix[0][0]; \
  1343. mat11 = m->matrix[1][1]; \
  1344. mat22 = m->matrix[2][2]; \
  1345. \
  1346. mat30 = m->matrix[3][0]; \
  1347. mat31 = m->matrix[3][1]; \
  1348. mat32 = m->matrix[3][2];
  1349. #define __GLXFORM3_2DNRW(res) \
  1350. a0 = mat00 * x; \
  1351. b0 = mat11 * y; \
  1352. c0 = mat22 * z; \
  1353. \
  1354. res->x = a0 + mat30; \
  1355. res->y = b0 + mat31; \
  1356. res->z = c0 + mat32; \
  1357. res->w = ((__GLfloat) 1.0);
  1358. #define __GLXFORM4_INIT(v) \
  1359. __GLfloat x = (v)[0]; \
  1360. __GLfloat y = (v)[1]; \
  1361. __GLfloat z = (v)[2]; \
  1362. __GLfloat w = (v)[3]; \
  1363. \
  1364. __GLfloat mat00, mat01, mat02, mat03; \
  1365. __GLfloat mat10, mat11, mat12, mat13; \
  1366. __GLfloat mat20, mat21, mat22, mat23; \
  1367. __GLfloat mat30, mat31, mat32, mat33; \
  1368. __GLfloat a0, a1, a2, a3; \
  1369. __GLfloat b0, b1, b2, b3; \
  1370. __GLfloat c0, c1, c2, c3; \
  1371. __GLfloat d0, d1, d2, d3; \
  1372. \
  1373. mat00 = m->matrix[0][0]; \
  1374. mat01 = m->matrix[0][1]; \
  1375. mat02 = m->matrix[0][2]; \
  1376. mat03 = m->matrix[0][3]; \
  1377. \
  1378. mat10 = m->matrix[1][0]; \
  1379. mat11 = m->matrix[1][1]; \
  1380. mat12 = m->matrix[1][2]; \
  1381. mat13 = m->matrix[1][3]; \
  1382. \
  1383. mat20 = m->matrix[2][0]; \
  1384. mat21 = m->matrix[2][1]; \
  1385. mat22 = m->matrix[2][2]; \
  1386. mat23 = m->matrix[2][3]; \
  1387. \
  1388. mat30 = m->matrix[3][0]; \
  1389. mat31 = m->matrix[3][1]; \
  1390. mat32 = m->matrix[3][2]; \
  1391. mat33 = m->matrix[3][3];
  1392. #define __GLXFORM4_CONT(v) \
  1393. x = (v)[0]; \
  1394. y = (v)[1]; \
  1395. z = (v)[2]; \
  1396. w = (v)[3];
  1397. #define __GLXFORM4(res) \
  1398. a0 = mat00 * x; \
  1399. a1 = mat01 * x; \
  1400. a2 = mat02 * x; \
  1401. a3 = mat03 * x; \
  1402. \
  1403. b0 = mat10 * y; \
  1404. b1 = mat11 * y; \
  1405. b2 = mat12 * y; \
  1406. b3 = mat13 * y; \
  1407. \
  1408. c0 = mat20 * z; \
  1409. c1 = mat21 * z; \
  1410. c2 = mat22 * z; \
  1411. c3 = mat23 * z; \
  1412. \
  1413. d0 = mat30 * w; \
  1414. d1 = mat31 * w; \
  1415. d2 = mat32 * w; \
  1416. d3 = mat33 * w; \
  1417. \
  1418. a0 += b0; \
  1419. a1 += b1; \
  1420. a2 += b2; \
  1421. a3 += b3; \
  1422. \
  1423. a0 += c0; \
  1424. a1 += c1; \
  1425. a2 += c2; \
  1426. a3 += c3; \
  1427. \
  1428. res->x = a0 + d0; \
  1429. res->y = a1 + d1; \
  1430. res->z = a2 + d2; \
  1431. res->w = a3 + d3;
  1432. #define __GLXFORM4_W_INIT(v) \
  1433. __GLfloat x = (v)[0]; \
  1434. __GLfloat y = (v)[1]; \
  1435. __GLfloat z = (v)[2]; \
  1436. __GLfloat w = (v)[3]; \
  1437. __GLfloat mat00, mat01, mat02; \
  1438. __GLfloat mat10, mat11, mat12; \
  1439. __GLfloat mat20, mat21, mat22; \
  1440. __GLfloat mat30, mat31, mat32; \
  1441. __GLfloat a0, a1, a2; \
  1442. __GLfloat b0, b1, b2; \
  1443. __GLfloat c0, c1, c2; \
  1444. __GLfloat d0, d1, d2; \
  1445. \
  1446. mat00 = m->matrix[0][0]; \
  1447. mat01 = m->matrix[0][1]; \
  1448. mat02 = m->matrix[0][2]; \
  1449. \
  1450. mat10 = m->matrix[1][0]; \
  1451. mat11 = m->matrix[1][1]; \
  1452. mat12 = m->matrix[1][2]; \
  1453. \
  1454. mat20 = m->matrix[2][0]; \
  1455. mat21 = m->matrix[2][1]; \
  1456. mat22 = m->matrix[2][2]; \
  1457. \
  1458. mat30 = m->matrix[3][0]; \
  1459. mat31 = m->matrix[3][1]; \
  1460. mat32 = m->matrix[3][2];
  1461. #define __GLXFORM4_W(res) \
  1462. a0 = mat00 * x; \
  1463. a1 = mat01 * x; \
  1464. a2 = mat02 * x; \
  1465. \
  1466. b0 = mat10 * y; \
  1467. b1 = mat11 * y; \
  1468. b2 = mat12 * y; \
  1469. \
  1470. c0 = mat20 * z; \
  1471. c1 = mat21 * z; \
  1472. c2 = mat22 * z; \
  1473. \
  1474. d0 = mat30 * w; \
  1475. d1 = mat31 * w; \
  1476. d2 = mat32 * w; \
  1477. \
  1478. a0 += b0; \
  1479. a1 += b1; \
  1480. a2 += b2; \
  1481. \
  1482. a0 += c0; \
  1483. a1 += c1; \
  1484. a2 += c2; \
  1485. \
  1486. res->x = a0 + d0; \
  1487. res->y = a1 + d1; \
  1488. res->z = a2 + d2; \
  1489. res->w = w;
  1490. #define __GLXFORM4_2DW_INIT(v) \
  1491. __GLfloat x = (v)[0]; \
  1492. __GLfloat y = (v)[1]; \
  1493. __GLfloat z = (v)[2]; \
  1494. __GLfloat w = (v)[3]; \
  1495. __GLfloat mat00, mat01; \
  1496. __GLfloat mat10, mat11; \
  1497. __GLfloat mat22; \
  1498. __GLfloat mat30, mat31, mat32; \
  1499. __GLfloat a0, a1; \
  1500. __GLfloat b0, b1; \
  1501. __GLfloat c0; \
  1502. __GLfloat d0; \
  1503. \
  1504. mat00 = m->matrix[0][0]; \
  1505. mat01 = m->matrix[0][1]; \
  1506. mat22 = m->matrix[2][2]; \
  1507. \
  1508. mat10 = m->matrix[1][0]; \
  1509. mat11 = m->matrix[1][1]; \
  1510. \
  1511. mat30 = m->matrix[3][0]; \
  1512. mat31 = m->matrix[3][1]; \
  1513. mat32 = m->matrix[3][2];
  1514. #define __GLXFORM4_2DW(res) \
  1515. a0 = mat00 * x; \
  1516. a1 = mat01 * x; \
  1517. c0 = mat22 * z; \
  1518. \
  1519. b0 = mat10 * y; \
  1520. b1 = mat11 * y; \
  1521. \
  1522. d0 = mat32 * w; \
  1523. \
  1524. a0 += mat30; \
  1525. a1 += mat31; \
  1526. \
  1527. res->x = a0 + b0; \
  1528. res->y = a1 + b1; \
  1529. res->z = c0 + d0; \
  1530. res->w = w;
  1531. #define __GLXFORM4_2DNRW_INIT(v) \
  1532. __GLfloat x = (v)[0]; \
  1533. __GLfloat y = (v)[1]; \
  1534. __GLfloat z = (v)[2]; \
  1535. __GLfloat w = (v)[3]; \
  1536. __GLfloat mat00; \
  1537. __GLfloat mat11; \
  1538. __GLfloat mat22; \
  1539. __GLfloat mat30, mat31, mat32; \
  1540. __GLfloat a0; \
  1541. __GLfloat b0; \
  1542. __GLfloat c0; \
  1543. __GLfloat d0, d1, d2; \
  1544. \
  1545. mat00 = m->matrix[0][0]; \
  1546. mat11 = m->matrix[1][1]; \
  1547. mat22 = m->matrix[2][2]; \
  1548. \
  1549. mat30 = m->matrix[3][0]; \
  1550. mat31 = m->matrix[3][1]; \
  1551. mat32 = m->matrix[3][2];
  1552. #define __GLXFORM4_2DNRW(res) \
  1553. a0 = mat00 * x; \
  1554. b0 = mat11 * y; \
  1555. c0 = mat22 * z; \
  1556. \
  1557. d0 = mat30 * w; \
  1558. d1 = mat31 * w; \
  1559. d2 = mat32 * w; \
  1560. \
  1561. res->x = a0 + d0; \
  1562. res->y = b0 + d1; \
  1563. res->z = c0 + d2; \
  1564. res->w = w;
  1565. #define __GLXFORM_NORMAL_BATCH(funcName, initFunc, workFunc, continueFunc) \
  1566. void FASTCALL funcName(POLYARRAY *pa, const __GLmatrix *m) \
  1567. { \
  1568. POLYDATA *pd = pa->pd0; \
  1569. POLYDATA *pdLast = pa->pdNextVertex; \
  1570. \
  1571. for (;pd < pdLast; pd++) { \
  1572. if (pd->flags & POLYDATA_NORMAL_VALID) \
  1573. { \
  1574. __GLcoord *res = &pd->normal; \
  1575. initFunc((__GLfloat *)res); \
  1576. workFunc(res); \
  1577. continueFunc((__GLfloat *)res); \
  1578. } \
  1579. } \
  1580. }
  1581. #define __GLXFORM_NORMAL_BATCHN(funcName, initFunc, workFunc, continueFunc) \
  1582. void FASTCALL funcName(POLYARRAY *pa, const __GLmatrix *m) \
  1583. { \
  1584. POLYDATA *pd = pa->pd0; \
  1585. POLYDATA *pdLast = pa->pdNextVertex; \
  1586. \
  1587. for (;pd < pdLast; pd++) { \
  1588. if (pd->flags & POLYDATA_NORMAL_VALID) \
  1589. { \
  1590. __GLcoord *res = &pd->normal; \
  1591. initFunc((__GLfloat *)res); \
  1592. workFunc(res); \
  1593. continueFunc((__GLfloat *)res); \
  1594. __glNormalize((__GLfloat *)res, (__GLfloat *)res); \
  1595. } \
  1596. } \
  1597. }
  1598. #define __GLXFORM_BATCH(funcName, initFunc, workFunc, continueFunc) \
  1599. void FASTCALL funcName(__GLcoord *res, __GLcoord *end, const __GLmatrix *m) \
  1600. { \
  1601. initFunc((__GLfloat *)res); \
  1602. \
  1603. for (;;) { \
  1604. workFunc(res); \
  1605. (char *)res += sizeof(POLYDATA); \
  1606. if (res > end) \
  1607. break; \
  1608. continueFunc((__GLfloat *)res); \
  1609. } \
  1610. }
  1611. /*
  1612. ** Note: These xform routines must allow for the case where the result
  1613. ** vector is equal to the source vector.
  1614. */
  1615. #ifndef __GL_ASM_XFORM1
  1616. /*
  1617. ** Avoid some transformation computations by knowing that the incoming
  1618. ** vertex has y=0, z=0 and w=1.
  1619. */
  1620. void FASTCALL __glXForm1(__GLcoord *res, const __GLfloat v[1], const __GLmatrix *m)
  1621. {
  1622. __GLXFORM1_INIT(v)
  1623. __GLXFORM1(res);
  1624. }
  1625. #endif /* !__GL_ASM_XFORM1 */
  1626. #ifndef __GL_ASM_XFORM1BATCH
  1627. __GLXFORM_BATCH(__glXForm1Batch, __GLXFORM1_INIT, __GLXFORM1, __GLXFORM1_CONT);
  1628. #endif /* !__GL_ASM_XFORM1BATCH */
  1629. #ifndef __GL_ASM_XFORM2
  1630. /*
  1631. ** Avoid some transformation computations by knowing that the incoming
  1632. ** vertex has z=0 and w=1
  1633. */
  1634. void FASTCALL __glXForm2(__GLcoord *res, const __GLfloat v[2], const __GLmatrix *m)
  1635. {
  1636. __GLXFORM2_INIT(v)
  1637. __GLXFORM2(res);
  1638. }
  1639. #endif /* !__GL_ASM_XFORM2 */
  1640. #ifndef __GL_ASM_XFORM2BATCH
  1641. __GLXFORM_BATCH (__glXForm2Batch, __GLXFORM2_INIT, __GLXFORM2, __GLXFORM2_CONT);
  1642. #endif /* !__GL_ASM_XFORM2BATCH */
  1643. #ifndef __GL_ASM_XFORM3
  1644. /*
  1645. ** Avoid some transformation computations by knowing that the incoming
  1646. ** vertex has w=1.
  1647. */
  1648. void FASTCALL __glXForm3(__GLcoord *res, const __GLfloat v[3], const __GLmatrix *m)
  1649. {
  1650. __GLXFORM3_INIT(v)
  1651. __GLXFORM3(res);
  1652. }
  1653. #endif /* !__GL_ASM_XFORM3 */
  1654. #ifndef __GL_ASM_XFORM3BATCH
  1655. __GLXFORM_BATCH (__glXForm3Batch, __GLXFORM3_INIT, __GLXFORM3, __GLXFORM3_CONT);
  1656. #endif /* !__GL_ASM_XFORM3BATCH */
  1657. #ifndef __GL_ASM_XFORM4
  1658. /*
  1659. ** Full 4x4 transformation.
  1660. */
  1661. void FASTCALL __glXForm4(__GLcoord *res, const __GLfloat v[4], const __GLmatrix *m)
  1662. {
  1663. __GLXFORM4_INIT(v)
  1664. __GLXFORM4(res);
  1665. }
  1666. #endif /* !__GL_ASM_XFORM4 */
  1667. #ifndef __GL_ASM_XFORM4BATCH
  1668. __GLXFORM_BATCH (__glXForm4Batch, __GLXFORM4_INIT, __GLXFORM4, __GLXFORM4_CONT);
  1669. #endif /* !__GL_ASM_XFORM4BATCH */
  1670. /************************************************************************/
  1671. #ifndef __GL_ASM_XFORM1_W
  1672. /*
  1673. ** Avoid some transformation computations by knowing that the incoming
  1674. ** vertex has y=0, z=0 and w=1. The w column of the matrix is [0 0 0 1].
  1675. */
  1676. void FASTCALL __glXForm1_W(__GLcoord *res, const __GLfloat v[1], const __GLmatrix *m)
  1677. {
  1678. __GLXFORM1_W_INIT(v)
  1679. __GLXFORM1_W(res);
  1680. }
  1681. #endif /* !__GL_ASM_XFORM1_W */
  1682. #ifndef __GL_ASM_XFORM1_WBATCH
  1683. __GLXFORM_BATCH (__glXForm1_WBatch, __GLXFORM1_W_INIT, __GLXFORM1_W, __GLXFORM1_CONT);
  1684. #endif /* !__GL_ASM_XFORM1_WBATCH */
  1685. #ifndef __GL_ASM_XFORM2_W
  1686. /*
  1687. ** Avoid some transformation computations by knowing that the incoming
  1688. ** vertex has z=0 and w=1. The w column of the matrix is [0 0 0 1].
  1689. */
  1690. void FASTCALL __glXForm2_W(__GLcoord *res, const __GLfloat v[2], const __GLmatrix *m)
  1691. {
  1692. __GLXFORM2_W_INIT(v)
  1693. __GLXFORM2_W(res);
  1694. }
  1695. #endif /* !__GL_ASM_XFORM2_W */
  1696. #ifndef __GL_ASM_XFORM2_WBATCH
  1697. __GLXFORM_BATCH (__glXForm2_WBatch, __GLXFORM2_W_INIT, __GLXFORM2_W, __GLXFORM2_CONT);
  1698. #endif /* !__GL_ASM_XFORM2_WBATCH */
  1699. #ifndef __GL_ASM_XFORM3_W
  1700. /*
  1701. ** Avoid some transformation computations by knowing that the incoming
  1702. ** vertex has w=1. The w column of the matrix is [0 0 0 1].
  1703. */
  1704. void FASTCALL __glXForm3_W(__GLcoord *res, const __GLfloat v[3], const __GLmatrix *m)
  1705. {
  1706. __GLXFORM3_W_INIT(v)
  1707. __GLXFORM3_W(res);
  1708. }
  1709. #endif /* !__GL_ASM_XFORM3_W */
  1710. #ifndef __GL_ASM_XFORM3_WBATCH
  1711. __GLXFORM_BATCH (__glXForm3_WBatch, __GLXFORM3_W_INIT, __GLXFORM3_W, __GLXFORM3_CONT);
  1712. #endif /* !__GL_ASM_XFORM3_WBATCH */
  1713. #ifndef __GL_ASM_XFORM3x3
  1714. /*
  1715. ** Avoid some transformation computations by knowing that the incoming
  1716. ** vertex is a normal. This is allowed according to the OpenGL spec.
  1717. */
  1718. void FASTCALL __glXForm3x3(__GLcoord *res, const __GLfloat v[3], const __GLmatrix *m)
  1719. {
  1720. __GLXFORM3x3_INIT(v);
  1721. __GLXFORM3x3(res);
  1722. }
  1723. #endif /* !__GL_ASM_XFORM3x3 */
  1724. #ifndef __GL_ASM_XFORM3x3BATCH
  1725. __GLXFORM_BATCH (__glXForm3x3Batch, __GLXFORM3x3_INIT, __GLXFORM3x3, __GLXFORM3_CONT);
  1726. #endif /* !__GL_ASM_XFORM3x3BATCH */
  1727. #ifndef __GL_ASM_XFORM4_W
  1728. /*
  1729. ** Full 4x4 transformation. The w column of the matrix is [0 0 0 1].
  1730. */
  1731. void FASTCALL __glXForm4_W(__GLcoord *res, const __GLfloat v[4], const __GLmatrix *m)
  1732. {
  1733. __GLXFORM4_W_INIT(v)
  1734. __GLXFORM4_W(res);
  1735. }
  1736. #endif /* !__GL_ASM_XFORM4_W */
  1737. #ifndef __GL_ASM_XFORM4_WBATCH
  1738. __GLXFORM_BATCH (__glXForm4_WBatch, __GLXFORM4_W_INIT, __GLXFORM4_W, __GLXFORM4_CONT);
  1739. #endif /* !__GL_ASM_XFORM4_WBATCH */
  1740. #ifndef __GL_ASM_XFORM1_2DW
  1741. /*
  1742. ** Avoid some transformation computations by knowing that the incoming
  1743. ** vertex has y=0, z=0 and w=1.
  1744. **
  1745. ** The matrix looks like:
  1746. ** | . . 0 0 |
  1747. ** | . . 0 0 |
  1748. ** | 0 0 . 0 |
  1749. ** | . . . 1 |
  1750. */
  1751. void FASTCALL __glXForm1_2DW(__GLcoord *res, const __GLfloat v[1], const __GLmatrix *m)
  1752. {
  1753. __GLXFORM1_2DW_INIT(v)
  1754. __GLXFORM1_2DW(res);
  1755. }
  1756. #endif /* !__GL_ASM_XFORM1_2DW */
  1757. #ifndef __GL_ASM_XFORM1_2DWBATCH
  1758. __GLXFORM_BATCH (__glXForm1_2DWBatch, __GLXFORM1_2DW_INIT, __GLXFORM1_2DW, __GLXFORM1_CONT);
  1759. #endif /* !__GL_ASM_XFORM1_2DWBATCH */
  1760. #ifndef __GL_ASM_XFORM2_2DW
  1761. /*
  1762. ** Avoid some transformation computations by knowing that the incoming
  1763. ** vertex has z=0 and w=1.
  1764. **
  1765. ** The matrix looks like:
  1766. ** | . . 0 0 |
  1767. ** | . . 0 0 |
  1768. ** | 0 0 . 0 |
  1769. ** | . . . 1 |
  1770. */
  1771. void FASTCALL __glXForm2_2DW(__GLcoord *res, const __GLfloat v[2],
  1772. const __GLmatrix *m)
  1773. {
  1774. __GLXFORM2_2DW_INIT(v)
  1775. __GLXFORM2_2DW(res);
  1776. }
  1777. #endif /* !__GL_ASM_XFORM2_2DW */
  1778. #ifndef __GL_ASM_XFORM2_2DWBATCH
  1779. __GLXFORM_BATCH (__glXForm2_2DWBatch, __GLXFORM2_2DW_INIT, __GLXFORM2_2DW, __GLXFORM2_CONT);
  1780. #endif /* !__GL_ASM_XFORM2_2DWBATCH */
  1781. #ifndef __GL_ASM_XFORM3_2DW
  1782. /*
  1783. ** Avoid some transformation computations by knowing that the incoming
  1784. ** vertex has w=1.
  1785. **
  1786. ** The matrix looks like:
  1787. ** | . . 0 0 |
  1788. ** | . . 0 0 |
  1789. ** | 0 0 . 0 |
  1790. ** | . . . 1 |
  1791. */
  1792. void FASTCALL __glXForm3_2DW(__GLcoord *res, const __GLfloat v[3],
  1793. const __GLmatrix *m)
  1794. {
  1795. __GLXFORM3_2DW_INIT(v)
  1796. __GLXFORM3_2DW(res);
  1797. }
  1798. #endif /* !__GL_ASM_XFORM3_2DW */
  1799. #ifndef __GL_ASM_XFORM3_2DWBATCH
  1800. __GLXFORM_BATCH (__glXForm3_2DWBatch, __GLXFORM3_2DW_INIT, __GLXFORM3_2DW, __GLXFORM3_CONT);
  1801. #endif /* !__GL_ASM_XFORM3_2DWBATCH */
  1802. #ifndef __GL_ASM_XFORM4_2DW
  1803. /*
  1804. ** Full 4x4 transformation.
  1805. **
  1806. ** The matrix looks like:
  1807. ** | . . 0 0 |
  1808. ** | . . 0 0 |
  1809. ** | 0 0 . 0 |
  1810. ** | . . . 1 |
  1811. */
  1812. void FASTCALL __glXForm4_2DW(__GLcoord *res, const __GLfloat v[4],
  1813. const __GLmatrix *m)
  1814. {
  1815. __GLXFORM4_2DW_INIT(v)
  1816. __GLXFORM4_2DW(res);
  1817. }
  1818. #endif /* !__GL_ASM_XFORM4_2DW */
  1819. #ifndef __GL_ASM_XFORM4_2DWBATCH
  1820. __GLXFORM_BATCH (__glXForm4_2DWBatch, __GLXFORM4_2DW_INIT, __GLXFORM4_2DW, __GLXFORM4_CONT);
  1821. #endif /* !__GL_ASM_XFORM4_2DWBATCH */
  1822. #ifndef __GL_ASM_XFORM1_2DNRW
  1823. /*
  1824. ** Avoid some transformation computations by knowing that the incoming
  1825. ** vertex has y=0, z=0 and w=1.
  1826. **
  1827. ** The matrix looks like:
  1828. ** | . 0 0 0 |
  1829. ** | 0 . 0 0 |
  1830. ** | 0 0 . 0 |
  1831. ** | . . . 1 |
  1832. */
  1833. void FASTCALL __glXForm1_2DNRW(__GLcoord *res, const __GLfloat v[1], const __GLmatrix *m)
  1834. {
  1835. __GLXFORM1_2DNRW_INIT(v)
  1836. __GLXFORM1_2DNRW(res);
  1837. }
  1838. #endif /* !__GL_ASM_XFORM1_2DNRW */
  1839. #ifndef __GL_ASM_XFORM1_2DNRWBATCH
  1840. __GLXFORM_BATCH (__glXForm1_2DNRWBatch, __GLXFORM1_2DNRW_INIT, __GLXFORM1_2DNRW, __GLXFORM1_CONT);
  1841. #endif /* !__GL_ASM_XFORM1_2DNRWBATCH */
  1842. #ifndef __GL_ASM_XFORM2_2DNRW
  1843. /*
  1844. ** Avoid some transformation computations by knowing that the incoming
  1845. ** vertex has z=0 and w=1.
  1846. **
  1847. ** The matrix looks like:
  1848. ** | . 0 0 0 |
  1849. ** | 0 . 0 0 |
  1850. ** | 0 0 . 0 |
  1851. ** | . . . 1 |
  1852. */
  1853. void FASTCALL __glXForm2_2DNRW(__GLcoord *res, const __GLfloat v[2],
  1854. const __GLmatrix *m)
  1855. {
  1856. __GLXFORM2_2DNRW_INIT(v)
  1857. __GLXFORM2_2DNRW(res);
  1858. }
  1859. #endif /* !__GL_ASM_XFORM2_2DNRW */
  1860. #ifndef __GL_ASM_XFORM2_2DNRWBATCH
  1861. __GLXFORM_BATCH (__glXForm2_2DNRWBatch, __GLXFORM2_2DNRW_INIT, __GLXFORM2_2DNRW, __GLXFORM2_CONT);
  1862. #endif /* !__GL_ASM_XFORM2_2DNRWBATCH */
  1863. #ifndef __GL_ASM_XFORM3_2DNRW
  1864. /*
  1865. ** Avoid some transformation computations by knowing that the incoming
  1866. ** vertex has w=1.
  1867. **
  1868. ** The matrix looks like:
  1869. ** | . 0 0 0 |
  1870. ** | 0 . 0 0 |
  1871. ** | 0 0 . 0 |
  1872. ** | . . . 1 |
  1873. */
  1874. void FASTCALL __glXForm3_2DNRW(__GLcoord *res, const __GLfloat v[3],
  1875. const __GLmatrix *m)
  1876. {
  1877. __GLXFORM3_2DNRW_INIT(v)
  1878. __GLXFORM3_2DNRW(res);
  1879. }
  1880. #endif /* !__GL_ASM_XFORM3_2DNRW */
  1881. #ifndef __GL_ASM_XFORM3_2DNRWBATCH
  1882. __GLXFORM_BATCH (__glXForm3_2DNRWBatch, __GLXFORM3_2DNRW_INIT, __GLXFORM3_2DNRW, __GLXFORM3_CONT);
  1883. #endif /* !__GL_ASM_XFORM3_2DNRWBATCH */
  1884. #ifndef __GL_ASM_XFORM4_2DNRW
  1885. /*
  1886. ** Full 4x4 transformation.
  1887. **
  1888. ** The matrix looks like:
  1889. ** | . 0 0 0 |
  1890. ** | 0 . 0 0 |
  1891. ** | 0 0 . 0 |
  1892. ** | . . . 1 |
  1893. */
  1894. void FASTCALL __glXForm4_2DNRW(__GLcoord *res, const __GLfloat v[4],
  1895. const __GLmatrix *m)
  1896. {
  1897. __GLXFORM4_2DNRW_INIT(v)
  1898. __GLXFORM4_2DNRW(res);
  1899. }
  1900. #endif /* !__GL_ASM_XFORM4_2DNRW */
  1901. #ifndef __GL_ASM_XFORM4_2DNRWBATCH
  1902. __GLXFORM_BATCH (__glXForm4_2DNRWBatch, __GLXFORM4_2DNRW_INIT, __GLXFORM4_2DNRW, __GLXFORM4_CONT);
  1903. #endif /* !__GL_ASM_XFORM4_2DNRWBATCH */
  1904. #ifndef __GL_ASM_NORMAL_BATCH
  1905. __GLXFORM_NORMAL_BATCH (__glXForm3_2DNRWBatchNormal, __GLXFORM3x3_INIT, __GLXFORM3x3, __GLXFORM3_CONT);
  1906. __GLXFORM_NORMAL_BATCHN(__glXForm3_2DNRWBatchNormalN, __GLXFORM3x3_INIT, __GLXFORM3x3, __GLXFORM3_CONT);
  1907. __GLXFORM_NORMAL_BATCH (__glXForm3_2DWBatchNormal, __GLXFORM3x3_INIT, __GLXFORM3x3, __GLXFORM3_CONT);
  1908. __GLXFORM_NORMAL_BATCHN(__glXForm3_2DWBatchNormalN, __GLXFORM3x3_INIT, __GLXFORM3x3, __GLXFORM3_CONT);
  1909. __GLXFORM_NORMAL_BATCH (__glXForm3x3BatchNormal, __GLXFORM3x3_INIT, __GLXFORM3x3, __GLXFORM3_CONT);
  1910. __GLXFORM_NORMAL_BATCHN(__glXForm3x3BatchNormalN, __GLXFORM3x3_INIT, __GLXFORM3x3, __GLXFORM3_CONT);
  1911. #endif // __GL_ASM_NORMAL_BATCH
  1912. /************************************************************************/
  1913. /*
  1914. ** A special picker for the mvp matrix which picks the mvp matrix, then
  1915. ** calls the vertex picker, because the vertex picker depends upon the mvp
  1916. ** matrix.
  1917. */
  1918. void FASTCALL __glGenericPickMvpMatrixProcs(__GLcontext *gc, __GLmatrix *m)
  1919. {
  1920. __glGenericPickMatrixProcs(gc, m);
  1921. (*gc->procs.pickVertexProcs)(gc);
  1922. }
  1923. void FASTCALL __glGenericPickMatrixProcs(__GLcontext *gc, __GLmatrix *m)
  1924. {
  1925. switch(m->matrixType)
  1926. {
  1927. case __GL_MT_GENERAL:
  1928. m->xf1 = __glXForm1;
  1929. m->xf2 = __glXForm2;
  1930. m->xf3 = __glXForm3;
  1931. m->xf4 = __glXForm4;
  1932. m->xfNorm = __glXForm3x3;
  1933. m->xf1Batch = __glXForm1Batch;
  1934. m->xf2Batch = __glXForm2Batch;
  1935. m->xf3Batch = __glXForm3Batch;
  1936. m->xf4Batch = __glXForm4Batch;
  1937. m->xfNormBatch = __glXForm3x3BatchNormal;
  1938. m->xfNormBatchN = __glXForm3x3BatchNormalN;
  1939. break;
  1940. case __GL_MT_W0001:
  1941. m->xf1 = __glXForm1_W;
  1942. m->xf2 = __glXForm2_W;
  1943. m->xf3 = __glXForm3_W;
  1944. m->xf4 = __glXForm4_W;
  1945. m->xfNorm = __glXForm3x3;
  1946. m->xf1Batch = __glXForm1_WBatch;
  1947. m->xf2Batch = __glXForm2_WBatch;
  1948. m->xf3Batch = __glXForm3_WBatch;
  1949. m->xf4Batch = __glXForm4_WBatch;
  1950. m->xfNormBatch = __glXForm3x3BatchNormal;
  1951. m->xfNormBatchN = __glXForm3x3BatchNormalN;
  1952. break;
  1953. case __GL_MT_IS2D:
  1954. m->xf1 = __glXForm1_2DW;
  1955. m->xf2 = __glXForm2_2DW;
  1956. m->xf3 = __glXForm3_2DW;
  1957. m->xf4 = __glXForm4_2DW;
  1958. m->xfNorm = __glXForm3_2DW;
  1959. m->xf1Batch = __glXForm1_2DWBatch;
  1960. m->xf2Batch = __glXForm2_2DWBatch;
  1961. m->xf3Batch = __glXForm3_2DWBatch;
  1962. m->xf4Batch = __glXForm4_2DWBatch;
  1963. m->xfNormBatch = __glXForm3_2DWBatchNormal;
  1964. m->xfNormBatchN = __glXForm3_2DWBatchNormalN;
  1965. break;
  1966. case __GL_MT_IS2DNR:
  1967. case __GL_MT_IDENTITY: /* probably never hit */
  1968. // Update __glGenericPickIdentityMatrixProcs if we change __GL_MT_IDENTITY
  1969. // procs!
  1970. m->xf1 = __glXForm1_2DNRW;
  1971. m->xf2 = __glXForm2_2DNRW;
  1972. m->xf3 = __glXForm3_2DNRW;
  1973. m->xf4 = __glXForm4_2DNRW;
  1974. m->xfNorm = __glXForm3_2DNRW;
  1975. m->xf1Batch = __glXForm1_2DNRWBatch;
  1976. m->xf2Batch = __glXForm2_2DNRWBatch;
  1977. m->xf3Batch = __glXForm3_2DNRWBatch;
  1978. m->xf4Batch = __glXForm4_2DNRWBatch;
  1979. m->xfNormBatch = __glXForm3_2DNRWBatchNormal;
  1980. m->xfNormBatchN = __glXForm3_2DNRWBatchNormalN;
  1981. break;
  1982. }
  1983. }