Windows NT 4.0 source code leak
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.

394 lines
9.2 KiB

5 years ago
  1. /*
  2. ** Copyright 1992, 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. #include <windows.h>
  18. #include <stdio.h>
  19. #include <stdarg.h>
  20. #include <string.h>
  21. #include <stdlib.h>
  22. #include "ctk.h"
  23. #include "shell.h"
  24. long verbose;
  25. GLint visualID = -99;
  26. void Output(char *format, ...)
  27. {
  28. va_list args;
  29. va_start(args, format);
  30. if (verbose) {
  31. vprintf(format, args);
  32. fflush(stdout);
  33. }
  34. va_end(args);
  35. }
  36. void FailAndDie(void)
  37. {
  38. Output("\n");
  39. printf("covgl failed.\n\n");
  40. tkQuit();
  41. }
  42. void ProbeEnum(void)
  43. {
  44. if (glGetError() == GL_INVALID_ENUM) {
  45. FailAndDie();
  46. }
  47. }
  48. void ProbeError(void (*Func)(void))
  49. {
  50. glPushAttrib(GL_ALL_ATTRIB_BITS);
  51. (*Func)();
  52. if (glGetError() != GL_NO_ERROR) {
  53. FailAndDie();
  54. }
  55. glFlush();
  56. glPopAttrib();
  57. }
  58. void ZeroBuf(long type, long size, void *buf)
  59. {
  60. long i;
  61. switch (type) {
  62. case GL_UNSIGNED_BYTE:
  63. {
  64. unsigned char *ptr = (unsigned char *)buf;
  65. for (i = 0; i < size; i++) {
  66. *ptr++ = 0;
  67. }
  68. }
  69. break;
  70. case GL_BYTE:
  71. {
  72. char *ptr = (char *)buf;
  73. for (i = 0; i < size; i++) {
  74. *ptr++ = 0;
  75. }
  76. }
  77. break;
  78. case GL_UNSIGNED_SHORT:
  79. {
  80. unsigned short *ptr = (unsigned short *)buf;
  81. for (i = 0; i < size; i++) {
  82. *ptr++ = 0;
  83. }
  84. }
  85. break;
  86. case GL_SHORT:
  87. {
  88. short *ptr = (short *)buf;
  89. for (i = 0; i < size; i++) {
  90. *ptr++ = 0;
  91. }
  92. }
  93. break;
  94. case GL_UNSIGNED_INT:
  95. {
  96. unsigned long *ptr = (unsigned long *)buf;
  97. for (i = 0; i < size; i++) {
  98. *ptr++ = 0;
  99. }
  100. }
  101. break;
  102. case GL_INT:
  103. {
  104. long *ptr = (long *)buf;
  105. for (i = 0; i < size; i++) {
  106. *ptr++ = 0;
  107. }
  108. }
  109. break;
  110. case GL_FLOAT:
  111. {
  112. float *ptr = (float *)buf;
  113. for (i = 0; i < size; i++) {
  114. *ptr++ = (GLfloat)0;
  115. }
  116. }
  117. break;
  118. }
  119. }
  120. static void DoTests(void)
  121. {
  122. VerifyEnums();
  123. ProbeError(CallGet);
  124. ProbeError(CallGetClipPlane);
  125. ProbeError(CallGetError);
  126. ProbeError(CallGetLight);
  127. ProbeError(CallGetMap);
  128. ProbeError(CallGetMaterial);
  129. ProbeError(CallGetPixelMap);
  130. ProbeError(CallGetPolygonStipple);
  131. ProbeError(CallGetString);
  132. ProbeError(CallGetTexEnv);
  133. ProbeError(CallGetTexGen);
  134. ProbeError(CallGetTexImage);
  135. ProbeError(CallGetTexLevelParameter);
  136. ProbeError(CallGetTexParameter);
  137. ProbeError(CallPushPopAttrib);
  138. ProbeError(CallEnableIsEnableDisable);
  139. ProbeError(CallHint);
  140. ProbeError(CallViewport);
  141. ProbeError(CallOrtho);
  142. ProbeError(CallFrustum);
  143. ProbeError(CallScissor);
  144. ProbeError(CallClipPlane);
  145. ProbeError(CallAccum);
  146. ProbeError(CallSelectBuffer);
  147. ProbeError(CallFeedbackBuffer);
  148. /*
  149. ** XXX
  150. **
  151. ProbeError(CallPassThrough);
  152. */
  153. ProbeError(CallInitNames);
  154. ProbeError(CallPushName);
  155. ProbeError(CallLoadName);
  156. ProbeError(CallPopName);
  157. ProbeError(CallLoadIdentity);
  158. ProbeError(CallMatrixMode);
  159. ProbeError(CallPushMatrix);
  160. ProbeError(CallLoadMatrix);
  161. ProbeError(CallMultMatrix);
  162. ProbeError(CallRotate);
  163. ProbeError(CallScale);
  164. ProbeError(CallTranslate);
  165. ProbeError(CallPopMatrix);
  166. ProbeError(CallClear);
  167. ProbeError(CallClearAccum);
  168. ProbeError(CallClearColor);
  169. ProbeError(CallClearDepth);
  170. ProbeError(CallClearIndex);
  171. ProbeError(CallClearStencil);
  172. ProbeError(CallColorMask);
  173. ProbeError(CallColor);
  174. ProbeError(CallIndexMask);
  175. ProbeError(CallIndex);
  176. ProbeError(CallVertex);
  177. ProbeError(CallNormal);
  178. ProbeError(CallAlphaFunc);
  179. ProbeError(CallBlendFunc);
  180. ProbeError(CallDepthFunc);
  181. ProbeError(CallDepthMask);
  182. ProbeError(CallDepthRange);
  183. ProbeError(CallLogicOp);
  184. ProbeError(CallStencilFunc);
  185. ProbeError(CallStencilMask);
  186. ProbeError(CallStencilOp);
  187. ProbeError(CallRenderMode);
  188. ProbeError(CallReadBuffer);
  189. ProbeError(CallDrawBuffer);
  190. ProbeError(CallRasterPos);
  191. /*
  192. * Put CallPixelStore at end of this function - otherwise modes it sets
  193. * can cause access violations for subsequent tests such as CallTexImage1D.
  194. */
  195. #if 0
  196. ProbeError(CallPixelStore);
  197. #endif
  198. ProbeError(CallPixelTransfer);
  199. ProbeError(CallPixelZoom);
  200. ProbeError(CallReadDrawPixels);
  201. ProbeError(CallCopyPixels);
  202. ProbeError(CallPixelMap);
  203. ProbeError(CallFog);
  204. ProbeError(CallLightModel);
  205. ProbeError(CallLight);
  206. ProbeError(CallMaterial);
  207. ProbeError(CallColorMaterial);
  208. ProbeError(CallTexCoord);
  209. ProbeError(CallTexEnv);
  210. ProbeError(CallTexGen);
  211. ProbeError(CallTexParameter);
  212. ProbeError(CallTexImage1D);
  213. ProbeError(CallTexImage2D);
  214. ProbeError(CallShadeModel);
  215. ProbeError(CallPointSize);
  216. ProbeError(CallLineStipple);
  217. ProbeError(CallLineWidth);
  218. ProbeError(CallRect);
  219. ProbeError(CallPolygonMode);
  220. ProbeError(CallPolygonStipple);
  221. ProbeError(CallCullFace);
  222. ProbeError(CallEdgeFlag);
  223. ProbeError(CallFrontFace);
  224. ProbeError(CallBitmap);
  225. ProbeError(CallBeginEnd);
  226. ProbeError(CallMap1);
  227. ProbeError(CallMap2);
  228. ProbeError(CallEvalCoord);
  229. ProbeError(CallEvalPoint1);
  230. ProbeError(CallEvalPoint2);
  231. ProbeError(CallMapGrid1);
  232. ProbeError(CallMapGrid2);
  233. ProbeError(CallEvalMesh1);
  234. ProbeError(CallEvalMesh2);
  235. ProbeError(CallGenLists);
  236. ProbeError(CallNewEndList);
  237. ProbeError(CallIsList);
  238. ProbeError(CallCallList);
  239. ProbeError(CallListBase);
  240. ProbeError(CallCallLists);
  241. ProbeError(CallDeleteLists);
  242. ProbeError(CallFlush);
  243. ProbeError(CallFinish);
  244. #if 1
  245. ProbeError(CallPixelStore);
  246. #endif
  247. printf("covgl passed.\n\n");
  248. }
  249. static long Exec(TK_EventRec *ptr)
  250. {
  251. if (ptr->event == TK_EVENT_EXPOSE) {
  252. DoTests();
  253. return 0;
  254. }
  255. return 1;
  256. }
  257. static long Init(int argc, char **argv)
  258. {
  259. long i;
  260. verbose = 0;
  261. for (i = 1; i < argc; i++) {
  262. if (strcmp(argv[i], "-h") == 0) {
  263. printf("Options:\n");
  264. printf("\t-h Print this help screen.\n");
  265. printf("\t-a [Default] Run tests on all pixel formats. \n");
  266. printf("\t-s Run tests on all display pixel formats. \n");
  267. printf("\t-b Run tests on all bitmap pixel formats. \n");
  268. printf("\t-v Verbose mode ON.\n");
  269. printf("\n");
  270. return 1;
  271. } else if (strcmp(argv[i], "-v") == 0) {
  272. verbose = 1;
  273. } else if (strcmp(argv[i], "-a") == 0) { // all display & bitmap fmt
  274. visualID = -99;
  275. } else if (strcmp(argv[i], "-s") == 0) { // all display formats
  276. visualID = -98;
  277. } else if (strcmp(argv[i], "-b") == 0) { // all bitmap formats
  278. visualID = -97;
  279. } else {
  280. printf("%s (Bad option).\n", argv[i]);
  281. return 1;
  282. }
  283. }
  284. return 0;
  285. }
  286. int main(int argc, char **argv)
  287. {
  288. TK_WindowRec wind;
  289. TK_VisualIDsRec list;
  290. int i;
  291. BOOL bTestAll = FALSE;
  292. printf("Open GL Coverage Test.\n");
  293. printf("Version 1.0.14\n");
  294. printf("\n");
  295. if (Init(argc, argv)) {
  296. tkQuit();
  297. return 1;
  298. }
  299. strcpy(wind.name, "Open GL Coverage Test");
  300. wind.x = CW_USEDEFAULT;
  301. wind.y = CW_USEDEFAULT;
  302. wind.width = WINSIZE;
  303. wind.height = WINSIZE;
  304. wind.eventMask = TK_EVENT_EXPOSE;
  305. switch (visualID) {
  306. case -99: // test all display and bitmap pixel formats
  307. bTestAll = TRUE;
  308. // fall through
  309. case -98: // test all display pixel formats
  310. tkGet(TK_VISUALIDS, (void *)&list);
  311. for (i = 0; i < list.count; i++) {
  312. wind.type = TK_WIND_VISUAL;
  313. wind.info = (GLint)list.IDs[i];
  314. wind.render = TK_WIND_DIRECT;
  315. if (tkNewWindow(&wind)) {
  316. printf("Display ID %d \n", list.IDs[i]);
  317. tkExec(Exec);
  318. tkCloseWindow();
  319. } else {
  320. printf("Display ID %d not found.\n\n", list.IDs[i]);
  321. }
  322. }
  323. if (!bTestAll)
  324. break;
  325. // fall through
  326. case -97: // test all bitmap pixel formats
  327. tkGet(TK_VISUALIDS, (void *)&list);
  328. for (i = 0; i < list.count; i++) {
  329. wind.type = TK_WIND_VISUAL;
  330. wind.info = -(GLint)list.IDs[i];
  331. wind.render = TK_WIND_DIRECT;
  332. if (tkNewWindow(&wind)) {
  333. printf("Bitmap ID %d \n", -list.IDs[i]);
  334. tkExec(Exec);
  335. tkCloseWindow();
  336. } else {
  337. printf("Bitmap ID %d not found.\n\n", -list.IDs[i]);
  338. }
  339. }
  340. break;
  341. default:
  342. break;
  343. }
  344. tkQuit();
  345. return 0;
  346. }