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.

250 lines
9.5 KiB

  1. #include "precomp.h"
  2. #pragma hdrstop
  3. void APIPRIVATE __glim_Enable(GLenum cap)
  4. {
  5. __GL_SETUP_NOT_IN_BEGIN();
  6. switch (cap) {
  7. case GL_ALPHA_TEST:
  8. if (gc->state.enables.general & __GL_ALPHA_TEST_ENABLE) return;
  9. gc->state.enables.general |= __GL_ALPHA_TEST_ENABLE;
  10. break;
  11. case GL_BLEND:
  12. if (gc->state.enables.general & __GL_BLEND_ENABLE) return;
  13. gc->state.enables.general |= __GL_BLEND_ENABLE;
  14. break;
  15. case GL_COLOR_MATERIAL:
  16. if (gc->state.enables.general & __GL_COLOR_MATERIAL_ENABLE) return;
  17. gc->state.enables.general |= __GL_COLOR_MATERIAL_ENABLE;
  18. ComputeColorMaterialChange(gc);
  19. (*gc->procs.pickColorMaterialProcs)(gc);
  20. (*gc->procs.applyColor)(gc);
  21. break;
  22. case GL_CULL_FACE:
  23. if (gc->state.enables.general & __GL_CULL_FACE_ENABLE) return;
  24. gc->state.enables.general |= __GL_CULL_FACE_ENABLE;
  25. __GL_DELAY_VALIDATE_MASK(gc, __GL_DIRTY_POLYGON);
  26. #ifdef _MCD_
  27. MCD_STATE_DIRTY(gc, ENABLES);
  28. #endif
  29. return;
  30. case GL_DEPTH_TEST:
  31. if (gc->state.enables.general & __GL_DEPTH_TEST_ENABLE) return;
  32. gc->state.enables.general |= __GL_DEPTH_TEST_ENABLE;
  33. if (gc->modes.depthBits) {
  34. if (!gc->modes.haveDepthBuffer)
  35. LazyAllocateDepth(gc);
  36. // XXX if this fails should we be setting the enable bit?
  37. } else {
  38. gc->state.depth.testFunc = GL_ALWAYS;
  39. #ifdef _MCD_
  40. MCD_STATE_DIRTY(gc, DEPTHTEST);
  41. #endif
  42. }
  43. __GL_DELAY_VALIDATE_MASK(gc, __GL_DIRTY_DEPTH);
  44. break;
  45. case GL_POLYGON_OFFSET_POINT:
  46. if (gc->state.enables.general & __GL_POLYGON_OFFSET_POINT_ENABLE)
  47. return;
  48. gc->state.enables.general |= __GL_POLYGON_OFFSET_POINT_ENABLE;
  49. __GL_DELAY_VALIDATE_MASK(gc, __GL_DIRTY_POINT);
  50. break;
  51. case GL_POLYGON_OFFSET_LINE:
  52. if (gc->state.enables.general & __GL_POLYGON_OFFSET_LINE_ENABLE)
  53. return;
  54. gc->state.enables.general |= __GL_POLYGON_OFFSET_LINE_ENABLE;
  55. __GL_DELAY_VALIDATE_MASK(gc, __GL_DIRTY_LINE);
  56. break;
  57. case GL_POLYGON_OFFSET_FILL:
  58. if (gc->state.enables.general & __GL_POLYGON_OFFSET_FILL_ENABLE)
  59. return;
  60. gc->state.enables.general |= __GL_POLYGON_OFFSET_FILL_ENABLE;
  61. __GL_DELAY_VALIDATE_MASK(gc, __GL_DIRTY_POLYGON);
  62. break;
  63. case GL_DITHER:
  64. if (gc->state.enables.general & __GL_DITHER_ENABLE) return;
  65. gc->state.enables.general |= __GL_DITHER_ENABLE;
  66. break;
  67. #ifdef GL_WIN_specular_fog
  68. case GL_FOG_SPECULAR_TEXTURE_WIN:
  69. if (gc->state.enables.general & __GL_FOG_SPEC_TEX_ENABLE) return;
  70. gc->state.enables.general |= __GL_FOG_SPEC_TEX_ENABLE;
  71. break;
  72. #endif //GL_WIN_specular_fog
  73. case GL_FOG:
  74. if (gc->state.enables.general & __GL_FOG_ENABLE) return;
  75. gc->state.enables.general |= __GL_FOG_ENABLE;
  76. break;
  77. case GL_LIGHTING:
  78. if (gc->state.enables.general & __GL_LIGHTING_ENABLE) return;
  79. gc->state.enables.general |= __GL_LIGHTING_ENABLE;
  80. __GL_DELAY_VALIDATE_MASK(gc, __GL_DIRTY_LIGHTING);
  81. #ifdef _MCD_
  82. MCD_STATE_DIRTY(gc, ENABLES);
  83. #endif
  84. #ifdef NT
  85. ComputeColorMaterialChange(gc);
  86. #endif
  87. (*gc->procs.pickColorMaterialProcs)(gc);
  88. (*gc->procs.applyColor)(gc);
  89. return;
  90. case GL_LINE_SMOOTH:
  91. if (gc->state.enables.general & __GL_LINE_SMOOTH_ENABLE) return;
  92. gc->state.enables.general |= __GL_LINE_SMOOTH_ENABLE;
  93. break;
  94. case GL_LINE_STIPPLE:
  95. if (gc->state.enables.general & __GL_LINE_STIPPLE_ENABLE) return;
  96. gc->state.enables.general |= __GL_LINE_STIPPLE_ENABLE;
  97. __GL_DELAY_VALIDATE_MASK(gc, __GL_DIRTY_LINE);
  98. #ifdef _MCD_
  99. MCD_STATE_DIRTY(gc, ENABLES);
  100. #endif
  101. return;
  102. case GL_INDEX_LOGIC_OP:
  103. if (gc->state.enables.general & __GL_INDEX_LOGIC_OP_ENABLE) return;
  104. gc->state.enables.general |= __GL_INDEX_LOGIC_OP_ENABLE;
  105. break;
  106. case GL_COLOR_LOGIC_OP:
  107. if (gc->state.enables.general & __GL_COLOR_LOGIC_OP_ENABLE) return;
  108. gc->state.enables.general |= __GL_COLOR_LOGIC_OP_ENABLE;
  109. break;
  110. case GL_NORMALIZE:
  111. if (gc->state.enables.general & __GL_NORMALIZE_ENABLE) return;
  112. gc->state.enables.general |= __GL_NORMALIZE_ENABLE;
  113. break;
  114. case GL_POINT_SMOOTH:
  115. if (gc->state.enables.general & __GL_POINT_SMOOTH_ENABLE) return;
  116. gc->state.enables.general |= __GL_POINT_SMOOTH_ENABLE;
  117. break;
  118. case GL_POLYGON_SMOOTH:
  119. if (gc->state.enables.general & __GL_POLYGON_SMOOTH_ENABLE) return;
  120. gc->state.enables.general |= __GL_POLYGON_SMOOTH_ENABLE;
  121. break;
  122. case GL_POLYGON_STIPPLE:
  123. if (gc->state.enables.general & __GL_POLYGON_STIPPLE_ENABLE) return;
  124. gc->state.enables.general |= __GL_POLYGON_STIPPLE_ENABLE;
  125. __GL_DELAY_VALIDATE_MASK(gc, __GL_DIRTY_POLYGON);
  126. #ifdef _MCD_
  127. MCD_STATE_DIRTY(gc, ENABLES);
  128. #endif
  129. return;
  130. case GL_SCISSOR_TEST:
  131. if (gc->state.enables.general & __GL_SCISSOR_TEST_ENABLE) return;
  132. gc->state.enables.general |= __GL_SCISSOR_TEST_ENABLE;
  133. #ifdef NT
  134. #ifdef _MCD_
  135. MCD_STATE_DIRTY(gc, SCISSOR);
  136. #endif
  137. // applyViewport does both
  138. (*gc->procs.applyViewport)(gc);
  139. #else
  140. (*gc->procs.computeClipBox)(gc);
  141. (*gc->procs.applyScissor)(gc);
  142. #endif
  143. break;
  144. case GL_STENCIL_TEST:
  145. if (gc->state.enables.general & __GL_STENCIL_TEST_ENABLE) return;
  146. gc->state.enables.general |= __GL_STENCIL_TEST_ENABLE;
  147. if (!gc->modes.haveStencilBuffer && gc->modes.stencilBits) {
  148. LazyAllocateStencil(gc);
  149. // XXX if this fails should we be setting the enable bit?
  150. }
  151. break;
  152. case GL_TEXTURE_1D:
  153. if (gc->state.enables.general & __GL_TEXTURE_1D_ENABLE) return;
  154. gc->state.enables.general |= __GL_TEXTURE_1D_ENABLE;
  155. break;
  156. case GL_TEXTURE_2D:
  157. if (gc->state.enables.general & __GL_TEXTURE_2D_ENABLE) return;
  158. gc->state.enables.general |= __GL_TEXTURE_2D_ENABLE;
  159. break;
  160. case GL_AUTO_NORMAL:
  161. if (gc->state.enables.general & __GL_AUTO_NORMAL_ENABLE) return;
  162. gc->state.enables.general |= __GL_AUTO_NORMAL_ENABLE;
  163. break;
  164. case GL_TEXTURE_GEN_S:
  165. if (gc->state.enables.general & __GL_TEXTURE_GEN_S_ENABLE) return;
  166. gc->state.enables.general |= __GL_TEXTURE_GEN_S_ENABLE;
  167. break;
  168. case GL_TEXTURE_GEN_T:
  169. if (gc->state.enables.general & __GL_TEXTURE_GEN_T_ENABLE) return;
  170. gc->state.enables.general |= __GL_TEXTURE_GEN_T_ENABLE;
  171. break;
  172. case GL_TEXTURE_GEN_R:
  173. if (gc->state.enables.general & __GL_TEXTURE_GEN_R_ENABLE) return;
  174. gc->state.enables.general |= __GL_TEXTURE_GEN_R_ENABLE;
  175. break;
  176. case GL_TEXTURE_GEN_Q:
  177. if (gc->state.enables.general & __GL_TEXTURE_GEN_Q_ENABLE) return;
  178. gc->state.enables.general |= __GL_TEXTURE_GEN_Q_ENABLE;
  179. break;
  180. #ifdef GL_WIN_multiple_textures
  181. case GL_TEXCOMBINE_CLAMP_WIN:
  182. if (gc->state.enables.general & __GL_TEXCOMBINE_CLAMP_ENABLE)
  183. {
  184. return;
  185. }
  186. gc->state.enables.general |= __GL_TEXCOMBINE_CLAMP_ENABLE;
  187. break;
  188. #endif // GL_WIN_multiple_textures
  189. #ifdef GL_EXT_flat_paletted_lighting
  190. case GL_PALETTED_LIGHTING_EXT:
  191. gc->state.enables.general |= __GL_PALETTED_LIGHTING_ENABLE;
  192. break;
  193. #endif
  194. case GL_CLIP_PLANE0: case GL_CLIP_PLANE1:
  195. case GL_CLIP_PLANE2: case GL_CLIP_PLANE3:
  196. case GL_CLIP_PLANE4: case GL_CLIP_PLANE5:
  197. cap -= GL_CLIP_PLANE0;
  198. if (gc->state.enables.clipPlanes & (1 << cap)) return;
  199. gc->state.enables.clipPlanes |= (1 << cap);
  200. #ifdef _MCD_
  201. MCD_STATE_DIRTY(gc, CLIPCTRL);
  202. #endif
  203. break;
  204. case GL_LIGHT0: case GL_LIGHT1:
  205. case GL_LIGHT2: case GL_LIGHT3:
  206. case GL_LIGHT4: case GL_LIGHT5:
  207. case GL_LIGHT6: case GL_LIGHT7:
  208. cap -= GL_LIGHT0;
  209. if (gc->state.enables.lights & (1 << cap)) return;
  210. gc->state.enables.lights |= (1 << cap);
  211. __GL_DELAY_VALIDATE_MASK(gc, __GL_DIRTY_LIGHTING);
  212. MCD_STATE_DIRTY(gc, LIGHTS);
  213. return;
  214. case GL_MAP1_COLOR_4:
  215. case GL_MAP1_NORMAL:
  216. case GL_MAP1_INDEX:
  217. case GL_MAP1_TEXTURE_COORD_1: case GL_MAP1_TEXTURE_COORD_2:
  218. case GL_MAP1_TEXTURE_COORD_3: case GL_MAP1_TEXTURE_COORD_4:
  219. case GL_MAP1_VERTEX_3: case GL_MAP1_VERTEX_4:
  220. cap = __GL_EVAL1D_INDEX(cap);
  221. if (gc->state.enables.eval1 & (GLushort) (1 << cap)) return;
  222. gc->state.enables.eval1 |= (GLushort) (1 << cap);
  223. break;
  224. case GL_MAP2_COLOR_4:
  225. case GL_MAP2_NORMAL:
  226. case GL_MAP2_INDEX:
  227. case GL_MAP2_TEXTURE_COORD_1: case GL_MAP2_TEXTURE_COORD_2:
  228. case GL_MAP2_TEXTURE_COORD_3: case GL_MAP2_TEXTURE_COORD_4:
  229. case GL_MAP2_VERTEX_3: case GL_MAP2_VERTEX_4:
  230. cap = __GL_EVAL2D_INDEX(cap);
  231. if (gc->state.enables.eval2 & (GLushort) (1 << cap)) return;
  232. gc->state.enables.eval2 |= (GLushort) (1 << cap);
  233. break;
  234. default:
  235. __glSetError(GL_INVALID_ENUM);
  236. return;
  237. }
  238. __GL_DELAY_VALIDATE(gc);
  239. #ifdef _MCD_
  240. MCD_STATE_DIRTY(gc, ENABLES);
  241. #endif
  242. }