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.

197 lines
5.3 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. ** $Revision: 1.12 $
  18. ** $Date: 1993/10/07 18:57:21 $
  19. */
  20. #include "precomp.h"
  21. #pragma hdrstop
  22. #include <fixed.h>
  23. void FASTCALL __glRenderAliasedPoint1_NoTex(__GLcontext *gc, __GLvertex *vx)
  24. {
  25. __GLfragment frag;
  26. frag.x = __GL_VERTEX_FLOAT_TO_INT(vx->window.x);
  27. frag.y = __GL_VERTEX_FLOAT_TO_INT(vx->window.y);
  28. frag.z = (__GLzValue)FTOL(vx->window.z);
  29. /*
  30. ** Compute the color
  31. */
  32. frag.color = *vx->color;
  33. /*
  34. ** Fog if enabled
  35. */
  36. if ((gc->polygon.shader.modeFlags & __GL_SHADE_CHEAP_FOG) &&
  37. !(gc->polygon.shader.modeFlags & __GL_SHADE_SMOOTH_LIGHT))
  38. {
  39. (*gc->procs.fogColor)(gc, &frag.color, &frag.color, vx->fog);
  40. }
  41. else if (gc->polygon.shader.modeFlags & __GL_SHADE_SLOW_FOG)
  42. {
  43. (*gc->procs.fogPoint)(gc, &frag, vx->eyeZ);
  44. }
  45. /* Render the single point */
  46. (*gc->procs.store)(gc->drawBuffer, &frag);
  47. }
  48. void FASTCALL __glRenderAliasedPoint1(__GLcontext *gc, __GLvertex *vx)
  49. {
  50. __GLfragment frag;
  51. GLuint modeFlags = gc->polygon.shader.modeFlags;
  52. frag.x = __GL_VERTEX_FLOAT_TO_INT(vx->window.x);
  53. frag.y = __GL_VERTEX_FLOAT_TO_INT(vx->window.y);
  54. frag.z = (__GLzValue)FTOL(vx->window.z);
  55. /*
  56. ** Compute the color
  57. */
  58. frag.color = *vx->color;
  59. if (modeFlags & __GL_SHADE_TEXTURE) {
  60. __GLfloat qInv = (vx->texture.w == (__GLfloat) 0.0) ? (__GLfloat) 0.0 : __glOne / vx->texture.w;
  61. (*gc->procs.texture)(gc, &frag.color, vx->texture.x * qInv,
  62. vx->texture.y * qInv, __glOne);
  63. }
  64. /*
  65. ** Fog if enabled
  66. */
  67. if (modeFlags & __GL_SHADE_COMPUTE_FOG)
  68. {
  69. (*gc->procs.fogPoint)(gc, &frag, vx->eyeZ);
  70. }
  71. else if ((modeFlags & __GL_SHADE_INTERP_FOG)
  72. ||
  73. (((modeFlags & (__GL_SHADE_CHEAP_FOG | __GL_SHADE_SMOOTH_LIGHT))
  74. == __GL_SHADE_CHEAP_FOG)))
  75. {
  76. (*gc->procs.fogColor)(gc, &frag.color, &frag.color, vx->fog);
  77. }
  78. /* Render the single point */
  79. (*gc->procs.store)(gc->drawBuffer, &frag);
  80. }
  81. void FASTCALL __glRenderAliasedPointN(__GLcontext *gc, __GLvertex *vx)
  82. {
  83. GLint pointSize, pointSizeHalf, ix, iy, xLeft, xRight, yBottom, yTop;
  84. __GLfragment frag;
  85. GLuint modeFlags = gc->polygon.shader.modeFlags;
  86. __GLfloat tmp;
  87. /*
  88. ** Compute the x and y starting coordinates for rendering the square.
  89. */
  90. pointSize = gc->state.point.aliasedSize;
  91. pointSizeHalf = pointSize >> 1;
  92. if (pointSize & 1) {
  93. /* odd point size */
  94. xLeft = __GL_VERTEX_FLOAT_TO_INT(vx->window.x) - pointSizeHalf;
  95. yBottom = __GL_VERTEX_FLOAT_TO_INT(vx->window.y) - pointSizeHalf;
  96. } else {
  97. /* even point size */
  98. tmp = vx->window.x+__glHalf;
  99. xLeft = __GL_VERTEX_FLOAT_TO_INT(tmp) - pointSizeHalf;
  100. tmp = vx->window.y+__glHalf;
  101. yBottom = __GL_VERTEX_FLOAT_TO_INT(tmp) - pointSizeHalf;
  102. }
  103. xRight = xLeft + pointSize;
  104. yTop = yBottom + pointSize;
  105. /*
  106. ** Compute the color
  107. */
  108. frag.color = *vx->color;
  109. if (modeFlags & __GL_SHADE_TEXTURE) {
  110. __GLfloat qInv = __glOne / vx->texture.w;
  111. (*gc->procs.texture)(gc, &frag.color, vx->texture.x * qInv,
  112. vx->texture.y * qInv, __glOne);
  113. }
  114. /*
  115. ** Fog if enabled
  116. */
  117. if (modeFlags & __GL_SHADE_COMPUTE_FOG)
  118. {
  119. (*gc->procs.fogPoint)(gc, &frag, vx->eyeZ);
  120. }
  121. else if ((modeFlags & __GL_SHADE_INTERP_FOG)
  122. ||
  123. (((modeFlags & (__GL_SHADE_CHEAP_FOG | __GL_SHADE_SMOOTH_LIGHT))
  124. == __GL_SHADE_CHEAP_FOG)))
  125. {
  126. (*gc->procs.fogColor)(gc, &frag.color, &frag.color, vx->fog);
  127. }
  128. /*
  129. ** Now render the square centered on xCenter,yCenter.
  130. */
  131. frag.z = (__GLzValue)FTOL(vx->window.z);
  132. for (iy = yBottom; iy < yTop; iy++) {
  133. for (ix = xLeft; ix < xRight; ix++) {
  134. frag.x = ix;
  135. frag.y = iy;
  136. (*gc->procs.store)(gc->drawBuffer, &frag);
  137. }
  138. }
  139. }
  140. #ifdef __BUGGY_RENDER_POINT
  141. void FASTCALL __glRenderFlatFogPoint(__GLcontext *gc, __GLvertex *vx)
  142. {
  143. __GLcolor *vxocp;
  144. __GLcolor vxcol;
  145. (*gc->procs.fogColor)(gc, &vxcol, vx->color, vx->fog);
  146. vxocp = vx->color;
  147. vx->color = &vxcol;
  148. (*gc->procs.renderPoint2)(gc, vx);
  149. vx->color = vxocp;
  150. }
  151. #ifdef NT
  152. // vx->fog is invalid if it is __GL_SHADE_SLOW_FOG!
  153. void FASTCALL __glRenderFlatFogPointSlow(__GLcontext *gc, __GLvertex *vx)
  154. {
  155. __GLcolor *vxocp;
  156. __GLcolor vxcol;
  157. // compute fog value first!
  158. vx->fog = __glFogVertex(gc, vx);
  159. (*gc->procs.fogColor)(gc, &vxcol, vx->color, vx->fog);
  160. vxocp = vx->color;
  161. vx->color = &vxcol;
  162. (*gc->procs.renderPoint2)(gc, vx);
  163. vx->color = vxocp;
  164. }
  165. #endif
  166. #endif //__BUGGY_RENDER_POINT