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.

358 lines
14 KiB

  1. #ifndef _transform_h_
  2. #define _transform_h_
  3. /*
  4. ** Copyright 1991, Silicon Graphics, Inc.
  5. ** All Rights Reserved.
  6. **
  7. ** This is UNPUBLISHED PROPRIETARY SOURCE CODE of Silicon Graphics, Inc.;
  8. ** the contents of this file may not be disclosed to third parties, copied or
  9. ** duplicated in any form, in whole or in part, without the prior written
  10. ** permission of Silicon Graphics, Inc.
  11. **
  12. ** RESTRICTED RIGHTS LEGEND:
  13. ** Use, duplication or disclosure by the Government is subject to restrictions
  14. ** as set forth in subdivision (c)(1)(ii) of the Rights in Technical Data
  15. ** and Computer Software clause at DFARS 252.227-7013, and/or in similar or
  16. ** successor clauses in the FAR, DOD or NASA FAR Supplement. Unpublished -
  17. ** rights reserved under the Copyright Laws of the United States.
  18. **
  19. ** $Revision: 1.18 $
  20. ** $Date: 1993/11/29 20:34:42 $
  21. */
  22. #include "vertex.h"
  23. extern __GLcoord __gl_frustumClipPlanes[6];
  24. extern void FASTCALL __glComputeClipBox(__GLcontext *gc);
  25. extern void FASTCALL __glUpdateDepthRange(__GLcontext *gc);
  26. extern void FASTCALL __glUpdateViewport(__GLcontext *gc);
  27. #ifdef NT
  28. extern void FASTCALL __glUpdateViewportDependents(__GLcontext *gc);
  29. #endif
  30. /*
  31. ** Note:
  32. **
  33. ** Other code assumes that all types >= __GL_MT_IS2D are also 2D
  34. ** Other code assumes that all types >= __GL_MT_W0001 are also W0001
  35. ** Other code assumes that all types >= __GL_MT_IS2DNR are also 2DNR
  36. **
  37. ** These enumerants are exposed to the MCD.
  38. */
  39. #define __GL_MT_GENERAL 0 /* No information */
  40. #define __GL_MT_W0001 1 /* W row looks like 0 0 0 1 */
  41. #define __GL_MT_IS2D 2 /* 2D matrix */
  42. #define __GL_MT_IS2DNR 3 /* 2D non-rotational matrix */
  43. #define __GL_MT_IDENTITY 4 /* Identity */
  44. /*
  45. ** Matrix struct. This contains a 4x4 matrix as well as function
  46. ** pointers used to do a transformation with the matrix. The function
  47. ** pointers are loaded based on the matrix contents attempting to
  48. ** avoid unneccesary computation.
  49. */
  50. // Matrix structure.
  51. typedef struct __GLmatrixBaseRec {
  52. __GLfloat matrix[4][4];
  53. } __GLmatrixBase;
  54. // Projection matrix structure.
  55. typedef struct __GLmatrixPRec {
  56. __GLfloat matrix[4][4];
  57. GLenum matrixType;
  58. } __GLmatrixP;
  59. // Modelview and texture transform structures.
  60. //
  61. // This structure is exposed to the MCD as MCDMATRIX.
  62. struct __GLmatrixRec {
  63. __GLfloat matrix[4][4];
  64. /*
  65. ** matrixType set to general if nothing is known about this matrix.
  66. **
  67. ** matrixType set to __GL_MT_W0001 if it looks like this:
  68. ** | . . . 0 |
  69. ** | . . . 0 |
  70. ** | . . . 0 |
  71. ** | . . . 1 |
  72. **
  73. ** matrixType set to __GL_MT_IS2D if it looks like this:
  74. ** | . . 0 0 |
  75. ** | . . 0 0 |
  76. ** | 0 0 . 0 |
  77. ** | . . . 1 |
  78. **
  79. ** matrixType set to __GL_MT_IS2DNR if it looks like this:
  80. ** | . 0 0 0 |
  81. ** | 0 . 0 0 |
  82. ** | 0 0 . 0 |
  83. ** | . . . 1 |
  84. **
  85. */
  86. GLenum matrixType;
  87. void (FASTCALL *xf1)(__GLcoord *res, const __GLfloat *v, const __GLmatrix *m);
  88. void (FASTCALL *xf2)(__GLcoord *res, const __GLfloat *v, const __GLmatrix *m);
  89. void (FASTCALL *xf3)(__GLcoord *res, const __GLfloat *v, const __GLmatrix *m);
  90. void (FASTCALL *xf4)(__GLcoord *res, const __GLfloat *v, const __GLmatrix *m);
  91. void (FASTCALL *xfNorm)(__GLcoord *res, const __GLfloat *v, const __GLmatrix *m);
  92. void (FASTCALL *xf1Batch)(__GLcoord *start, __GLcoord *end, const __GLmatrix *m);
  93. void (FASTCALL *xf2Batch)(__GLcoord *start, __GLcoord *end, const __GLmatrix *m);
  94. void (FASTCALL *xf3Batch)(__GLcoord *start, __GLcoord *end, const __GLmatrix *m);
  95. void (FASTCALL *xf4Batch)(__GLcoord *start, __GLcoord *end, const __GLmatrix *m);
  96. void (FASTCALL *xfNormBatch) (POLYARRAY *pa, const __GLmatrix *m);
  97. // Transform and normalize
  98. void (FASTCALL *xfNormBatchN)(POLYARRAY *pa, const __GLmatrix *m);
  99. GLboolean nonScaling;
  100. };
  101. extern void FASTCALL __glGenericPickMatrixProcs(__GLcontext *gc, __GLmatrix *m );
  102. extern void FASTCALL __glGenericPickInvTransposeProcs(__GLcontext *gc, __GLmatrix *m );
  103. extern void FASTCALL __glGenericPickMvpMatrixProcs(__GLcontext *gc, __GLmatrix *m );
  104. /************************************************************************/
  105. /*
  106. ** Transform struct. This structure is what the matrix stacks are
  107. ** composed of. inverseTranspose contains the inverse transpose of matrix.
  108. ** For the modelView stack, "mvp" will contain the concatenation of
  109. ** the modelView and current projection matrix (i.e. the multiplication of
  110. ** the two matricies).
  111. **
  112. ** The beginning of this structure is exposed to the MCD as MCDTRANSFORM.
  113. */
  114. // Transform flags
  115. // Used for MCD
  116. #define XFORM_CHANGED 0x00000001
  117. // Internal
  118. #define XFORM_UPDATE_INVERSE 0x00000002
  119. // Modelview transform structure.
  120. struct __GLtransformRec {
  121. __GLmatrix matrix;
  122. __GLmatrix mvp;
  123. GLuint flags;
  124. /* MCDTRANSFORM ends */
  125. /* Sequence number tag for mvp */
  126. GLuint sequence;
  127. __GLmatrix inverseTranspose;
  128. };
  129. // Texture transform structure.
  130. typedef struct __GLtransformTRec {
  131. __GLmatrix matrix;
  132. } __GLtransformT;
  133. // Projection transform structure.
  134. typedef struct __GLtransformPRec {
  135. __GLmatrixP matrix;
  136. /* Sequence number tag for mvp */
  137. GLuint sequence;
  138. } __GLtransformP;
  139. /************************************************************************/
  140. /* Unbias an x,y coordinate */
  141. #define __GL_UNBIAS_X(gc, x) ((x) - (gc)->constants.viewportXAdjust)
  142. #define __GL_UNBIAS_Y(gc, y) ((y) - (gc)->constants.viewportYAdjust)
  143. /*
  144. ** Transformation machinery state. Contains the state needed to transform
  145. ** user coordinates into eye & window coordinates.
  146. */
  147. typedef struct __GLtransformMachineRec {
  148. /*
  149. ** Transformation stack. "modelView" points to the active element in
  150. ** the stack.
  151. */
  152. __GLtransform *modelViewStack;
  153. __GLtransform *modelView;
  154. /*
  155. ** Current projection matrix. Used to transform eye coordinates into
  156. ** NTVP (or clip) coordinates.
  157. */
  158. __GLtransformP *projectionStack;
  159. __GLtransformP *projection;
  160. GLuint projectionSequence;
  161. /*
  162. ** Texture matrix stack.
  163. */
  164. __GLtransformT *textureStack;
  165. __GLtransformT *texture;
  166. /*
  167. ** Temporary verticies used during clipping. These contain verticies
  168. ** that are the result of clipping a polygon edge against a clipping
  169. ** plane. For a convex polygon at most one vertex can be added for
  170. ** each clipping plane.
  171. */
  172. __GLvertex *clipTemp;
  173. __GLvertex *nextClipTemp;
  174. /*
  175. ** The smallest rectangle that is the intersection of the window clip
  176. ** and the scissor clip. If the scissor box is disabled then this
  177. ** is just the window box. Note that the x0,y0 point is inside the
  178. ** box but that the x1,y1 point is just outside the box.
  179. */
  180. GLint clipX0;
  181. GLint clipY0;
  182. GLint clipX1;
  183. GLint clipY1;
  184. /*
  185. ** The viewport translated into offset window coordinates. maxx and maxy
  186. ** are one past the edge (an x coord is in if minx <= x < maxx).
  187. */
  188. GLint minx, miny, maxx, maxy;
  189. /*
  190. ** The same thing expressed as floating point numbers.
  191. */
  192. __GLfloat fminx, fminy, fmaxx, fmaxy;
  193. #ifdef SGI
  194. // Not used.
  195. /*
  196. ** Fast 2D transform state. If the mvp matrix is >= __GL_MT_IS2D, then
  197. ** matrix2D contains the matrix to transform object coordinates directly
  198. ** to window coordinates.
  199. ** Even though this optimization is used on a per implementation basis,
  200. ** this matrix is maintained up to date by the soft code.
  201. */
  202. __GLmatrix matrix2D;
  203. #endif // SGI
  204. /* A flag for fast path triangle rendering.
  205. ** If this flag is set, then the user has created a viewport that
  206. ** fits within the window, and we can make it render fast. If, however,
  207. ** the viewport extends outside the window, we have to be more careful
  208. ** about scissoring.
  209. */
  210. GLboolean reasonableViewport;
  211. } __GLtransformMachine;
  212. extern void __glDoClip(__GLcontext *gc, const __GLvertex *v0,
  213. const __GLvertex *v1, __GLvertex *result, __GLfloat t);
  214. extern void FASTCALL __glDoLoadMatrix(__GLcontext *gc, const __GLfloat m[4][4],
  215. BOOL bIsIdentity);
  216. extern void FASTCALL __glDoMultMatrix(__GLcontext *gc, void *data,
  217. void (FASTCALL *multiply)(__GLcontext *gc, __GLmatrix *m, void *data));
  218. extern void __glDoRotate(__GLcontext *gc, __GLfloat angle, __GLfloat ax,
  219. __GLfloat ay, __GLfloat az);
  220. extern void __glDoScale(__GLcontext *gc, __GLfloat x, __GLfloat y, __GLfloat z);
  221. extern void __glDoTranslate(__GLcontext *gc, __GLfloat x, __GLfloat y,
  222. __GLfloat z);
  223. extern void FASTCALL __glComputeInverseTranspose(__GLcontext *gc, __GLtransform *tr);
  224. /*
  225. ** Matrix routines.
  226. */
  227. extern void FASTCALL __glCopyMatrix(__GLmatrix *dst, const __GLmatrix *src);
  228. extern void FASTCALL __glInvertTransposeMatrix(__GLmatrix *dst, const __GLmatrix *src);
  229. extern void FASTCALL __glMakeIdentity(__GLmatrix *result);
  230. extern void FASTCALL __glMultMatrix(__GLmatrix *result, const __GLmatrix *a,
  231. const __GLmatrix *b);
  232. extern void __glTranspose3x3(__GLmatrix *dst, __GLmatrix *src);
  233. /*
  234. ** Miscellaneous routines.
  235. */
  236. extern void FASTCALL __glNormalize(__GLfloat dst[3], const __GLfloat src[3]);
  237. extern void FASTCALL __glNormalizeBatch(POLYARRAY* pa);
  238. /************************************************************************/
  239. extern void FASTCALL __glPushModelViewMatrix(__GLcontext *gc);
  240. extern void FASTCALL __glPopModelViewMatrix(__GLcontext *gc);
  241. extern void FASTCALL __glLoadIdentityModelViewMatrix(__GLcontext *gc);
  242. extern void FASTCALL __glPushProjectionMatrix(__GLcontext *gc);
  243. extern void FASTCALL __glPopProjectionMatrix(__GLcontext *gc);
  244. extern void FASTCALL __glLoadIdentityProjectionMatrix(__GLcontext *gc);
  245. extern void FASTCALL __glPushTextureMatrix(__GLcontext *gc);
  246. extern void FASTCALL __glPopTextureMatrix(__GLcontext *gc);
  247. extern void FASTCALL __glLoadIdentityTextureMatrix(__GLcontext *gc);
  248. /*
  249. ** Xforming routines.
  250. */
  251. void FASTCALL __glXForm4_2DNRW(__GLcoord *res, const __GLfloat v[4],
  252. const __GLmatrix *m);
  253. void FASTCALL __glXForm3_2DNRW(__GLcoord *res, const __GLfloat v[3],
  254. const __GLmatrix *m);
  255. void FASTCALL __glXForm4_2DW(__GLcoord *res, const __GLfloat v[4],
  256. const __GLmatrix *m);
  257. void FASTCALL __glXForm3_2DW(__GLcoord *res, const __GLfloat v[3],
  258. const __GLmatrix *m);
  259. #ifndef __GL_USEASMCODE
  260. void FASTCALL __glXForm4_W(__GLcoord *res, const __GLfloat v[4], const __GLmatrix *m);
  261. void FASTCALL __glXForm3x3(__GLcoord *res, const __GLfloat v[3], const __GLmatrix *m);
  262. void FASTCALL __glXForm3_W(__GLcoord *res, const __GLfloat v[3], const __GLmatrix *m);
  263. void FASTCALL __glXForm2_W(__GLcoord *res, const __GLfloat v[2], const __GLmatrix *m);
  264. void FASTCALL __glXForm4(__GLcoord *res, const __GLfloat v[4], const __GLmatrix *m);
  265. void FASTCALL __glXForm3(__GLcoord *res, const __GLfloat v[3], const __GLmatrix *m);
  266. void FASTCALL __glXForm2(__GLcoord *res, const __GLfloat v[2], const __GLmatrix *m);
  267. void FASTCALL __glXForm2_2DW(__GLcoord *res, const __GLfloat v[2],
  268. const __GLmatrix *m);
  269. void FASTCALL __glXForm2_2DNRW(__GLcoord *res, const __GLfloat v[2],
  270. const __GLmatrix *m);
  271. #endif /* !__GL_USEASMCODE */
  272. void FASTCALL __glXForm1_W(__GLcoord *res, const __GLfloat v[1], const __GLmatrix *m);
  273. void FASTCALL __glXForm1(__GLcoord *res, const __GLfloat v[1], const __GLmatrix *m);
  274. void FASTCALL __glXForm1_2DW(__GLcoord *res, const __GLfloat v[1],
  275. const __GLmatrix *m);
  276. void FASTCALL __glXForm1_2DNRW(__GLcoord *res, const __GLfloat v[1],
  277. const __GLmatrix *m);
  278. /*
  279. ** Batched versions of the above routines.
  280. */
  281. void FASTCALL __glXForm4_2DNRWBatch(__GLcoord *start, __GLcoord *end, const __GLmatrix *m);
  282. void FASTCALL __glXForm3_2DNRWBatch(__GLcoord *start, __GLcoord *end, const __GLmatrix *m);
  283. void FASTCALL __glXForm4_2DWBatch(__GLcoord *start, __GLcoord *end, const __GLmatrix *m);
  284. void FASTCALL __glXForm3_2DWBatch(__GLcoord *start, __GLcoord *end, const __GLmatrix *m);
  285. #ifndef __GL_USEASMCODE
  286. void FASTCALL __glXForm4_WBatch(__GLcoord *start, __GLcoord *end, const __GLmatrix *m);
  287. void FASTCALL __glXForm3x3Batch(__GLcoord *start, __GLcoord *end, const __GLmatrix *m);
  288. void FASTCALL __glXForm3_WBatch(__GLcoord *start, __GLcoord *end, const __GLmatrix *m);
  289. void FASTCALL __glXForm2_WBatch(__GLcoord *start, __GLcoord *end, const __GLmatrix *m);
  290. void FASTCALL __glXForm4Batch(__GLcoord *start, __GLcoord *end, const __GLmatrix *m);
  291. void FASTCALL __glXForm3Batch(__GLcoord *start, __GLcoord *end, const __GLmatrix *m);
  292. void FASTCALL __glXForm2Batch(__GLcoord *start, __GLcoord *end, const __GLmatrix *m);
  293. void FASTCALL __glXForm2_2DWBatch(__GLcoord *start, __GLcoord *end, const __GLmatrix *m);
  294. void FASTCALL __glXForm2_2DNRWBatch(__GLcoord *start, __GLcoord *end, const __GLmatrix *m);
  295. #endif /* !__GL_USEASMCODE */
  296. void FASTCALL __glXForm1_WBatch(__GLcoord *start, __GLcoord *end, const __GLmatrix *m);
  297. void FASTCALL __glXForm1Batch(__GLcoord *start, __GLcoord *end, const __GLmatrix *m);
  298. void FASTCALL __glXForm1_2DWBatch(__GLcoord *start, __GLcoord *end, const __GLmatrix *m);
  299. void FASTCALL __glXForm1_2DNRWBatch(__GLcoord *start, __GLcoord *end, const __GLmatrix *m);
  300. // Transformations for normals
  301. //
  302. void FASTCALL __glXForm3_2DNRWBatchNormal (POLYARRAY *pa, const __GLmatrix *m);
  303. void FASTCALL __glXForm3_2DNRWBatchNormalN (POLYARRAY *pa, const __GLmatrix *m);
  304. void FASTCALL __glXForm3_2DWBatchNormal (POLYARRAY *pa, const __GLmatrix *m);
  305. void FASTCALL __glXForm3_2DWBatchNormalN (POLYARRAY *pa, const __GLmatrix *m);
  306. void FASTCALL __glXForm3x3BatchNormal (POLYARRAY *pa, const __GLmatrix *m);
  307. void FASTCALL __glXForm3x3BatchNormalN (POLYARRAY *pa, const __GLmatrix *m);
  308. #endif