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.

265 lines
6.7 KiB

  1. #include <glos.h>
  2. #include <GL/gl.h>
  3. #include <GL/glu.h>
  4. #include "glimport.h"
  5. #include "glrender.h"
  6. #include "nurbscon.h"
  7. GLUnurbs *gluNewNurbsRenderer(void)
  8. {
  9. GLUnurbs *t;
  10. t = new GLUnurbs;
  11. return t;
  12. }
  13. void gluDeleteNurbsRenderer(GLUnurbs *r)
  14. {
  15. delete r;
  16. }
  17. void gluBeginSurface(GLUnurbs *r)
  18. {
  19. r->bgnsurface(0);
  20. }
  21. void gluBeginCurve(GLUnurbs *r)
  22. {
  23. r->bgncurve(0);
  24. }
  25. void gluEndCurve(GLUnurbs *r)
  26. {
  27. r->endcurve();
  28. }
  29. void gluEndSurface(GLUnurbs *r)
  30. {
  31. r->endsurface();
  32. }
  33. void gluBeginTrim(GLUnurbs *r)
  34. {
  35. r->bgntrim();
  36. }
  37. void gluEndTrim(GLUnurbs *r)
  38. {
  39. r->endtrim();
  40. }
  41. void gluPwlCurve(GLUnurbs *r, GLint count, INREAL array[],
  42. GLint stride, GLenum type)
  43. {
  44. GLenum realType;
  45. switch(type) {
  46. case GLU_MAP1_TRIM_2:
  47. realType = N_P2D;
  48. break;
  49. case GLU_MAP1_TRIM_3:
  50. realType = N_P2DR;
  51. break;
  52. default:
  53. realType = type;
  54. break;
  55. }
  56. r->pwlcurve(count, array, sizeof(INREAL) * stride, realType);
  57. }
  58. void gluNurbsCurve(GLUnurbs *r, GLint nknots, INREAL knot[], GLint stride,
  59. INREAL ctlarray[], GLint order, GLenum type)
  60. {
  61. GLenum realType;
  62. switch(type) {
  63. case GLU_MAP1_TRIM_2:
  64. realType = N_P2D;
  65. break;
  66. case GLU_MAP1_TRIM_3:
  67. realType = N_P2DR;
  68. break;
  69. default:
  70. realType = type;
  71. break;
  72. }
  73. r->nurbscurve(nknots, knot, sizeof(INREAL) * stride, ctlarray, order,
  74. realType);
  75. }
  76. void gluNurbsSurface(GLUnurbs *r, GLint sknot_count, GLfloat *sknot,
  77. GLint tknot_count, GLfloat *tknot,
  78. GLint s_stride, GLint t_stride,
  79. GLfloat *ctlarray, GLint sorder, GLint torder,
  80. GLenum type)
  81. {
  82. r->nurbssurface(sknot_count, sknot, tknot_count, tknot,
  83. sizeof(INREAL) * s_stride, sizeof(INREAL) * t_stride,
  84. ctlarray, sorder, torder, type);
  85. }
  86. void gluLoadSamplingMatrices(GLUnurbs *r, const GLfloat modelMatrix[16],
  87. const GLfloat projMatrix[16],
  88. const GLint viewport[4])
  89. {
  90. #ifdef NT
  91. r->useGLMatrices((float (*)[4])modelMatrix, (float (*)[4])projMatrix, viewport);
  92. #else
  93. r->useGLMatrices(modelMatrix, projMatrix, viewport);
  94. #endif
  95. }
  96. void gluNurbsProperty(GLUnurbs *r, GLenum property, GLfloat value)
  97. {
  98. GLfloat nurbsValue;
  99. switch (property) {
  100. case GLU_AUTO_LOAD_MATRIX:
  101. r->setautoloadmode(value);
  102. return;
  103. case GLU_CULLING:
  104. if (value != 0.0) {
  105. nurbsValue = N_CULLINGON;
  106. } else {
  107. nurbsValue = N_NOCULLING;
  108. }
  109. r->setnurbsproperty(GL_MAP2_VERTEX_3, N_CULLING, nurbsValue);
  110. r->setnurbsproperty(GL_MAP2_VERTEX_4, N_CULLING, nurbsValue);
  111. r->setnurbsproperty(GL_MAP1_VERTEX_3, N_CULLING, nurbsValue);
  112. r->setnurbsproperty(GL_MAP1_VERTEX_4, N_CULLING, nurbsValue);
  113. return;
  114. case GLU_SAMPLING_METHOD:
  115. if (value == GLU_PATH_LENGTH) {
  116. nurbsValue = N_PATHLENGTH;
  117. } else if (value == GLU_PARAMETRIC_ERROR) {
  118. nurbsValue = N_PARAMETRICDISTANCE;
  119. } else if (value == GLU_DOMAIN_DISTANCE) {
  120. nurbsValue = N_DOMAINDISTANCE;
  121. } else {
  122. r->postError(GLU_INVALID_VALUE);
  123. return;
  124. }
  125. r->setnurbsproperty(GL_MAP2_VERTEX_3, N_SAMPLINGMETHOD, nurbsValue);
  126. r->setnurbsproperty(GL_MAP2_VERTEX_4, N_SAMPLINGMETHOD, nurbsValue);
  127. r->setnurbsproperty(GL_MAP1_VERTEX_3, N_SAMPLINGMETHOD, nurbsValue);
  128. r->setnurbsproperty(GL_MAP1_VERTEX_4, N_SAMPLINGMETHOD, nurbsValue);
  129. return;
  130. case GLU_SAMPLING_TOLERANCE:
  131. r->setnurbsproperty(GL_MAP2_VERTEX_3, N_PIXEL_TOLERANCE, value);
  132. r->setnurbsproperty(GL_MAP2_VERTEX_4, N_PIXEL_TOLERANCE, value);
  133. r->setnurbsproperty(GL_MAP1_VERTEX_3, N_PIXEL_TOLERANCE, value);
  134. r->setnurbsproperty(GL_MAP1_VERTEX_4, N_PIXEL_TOLERANCE, value);
  135. return;
  136. case GLU_PARAMETRIC_TOLERANCE:
  137. r->setnurbsproperty(GL_MAP2_VERTEX_3, N_ERROR_TOLERANCE, value);
  138. r->setnurbsproperty(GL_MAP2_VERTEX_4, N_ERROR_TOLERANCE, value);
  139. r->setnurbsproperty(GL_MAP1_VERTEX_3, N_ERROR_TOLERANCE, value);
  140. r->setnurbsproperty(GL_MAP1_VERTEX_4, N_ERROR_TOLERANCE, value);
  141. return;
  142. case GLU_DISPLAY_MODE:
  143. if (value == GLU_FILL) {
  144. nurbsValue = N_FILL;
  145. } else if (value == GLU_OUTLINE_POLYGON) {
  146. nurbsValue = N_OUTLINE_POLY;
  147. } else if (value == GLU_OUTLINE_PATCH) {
  148. nurbsValue = N_OUTLINE_PATCH;
  149. } else {
  150. r->postError(GLU_INVALID_VALUE);
  151. return;
  152. }
  153. r->setnurbsproperty(N_DISPLAY, nurbsValue);
  154. break;
  155. case GLU_U_STEP:
  156. r->setnurbsproperty(GL_MAP1_VERTEX_3, N_S_STEPS, value);
  157. r->setnurbsproperty(GL_MAP1_VERTEX_4, N_S_STEPS, value);
  158. r->setnurbsproperty(GL_MAP2_VERTEX_3, N_S_STEPS, value);
  159. r->setnurbsproperty(GL_MAP2_VERTEX_4, N_S_STEPS, value);
  160. break;
  161. case GLU_V_STEP:
  162. r->setnurbsproperty(GL_MAP1_VERTEX_3, N_T_STEPS, value);
  163. r->setnurbsproperty(GL_MAP1_VERTEX_4, N_T_STEPS, value);
  164. r->setnurbsproperty(GL_MAP2_VERTEX_3, N_T_STEPS, value);
  165. r->setnurbsproperty(GL_MAP2_VERTEX_4, N_T_STEPS, value);
  166. break;
  167. default:
  168. r->postError(GLU_INVALID_ENUM);
  169. return;
  170. }
  171. }
  172. void gluGetNurbsProperty(GLUnurbs *r, GLenum property, GLfloat *value)
  173. {
  174. GLfloat nurbsValue;
  175. switch(property) {
  176. case GLU_AUTO_LOAD_MATRIX:
  177. if (r->getautoloadmode()) {
  178. *value = GL_TRUE;
  179. } else {
  180. *value = GL_FALSE;
  181. }
  182. break;
  183. case GLU_CULLING:
  184. r->getnurbsproperty(GL_MAP2_VERTEX_3, N_CULLING, &nurbsValue);
  185. if (nurbsValue == N_CULLINGON) {
  186. *value = GL_TRUE;
  187. } else {
  188. *value = GL_FALSE;
  189. }
  190. break;
  191. case GLU_SAMPLING_METHOD:
  192. r->getnurbsproperty(GL_MAP2_VERTEX_3, N_SAMPLINGMETHOD, value);
  193. break;
  194. case GLU_SAMPLING_TOLERANCE:
  195. r->getnurbsproperty(GL_MAP2_VERTEX_3, N_PIXEL_TOLERANCE, value);
  196. break;
  197. case GLU_PARAMETRIC_TOLERANCE:
  198. r->getnurbsproperty(GL_MAP2_VERTEX_3, N_ERROR_TOLERANCE, value);
  199. break;
  200. case GLU_U_STEP:
  201. r->getnurbsproperty(GL_MAP2_VERTEX_3, N_S_STEPS, value);
  202. break;
  203. case GLU_V_STEP:
  204. r->getnurbsproperty(GL_MAP2_VERTEX_3, N_T_STEPS, value);
  205. break;
  206. case GLU_DISPLAY_MODE:
  207. r->getnurbsproperty(N_DISPLAY, &nurbsValue);
  208. if (nurbsValue == N_FILL) {
  209. *value = GLU_FILL;
  210. } else if (nurbsValue == N_OUTLINE_POLY) {
  211. *value = GLU_OUTLINE_POLYGON;
  212. } else {
  213. *value = GLU_OUTLINE_PATCH;
  214. }
  215. break;
  216. default:
  217. r->postError(GLU_INVALID_ENUM);
  218. return;
  219. }
  220. }
  221. void gluNurbsCallback(GLUnurbs *r, GLenum which, void (*fn)())
  222. {
  223. switch (which) {
  224. case GLU_ERROR:
  225. #ifdef NT
  226. r->errorCallback = (GLUnurbsErrorProc) fn;
  227. #else
  228. r->errorCallback = (void (*)( GLenum )) fn;
  229. #endif
  230. break;
  231. default:
  232. r->postError(GLU_INVALID_ENUM);
  233. return;
  234. }
  235. }