Source code of Windows XP (NT5)
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

181 lines
4.7 KiB

  1. #ifndef __glphong_h_
  2. #define __glphong_h_
  3. #include "types.h"
  4. #ifdef GL_WIN_phong_shading
  5. //Definitions for the phong-flag
  6. #define __GL_PHONG_INV_COLOR_VALID 0x00000001
  7. #define __GL_PHONG_NEED_EYE_XPOLATE 0x00000002
  8. #define __GL_PHONG_NEED_COLOR_XPOLATE 0x00000004
  9. #define __GL_PHONG_ALREADY_SORTED 0x00000010
  10. #define __GL_PHONG_USE_FAST_COLOR 0x00000020
  11. #define __GL_PHONG_USE_SLOW_COLOR 0x00000040
  12. /*
  13. ** Shader record for iterated objects (lines/triangles). This keeps
  14. ** track of all the various deltas needed to rasterize a triangle.
  15. */
  16. /* NOTES:
  17. * -----
  18. * After expanding the shading equation using Taylor's series
  19. * /=======================================\
  20. * | 2 2 |
  21. * | S(x,y) = ax + by + cxy + dx + ey + f |
  22. * \=======================================/
  23. *
  24. * f = S (0, 0) , e = S (0, 0 )
  25. * y
  26. *
  27. * d = S (0, 0) , c = S (0, 0)
  28. * x xy
  29. *
  30. * b = 0.5 * S (0 , 0) , a = 0.5 * S (0, 0)
  31. * yy xx
  32. *
  33. * Compute these in SetInitialPhongParameters
  34. */
  35. /* NOTES on Forward differencing:
  36. * -----------------------------
  37. *
  38. * Along the edge interpolation: delta_x = X (dxdy), delta_y = 1
  39. * -------------------------------------------------------------
  40. * Initial S: S (0, 0) = f (compute in SetInitialPhongParameters, for vert A)
  41. * (Sinit_edge)
  42. * 2
  43. * Initial dS : aX + b + cX + dX + e (compute in FillSubTriangle)
  44. * (dS_edge)
  45. * 2
  46. * Initial ddS (constant) : 2aX + 2cX + 2b (compute in FillSubTriangle)
  47. * (ddS_edge)
  48. *
  49. * Every iteration compute Sinit_span (in FillSubTriangle).
  50. *
  51. *
  52. *
  53. * Along the span interpolation: delta_x = 1, delta_y = 0
  54. * -------------------------------------------------------------
  55. * Initial S: sEdge (compute in FillSubTriangle)
  56. * (Sinit_span)
  57. *
  58. * Initial dS: a(2x+1) + cy + d (compute once in SpanProc)
  59. * (dS_span)
  60. *
  61. * Initial ddS (constant): 2a (compute in SetInitialPhongParameters)
  62. * (ddS_span)
  63. *
  64. * Every iteration compute Color (in SpanProc).
  65. *
  66. */
  67. typedef struct __GLphongPerLightDataRec {
  68. /****** Diffuse Part *****/
  69. GLfloat Dcurr; //current dot-product
  70. GLfloat Ddel;
  71. GLfloat Ddel2;
  72. /****** Specular Part *****/
  73. GLfloat Scurr; //current dot-product
  74. GLfloat Sdel;
  75. GLfloat Sdel2;
  76. #ifdef __JUNKED_CODE
  77. /* Along the edge */
  78. GLfloat DdelEdgeLittle;
  79. GLfloat Ddel2EdgeLittle;
  80. GLfloat DdelEdgeBig;
  81. GLfloat Ddel2EdgeBig;
  82. /* Along the span */
  83. GLfloat DdelSpan;
  84. GLfloat DdelSpanEdgeBig, DdelSpanEdgeLittle;
  85. GLfloat Ddel2Span;
  86. /* Temporary storages during span-generation */
  87. GLfloat D_tmp;
  88. GLfloat Ddel_tmp;
  89. /* Polynomial coefficients */
  90. GLfloat D[6];
  91. /****** Specular Part *****/
  92. GLfloat S_curr; //current dot-product
  93. /* Along the edge */
  94. GLfloat SdelEdgeLittle;
  95. GLfloat Sdel2EdgeLittle;
  96. GLfloat SdelEdgeBig;
  97. GLfloat Sdel2EdgeBig;
  98. /* Along the span */
  99. GLfloat SdelSpan;
  100. GLfloat SdelSpanEdgeBig, SdelSpanEdgeLittle;
  101. GLfloat Sdel2Span;
  102. /* Temporary storages during span-generation */
  103. GLfloat S_tmp;
  104. GLfloat Sdel_tmp;
  105. /* Polynomial coefficients */
  106. GLfloat S[6];
  107. /****** Attenuation Part *****/
  108. /****** Spotlight Part *****/
  109. #endif //__JUNKED_CODE
  110. } __GLphongPerLightData;
  111. typedef struct __GLphongShadeRec {
  112. GLuint flags;
  113. GLint numLights;
  114. /* Normals */
  115. __GLcoord dndx, dndy;
  116. __GLcoord nBig, nLittle;
  117. __GLcoord nCur, nTmp;
  118. /* Eye */
  119. __GLcoord dedx, dedy;
  120. __GLcoord eBig, eLittle;
  121. __GLcoord eCur, eTmp;
  122. /* Face: Whether to use the FRONT or the BACK material */
  123. GLint face;
  124. /* Store the invarient color */
  125. __GLcolor invColor;
  126. /* Temporary storage during span-interpolation of color */
  127. __GLcolor tmpColor;
  128. #ifdef __JUNKED_CODE
  129. /* Tracks the current position wrt to the starting vertex */
  130. __GLcoord cur_pos;
  131. __GLcoord tmp_pos;
  132. #endif //__JUNKED_CODE
  133. /* Per-light data array */
  134. __GLphongPerLightData perLight[8]; //update this to WGL_MAX_NUM_LIGHTS
  135. } __GLphongShader;
  136. extern void FASTCALL __glGenericPickPhongProcs(__GLcontext *gc);
  137. extern void ComputePhongInvarientRGBColor (__GLcontext *gc);
  138. #ifdef GL_WIN_specular_fog
  139. extern __GLfloat ComputeSpecValue (__GLcontext *gc, __GLvertex *vx);
  140. #endif //GL_WIN_specular_fog
  141. #endif //GL_WIN_phong_shading
  142. #endif /* __glphong_h_ */