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.

7979 lines
215 KiB

  1. /*
  2. gstrip need to be implemented
  3. bigchar needs to be implemented
  4. Here is a new version of perf, for use in measuring graphics performance.
  5. I've renamed it to be gpt, and added a lot of functionality.
  6. I'd like it to be the standard way for ESD to measure performance.
  7. It measures the performance of geometric primitives over a range
  8. of angles, as specified in the Periodic Table.
  9. I've calibrated gpt by running it on a GT, a VGX, a PI, a Magnum,
  10. and a Hollywood. I believe it gives accurate and consistent
  11. numbers. It measures all of the numbers that we publish, including
  12. fill rate and DMA.
  13. If you find bugs in gpt, or want to add features, feel free to
  14. modify it. But please mail out the new copy to this group, so
  15. we all have a consistent version.
  16. Jim
  17. */
  18. /*
  19. * gpt.c - Graphics Performance Tester
  20. *
  21. * Benchmark for performance testing.
  22. *
  23. * Vimal Parikh - 1988 Silicon Graphics Inc.
  24. *
  25. * Modified by Jim Bennett - 1991
  26. * - Added self timing and loop count
  27. * - Added pixel dma tests
  28. * - Added tests at various angles
  29. * - Added named tests and modifiers mechanism
  30. * Modified by Gary Tarolli - 1991
  31. * - Unrolled loops somemore, and optimized some of them a little
  32. * - fixed some minor bugs, like forgetting to use ortho to test 3d
  33. * - use v2f for fast 2d primitives
  34. * Modified by David Ligon - 1992
  35. * - cleaned up loops
  36. * - added mdifiers (dashed, width, pattern, cmode)
  37. * - varied dma size
  38. * - varied viewport size for clear
  39. * - added qstrip
  40. * - added 2d for geometry
  41. * - added anti aliased points
  42. * - added check for bad parameter combinations
  43. * Modified by Gianpaolo Tommasi - 1993
  44. * - ported to OpenGL
  45. * Modified by Scott Carr - 1993
  46. * - Use libaux so I can run it on NT
  47. *
  48. * Usage: gpt <test> [<modifiers>] [loop count] [duration]
  49. *
  50. * The currently supported tests are:
  51. *
  52. * xform Test transform rate (points)
  53. * fill Test fill rate
  54. * dma Test DMA rate
  55. * char Test character drawing rate
  56. * line Test line drawing rate
  57. * poly Test polygon drawing rate
  58. * tmesh Test Triangle mesh drawing rate
  59. * qmesh Test Quad mesh drawing rate
  60. * clear Test screen clear rate
  61. * varray Test vertex array rate (uses tmesh)
  62. *
  63. * The currently supported modifiers are:
  64. *
  65. * +2d Restrict transform to 2D
  66. * +z Enable Z buffering
  67. * +shade Enable Gouraud shading
  68. * +cmode Use color index mode (Not implemented yet)
  69. * +1ilight Enable 1 infinite light
  70. * +2ilight Enable 2 infinite lights
  71. * +4ilight Enable 4 infinite lights
  72. * +1llight Enable 1 local light
  73. * +2llight Enable 2 local lights
  74. * +4llight Enable 4 local lights
  75. * +lmcolor Enable colored lighted vertices
  76. * +depth Enable depth cueing
  77. * +aa Enable anti-aliasing
  78. * +snap Set subpixel FALSE (fast path for PI).
  79. * +dashed Enable dashed lines
  80. * +width Set line width, +width n (n = 0-9 pixels)
  81. * +pattern Enable pattern filling
  82. * +scale Set scale for geometry (not implemented yet)
  83. * +oldwindow Open window at (100,900)-(100,650)
  84. * +brief Brief text output
  85. * +bigger Bigger tmesh 20x20
  86. * +backface Sets frontface or backface to cull all primitives
  87. * +dlist Use display lists
  88. * +db Use double-buffered visual
  89. * +avg Print averages only
  90. * +size <size> Size of line or side of triangle
  91. * +mod_texture Use Texture mapping.
  92. * +blend Blend the texture with the color
  93. * +modulate Use the modulation function for textures
  94. * (Decal mode is the default)
  95. * +texfile <filename> Specify the texture file
  96. * (the abobe three work only if mod_texture)
  97. *
  98. * Loop count specifies the number of times the test is run,
  99. * and duration specifies the length of each run of the test.
  100. * By default, the test is run once for one second.
  101. *
  102. * The line, poly, and tmesh tests are run 16 times, at a
  103. * variety of angles, and the average result is printed.
  104. *
  105. */
  106. /*
  107. * Notes for OpenGL version:
  108. * - Uses linear fog instead of depth cueing.
  109. * - 8 bit pixel writes are done by writing to only the red channel of an
  110. * RGB visual as opposed to writing to a 8 bit CI visual as the IrisGL
  111. * version did.
  112. * - Since the polygons used in the perfpoly test are all quadrilaterals,
  113. * GL_QUADS are used.
  114. */
  115. #include <windows.h>
  116. #include <stdlib.h>
  117. #include <stdio.h>
  118. #include <string.h>
  119. #include <math.h>
  120. #include <time.h>
  121. #include <GL/glu.h>
  122. #include <GL/gl.h>
  123. #include "glaux.h"
  124. #define M_SQRT2 1.41421356237309504880
  125. #define M_SQRT1_2 0.70710678118654752440
  126. /* default window size for geometry testing */
  127. #define WINWIDTH 620
  128. #define WINHEIGHT 440
  129. #define MINDIMENSION 440
  130. /* default texture size */
  131. #define DEF_TEX_WIDTH 64
  132. #define DEF_TEX_HEIGHT 64
  133. #define MESH_W 64
  134. #define MESH_H 64
  135. #define DEF_PRIM_SIZE 10
  136. #define QUAD_ROUND(x) (((x)+0x0f)&(~0x0f))
  137. #define NVERT 62
  138. #define NNORM 4
  139. #define NCOLR 8
  140. #define NTEXTR 4
  141. typedef struct {
  142. GLfloat x;
  143. GLfloat y;
  144. GLfloat z;
  145. } vertType;
  146. typedef struct {
  147. GLfloat r;
  148. GLfloat g;
  149. GLfloat b;
  150. } colorType;
  151. typedef struct {
  152. vertType vertex;
  153. vertType normal;
  154. colorType color;
  155. vertType texture;
  156. } MESHVERTEX;
  157. char fiftychars[51] = {
  158. "12345678901234567890123456789012345678901234567890"
  159. };
  160. float *v; /* Vertices */
  161. float *mv; /* Farhad's Vertices */
  162. float *n; /* Normals */
  163. float *c; /* Colors */
  164. float *t; /* Texture coords */
  165. MESHVERTEX *va; /* Vertex Array */
  166. GLuint *ve; /* Vertex Element array */
  167. int stride = sizeof (MESHVERTEX);
  168. int mod_2d = 0;
  169. int mod_z = 0;
  170. int mod_shade = 0;
  171. int mod_cmode = 0;
  172. int mod_light = 0;
  173. int mod_1ilight = 0;
  174. int mod_2ilight = 0;
  175. int mod_4ilight = 0;
  176. int mod_1llight = 0;
  177. int mod_2llight = 0;
  178. int mod_4llight = 0;
  179. int mod_lmcolor = 0;
  180. int mod_depth = 0;
  181. int mod_aa = 0;
  182. int mod_snap = 0;
  183. int mod_dashed = 0;
  184. int mod_width = 0;
  185. int mod_pattern = 0;
  186. int mod_oldwindow = 0;
  187. int mod_brief = 0;
  188. int mod_bigger = 0;
  189. int mod_backface = 0;
  190. int mod_doublebuffer = 0;
  191. int mod_average = 0;
  192. int mod_size = 0;
  193. int mod_blend = 0;
  194. int mod_modulate = 0;
  195. int mod_texfile = 0;
  196. int mod_texture = 0;
  197. char tex_fname[50];
  198. float prim_size = DEF_PRIM_SIZE;
  199. int tex_width = DEF_TEX_WIDTH;
  200. int tex_height = DEF_TEX_HEIGHT;
  201. float secspertest;
  202. float angle;
  203. float secs;
  204. float sum_secs;
  205. int sum_n;
  206. int rate;
  207. int loopcount;
  208. long xsize,ysize;
  209. static int delay_counter;
  210. static DWORD startelapsed, endelapsed;
  211. short line_width = 1;
  212. static unsigned int pattern[] = {
  213. 0x55555555, 0xaaaaaaaa,
  214. 0x55555555, 0xaaaaaaaa,
  215. 0x55555555, 0xaaaaaaaa,
  216. 0x55555555, 0xaaaaaaaa,
  217. 0x55555555, 0xaaaaaaaa,
  218. 0x55555555, 0xaaaaaaaa,
  219. 0x55555555, 0xaaaaaaaa,
  220. 0x55555555, 0xaaaaaaaa,
  221. 0x55555555, 0xaaaaaaaa,
  222. 0x55555555, 0xaaaaaaaa,
  223. 0x55555555, 0xaaaaaaaa,
  224. 0x55555555, 0xaaaaaaaa,
  225. 0x55555555, 0xaaaaaaaa,
  226. 0x55555555, 0xaaaaaaaa,
  227. 0x55555555, 0xaaaaaaaa,
  228. 0x55555555, 0xaaaaaaaa,
  229. };
  230. GLubyte *image; //place to store the texture
  231. AUX_RGBImageRec *image_rec ;
  232. static float gold_col[] = {0.2, 0.2, 0.0, 1.0};
  233. static float gold_dif[] = {0.9, 0.5, 0.0, 1.0};
  234. static float gold_spec[] = {0.7, 0.7, 0.0, 1.0};
  235. static float gold_shiny[] = {20.0};
  236. static float white_inf_light_amb[] = {0.0, 0.0, 0.0, 1.0};
  237. static float white_inf_light_dif[] = {0.9, 0.9, 0.9, 1.0};
  238. static float white_inf_light_pos[] = {50.0, 50.0, 50.0, 0.0};
  239. static float blue_inf_light_amb[] = {0.0, 0.0, 0.0, 1.0};
  240. static float blue_inf_light_dif[] = {0.30, 0.10, 0.90, 1.0};
  241. static float blue_inf_light_pos[] = {-50.0, 50.0, 50.0, 0.0};
  242. static float red_inf_light_amb[] = {0.0, 0.0, 0.0, 1.0};
  243. static float red_inf_light_dif[] = {0.90, 0.10, 0.30, 1.0};
  244. static float red_inf_light_pos[] = {-50.0, -50.0, 50.0, 0.0};
  245. static float white2_inf_light_amb[] = {0.0, 0.0, 0.0, 1.0};
  246. static float white2_inf_light_dif[] = {0.60, 0.60, 0.60, 1.0};
  247. static float white2_inf_light_pos[] = {50.0, -50.0, 50.0, 0.0};
  248. static float blue_local_light_amb[] = {0.0, 0.0, 0.0, 1.0};
  249. static float blue_local_light_dif[] = {0.30, 0.10, 0.90, 1.0};
  250. static float blue_local_light_pos[] = {-50.0, 50.0, -50.0, 1.0};
  251. static float red_local_light_amb[] = {0.0, 0.0, 0.0, 1.0};
  252. static float red_local_light_dif[] = {0.90, 0.10, 0.10, 1.0};
  253. static float red_local_light_pos[] = {50.0, 50.0, -50.0, 1.0};
  254. static float green_local_light_amb[] = {0.0, 0.0, 0.0, 1.0};
  255. static float green_local_light_dif[] = {0.10, 0.90, 0.10, 1.0};
  256. static float green_local_light_pos[] = {50.0, -50.0, -50.0, 1.0};
  257. static float white_local_light_amb[] = {0.0, 0.0, 0.0, 1.0};
  258. static float white_local_light_dif[] = {0.90, 0.90, 0.90, 1.0};
  259. static float white_local_light_pos[] = {-50.0, -50.0, -50.0, 1.0};
  260. static float lightmod_amb[] = {0.3, 0.3, 0.3, 1.0};
  261. static float lightmod_loc[] = {GL_FALSE};
  262. enum {
  263. BLACK = 0,
  264. RED = 13,
  265. GREEN = 14,
  266. YELLOW = 15,
  267. BLUE = 16,
  268. MAGENTA = 17,
  269. CYAN = 18,
  270. WHITE = 19
  271. };
  272. GLboolean useList = GL_FALSE;
  273. GLboolean newList = GL_FALSE;
  274. GLuint listID = 0;
  275. /*****************************************************************************/
  276. /*
  277. * Some support routines
  278. */
  279. static void initListMode(void) {
  280. useList = GL_TRUE;
  281. newList = GL_FALSE;
  282. listID = glGenLists(1);
  283. }
  284. static float timer(int flag)
  285. {
  286. if (useList && flag) {
  287. if (newList) {
  288. glEndList();
  289. newList = GL_FALSE;
  290. }
  291. glFinish();
  292. startelapsed = GetTickCount();
  293. glCallList(listID);
  294. }
  295. glFinish();
  296. if (flag == 0) {
  297. startelapsed = GetTickCount();
  298. return(0.0);
  299. }
  300. endelapsed = GetTickCount();
  301. return(endelapsed - startelapsed) / (float)1000;
  302. }
  303. static int starttest(int flag)
  304. {
  305. if (useList) {
  306. if (flag == 0) {
  307. glNewList(listID, GL_COMPILE);
  308. newList = GL_TRUE;
  309. return(1);
  310. }
  311. else
  312. return(0);
  313. } else {
  314. glFinish();
  315. startelapsed = GetTickCount();
  316. return(1);
  317. }
  318. }
  319. static void endtest(char *s, int r, int force)
  320. {
  321. if (useList) {
  322. if (newList) {
  323. glEndList();
  324. newList = GL_FALSE;
  325. }
  326. glFinish();
  327. startelapsed = GetTickCount();
  328. glCallList(listID);
  329. }
  330. glFinish();
  331. endelapsed = GetTickCount();
  332. secs = (endelapsed - startelapsed) / (float)1000;
  333. if (!mod_average || force) {
  334. printf("%-44s--", s);
  335. printf("%12.2f/sec (%6.3f secs)\n", r/secs, secs);
  336. fflush(stdout);
  337. }
  338. sum_secs += secs;
  339. sum_n += r;
  340. Sleep(300);
  341. }
  342. static void printaverage (void)
  343. {
  344. printf("\n%-44s--", "Average over all angles");
  345. printf("%12.2f/sec\n", sum_n/sum_secs);
  346. }
  347. static void pixendtest(char *s, int r, int xpix, int ypix)
  348. {
  349. double pixrate;
  350. char pbuf[256];
  351. secs = timer(1);
  352. sprintf(pbuf,"%dx%d %s",xpix,ypix,s);
  353. printf("%-44s--", pbuf);
  354. #if 0
  355. pixrate = r/secs;
  356. pixrate = (pixrate * xpix * ypix) / 1000000.0;
  357. printf("%10.4f Million pixels/sec\n", pixrate);
  358. #else
  359. pixrate = ((double)(r * xpix * ypix) / secs);
  360. if (pixrate > 1000000.0)
  361. printf("%10.4f Million pixels/sec\n", pixrate/1000000.0);
  362. else if (pixrate > 1000.0)
  363. printf("%10.4f Thousand pixels/sec\n", pixrate/1000.0);
  364. else
  365. printf("%10.4f Pixels/sec\n", pixrate);
  366. #endif
  367. fflush(stdout);
  368. Sleep(250);
  369. }
  370. static void clearendtest(char *s, int r, int numpix)
  371. {
  372. double pixrate;
  373. secs = timer(1);
  374. printf("%s \n",s);
  375. printf("\ttotal time: %f for %d clears \n", secs, r);
  376. printf("\tcalculated average time for a clear: %f ms\n",1000.0*secs/(float)r);
  377. pixrate = ((double)(r * numpix) / secs) / 1000000.0;
  378. printf("\t%10.4f Million pixels/sec\n\n",pixrate);
  379. fflush(stdout);
  380. Sleep(250);
  381. }
  382. static void spindelay(void)
  383. {
  384. int i;
  385. delay_counter = 0;
  386. for (i=0; i<2000000; i++) {
  387. delay_counter = delay_counter + i;
  388. delay_counter = delay_counter/39;
  389. }
  390. }
  391. static void makeramp(int i, int r1, int g1, int b1, int r2, int g2, int b2,
  392. int nindexes)
  393. {
  394. #ifdef PORTME
  395. XColor col;
  396. int count;
  397. int r,g,b;
  398. for (count = 0; count < nindexes; count++) {
  399. r = (r2 - r1) * count/(nindexes - 1) + r1;
  400. g = (g2 - g1) * count/(nindexes - 1) + g1;
  401. b = (b2 - b1) * count/(nindexes - 1) + b1;
  402. col.red = r * (65535.0 / 255);
  403. col.green = g * (65535.0 / 255);
  404. col.blue = b * (65535.0 / 255);
  405. col.pixel = i;
  406. col.flags = DoRed | DoGreen | DoBlue;
  407. XStoreColor(theDisplay, theCMap, &col);
  408. i++;
  409. }
  410. XFlush(theDisplay);
  411. #endif
  412. }
  413. static void setLightingParameters(void)
  414. {
  415. if (mod_1ilight || mod_2ilight || mod_4ilight) {
  416. /* lmbind(LIGHT1, 1); */
  417. glEnable(GL_LIGHTING);
  418. glLightfv(GL_LIGHT0, GL_AMBIENT, white_inf_light_amb);
  419. glLightfv(GL_LIGHT0, GL_DIFFUSE, white_inf_light_dif);
  420. glLightfv(GL_LIGHT0, GL_POSITION, white_inf_light_pos);
  421. glEnable(GL_LIGHT0);
  422. }
  423. if (mod_2ilight || mod_4ilight) {
  424. /* lmbind(LIGHT1, 1);lmbind(LIGHT2, 2); */
  425. glLightfv(GL_LIGHT1, GL_AMBIENT, blue_inf_light_amb);
  426. glLightfv(GL_LIGHT1, GL_DIFFUSE, blue_inf_light_dif);
  427. glLightfv(GL_LIGHT1, GL_POSITION, blue_inf_light_pos);
  428. glEnable(GL_LIGHT1);
  429. }
  430. if (mod_4ilight) {
  431. /* lmbind(LIGHT1, 1);lmbind(LIGHT2, 2);
  432. lmbind(LIGHT3, 3);lmbind(LIGHT4, 4); */
  433. glLightfv(GL_LIGHT2, GL_AMBIENT, red_inf_light_amb);
  434. glLightfv(GL_LIGHT2, GL_DIFFUSE, red_inf_light_dif);
  435. glLightfv(GL_LIGHT2, GL_POSITION, red_inf_light_pos);
  436. glEnable(GL_LIGHT2);
  437. glLightfv(GL_LIGHT3, GL_AMBIENT, white2_inf_light_amb);
  438. glLightfv(GL_LIGHT3, GL_DIFFUSE, white2_inf_light_dif);
  439. glLightfv(GL_LIGHT3, GL_POSITION, white2_inf_light_pos);
  440. glEnable(GL_LIGHT3);
  441. }
  442. if (mod_1llight || mod_2llight || mod_4llight) {
  443. /* lmbind(LIGHT5, 5); */
  444. glEnable(GL_LIGHTING);
  445. glLightfv(GL_LIGHT4, GL_AMBIENT, blue_local_light_amb);
  446. glLightfv(GL_LIGHT4, GL_DIFFUSE, blue_local_light_dif);
  447. glLightfv(GL_LIGHT4, GL_POSITION, blue_local_light_pos);
  448. glEnable(GL_LIGHT4);
  449. }
  450. if (mod_2llight) {
  451. /* lmbind(LIGHT5, 5);lmbind(LIGHT6, 6);*/
  452. glLightfv(GL_LIGHT5, GL_AMBIENT, red_local_light_amb);
  453. glLightfv(GL_LIGHT5, GL_DIFFUSE, red_local_light_dif);
  454. glLightfv(GL_LIGHT5, GL_POSITION, red_local_light_pos);
  455. glEnable(GL_LIGHT5);
  456. }
  457. if (mod_4llight) {
  458. /* lmbind(LIGHT5, 5);lmbind(LIGHT6, 6);lmbind(LIGHT7, 7);
  459. lmbind(LIGHT0, 8); */
  460. glLightfv(GL_LIGHT6, GL_AMBIENT, green_local_light_amb);
  461. glLightfv(GL_LIGHT6, GL_DIFFUSE, green_local_light_dif);
  462. glLightfv(GL_LIGHT6, GL_POSITION, green_local_light_pos);
  463. glEnable(GL_LIGHT6);
  464. glLightfv(GL_LIGHT7, GL_AMBIENT, white_local_light_amb);
  465. glLightfv(GL_LIGHT7, GL_DIFFUSE, white_local_light_dif);
  466. glLightfv(GL_LIGHT7, GL_POSITION, white_local_light_pos);
  467. glEnable(GL_LIGHT7);
  468. }
  469. /* lmbind(LMODEL, 1); */
  470. glLightModelfv(GL_LIGHT_MODEL_AMBIENT, lightmod_amb);
  471. glLightModelfv(GL_LIGHT_MODEL_LOCAL_VIEWER, lightmod_loc);
  472. /* lmbind(MATERIAL, 1); */
  473. glMaterialfv(GL_FRONT, GL_AMBIENT, gold_col);
  474. glMaterialfv(GL_FRONT, GL_DIFFUSE, gold_dif);
  475. glMaterialfv(GL_FRONT, GL_SPECULAR, gold_spec);
  476. glMaterialfv(GL_FRONT, GL_SHININESS, gold_shiny);
  477. /* if (mod_lmcolor) lmcolor(LMC_DIFFUSE); */
  478. if (mod_lmcolor) {
  479. glColorMaterial(GL_FRONT_AND_BACK, GL_DIFFUSE);
  480. glEnable(GL_COLOR_MATERIAL);
  481. }
  482. }
  483. /******************************Public*Routine******************************\
  484. * ss_fRand
  485. *
  486. * Generates float random number min...max
  487. *
  488. \**************************************************************************/
  489. FLOAT ss_fRand( FLOAT min, FLOAT max )
  490. {
  491. FLOAT diff;
  492. diff = max - min;
  493. return min + ( diff * ( ((float)rand()) / ((float)(RAND_MAX)) ) );
  494. }
  495. static int GenVertData (int num_x, int num_y)
  496. {
  497. int i, j, k, ti, ci, ni, num_tri, num_vert;
  498. int l0, l1, l2, l3, numVinRow, numVinCol;
  499. GLfloat curr_x, curr_y, beg;
  500. float *tt;
  501. srand ( (unsigned) time (NULL));
  502. numVinRow = num_x;
  503. numVinCol = num_y;
  504. num_vert = numVinRow * numVinCol;
  505. num_tri = (numVinRow - 1) * (numVinCol - 1) * 2;
  506. va = (MESHVERTEX *) malloc (sizeof (MESHVERTEX) * num_vert);
  507. ve = (GLuint *) malloc (sizeof (GLuint) * num_tri * 3);
  508. printf ("num_vert = %d, prim_size = %f, num_tri = %d\n",
  509. num_vert, prim_size, num_tri);
  510. /* 255 = r, 240 = g, 255 = b */
  511. makeramp(208,255,0,0,0,0,255,16);
  512. makeramp(224,0,0,255,255,255,0,16);
  513. makeramp(240,255,255,0,255,0,255,16);
  514. k = 0;
  515. beg = - (numVinRow * prim_size) / 2.0;
  516. for (i = 0, curr_y = beg; i < numVinCol; i++, curr_y += prim_size) {
  517. for (j = 0, curr_x = beg; j < numVinRow;
  518. j++, k++, curr_x += prim_size) {
  519. va [k].vertex.x = curr_x;
  520. va [k].vertex.y = curr_y;
  521. va [k].vertex.z = 0.0;
  522. va [k].normal.x = ss_fRand (-0.25, 0.25);
  523. va [k].normal.y = ss_fRand (-0.25, 0.25);
  524. va [k].normal.z = 1.0;
  525. va [k].texture.x = (float) (j % 4) / 4.0;
  526. va [k].texture.y = (float) (i % 4) / 4.0;
  527. if (i % 2) {
  528. if (j % 2) {ci = 4; ni = 255;}
  529. else {ci = 8; ni = 240;}
  530. } else {
  531. if (j % 2) {ci = 16; ni = 223;}
  532. else {ci = 8; ni = 208;}
  533. }
  534. if (!mod_cmode) { /* Color Mode */
  535. va [k].color.r = c[ci];
  536. va [k].color.g = c[ci+1];
  537. va [k].color.b = c[ci+2];
  538. } else { /* Color Index mode */
  539. va [k].color.r = (float) ni;
  540. }
  541. }
  542. }
  543. /* Assign the element array to draw triangles */
  544. k = 0;
  545. for (i = 0; i < (numVinCol - 1); i++) {
  546. for (j = 0; j < (numVinRow - 1); j++) {
  547. l0 = i * numVinRow + j;
  548. l1 = (i + 1) * numVinRow + j;
  549. l2 = l0 + 1;
  550. l3 = l1 + 1;
  551. ve[k++] = l0; ve[k++] = l1; ve[k++] = l2;
  552. ve[k++] = l2; ve[k++] = l1; ve[k++] = l3;
  553. }
  554. }
  555. /* Specify vertex array data */
  556. glNormalPointer (GL_FLOAT, stride, &(va[0].normal.x));
  557. glColorPointer (3, GL_FLOAT, stride, &(va[0].color.r));
  558. glIndexPointer (GL_FLOAT, stride, &(va[0].color.r));
  559. glTexCoordPointer (2, GL_FLOAT, stride, &(va[0].texture.x));
  560. /* Enable the appropriate arrays */
  561. glDisableClientState (GL_EDGE_FLAG_ARRAY);
  562. glEnableClientState (GL_VERTEX_ARRAY);
  563. if (mod_texture) glEnableClientState (GL_TEXTURE_COORD_ARRAY);
  564. else glDisableClientState (GL_TEXTURE_COORD_ARRAY);
  565. printf ("Num elements = %d\n", k);
  566. return (k);
  567. }
  568. static void CreateImage(void)
  569. {
  570. int i, j;
  571. GLubyte col = 0 ;
  572. tex_width = DEF_TEX_WIDTH;
  573. tex_height = DEF_TEX_HEIGHT;
  574. image = (GLubyte *) LocalAlloc (LMEM_FIXED,
  575. sizeof (GLubyte) * tex_width * tex_height * 3);
  576. for(i=0; i<tex_width; i++)
  577. for(j=0; j<tex_height; j++)
  578. if( ((j/8)%2 && (i/8)%2) || (!((j/8)%2) && !((i/8)%2)) )
  579. {
  580. image[(i*tex_height+j)*3] = 127 ;
  581. image[(i*tex_height+j)*3+1] = 127 ;
  582. image[(i*tex_height+j)*3+2] = 127 ;
  583. }
  584. else
  585. {
  586. image[(i*tex_height+j)*3] = 0 ;
  587. image[(i*tex_height+j)*3+1] = 0 ;
  588. image[(i*tex_height+j)*3+2] = 0 ;
  589. }
  590. }
  591. static void MyLoadImage(void)
  592. {
  593. image_rec = auxDIBImageLoad(tex_fname);
  594. tex_width = image_rec->sizeX;
  595. tex_height = image_rec->sizeY;
  596. printf("Image size -- X= %d, Y= %d\n", tex_width, tex_height) ;
  597. }
  598. static void InitTexParams (void)
  599. {
  600. if (mod_blend)
  601. glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_BLEND) ;
  602. else if (mod_modulate)
  603. glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_MODULATE) ;
  604. else
  605. glTexEnvf(GL_TEXTURE_ENV, GL_TEXTURE_ENV_MODE, GL_DECAL) ;
  606. if (!mod_texfile) {
  607. glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT) ;
  608. glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT) ;
  609. glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST) ;
  610. glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST) ;
  611. glTexImage2D(GL_TEXTURE_2D, 0, 3, tex_width, tex_height, 0, GL_RGB,
  612. GL_UNSIGNED_BYTE, image) ;
  613. } else {
  614. glPixelStorei(GL_UNPACK_ALIGNMENT, 1);
  615. glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_S, GL_REPEAT) ;
  616. glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_WRAP_T, GL_REPEAT) ;
  617. glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_NEAREST) ;
  618. glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_NEAREST) ;
  619. gluBuild2DMipmaps(GL_TEXTURE_2D, 3, image_rec->sizeX,
  620. image_rec->sizeY, GL_RGB, GL_UNSIGNED_BYTE,
  621. image_rec->data);
  622. }
  623. glEnable (GL_TEXTURE_2D);
  624. }
  625. /*****************************************************************************/
  626. /*
  627. * The tests proper
  628. */
  629. static void perfpoint(void)
  630. {
  631. int i, k;
  632. float *vp = v;
  633. /*** POINTS *****/
  634. if (mod_width) {
  635. glPointSize(line_width);
  636. }
  637. if (mod_aa) {
  638. glEnable(GL_POINT_SMOOTH);
  639. if (mod_cmode) {
  640. /* create a colour ramp appropriate for anti-aliasing */
  641. /* i, r1, g1, b1, r2, g2, b2, nindexes */
  642. makeramp(240, 0, 0, 0, 255, 255, 255, 16);
  643. glClearIndex(240);
  644. glClear(GL_COLOR_BUFFER_BIT);
  645. glIndexi(240);
  646. } else {
  647. glEnable(GL_BLEND);
  648. /* blendfunction(BF_SA,BF_ONE); */
  649. glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  650. }
  651. }
  652. /****** Calibration Loop ******/
  653. secs = 0.0;
  654. rate = 125;
  655. while (secs < (secspertest/4.0)) {
  656. rate = rate * 2;
  657. starttest(0);
  658. glBegin(GL_POINTS);
  659. if (mod_2d)
  660. for (i = 0; i < rate; i++)
  661. glVertex2fv(vp);
  662. else
  663. for (i = 0; i < rate; i++)
  664. glVertex3fv(vp);
  665. glEnd();
  666. secs = timer(1);
  667. }
  668. rate = rate * (secspertest / secs);
  669. rate = 10 * (rate / 10);
  670. /* do the real thing */
  671. for (k = 0; k < loopcount; k++) {
  672. if (starttest(k)) {
  673. glBegin(GL_POINTS);
  674. if (mod_2d) {
  675. for (i = rate / 10; i; i--) {
  676. glVertex2fv(vp);
  677. glVertex2fv(vp);
  678. glVertex2fv(vp);
  679. glVertex2fv(vp);
  680. glVertex2fv(vp);
  681. glVertex2fv(vp);
  682. glVertex2fv(vp);
  683. glVertex2fv(vp);
  684. glVertex2fv(vp);
  685. glVertex2fv(vp);
  686. }
  687. } else {
  688. for (i = rate / 10; i; i--) {
  689. glVertex3fv(vp);
  690. glVertex3fv(vp);
  691. glVertex3fv(vp);
  692. glVertex3fv(vp);
  693. glVertex3fv(vp);
  694. glVertex3fv(vp);
  695. glVertex3fv(vp);
  696. glVertex3fv(vp);
  697. glVertex3fv(vp);
  698. glVertex3fv(vp);
  699. }
  700. }
  701. glEnd();
  702. }
  703. endtest("", rate, 1);
  704. }
  705. if (mod_doublebuffer) {
  706. auxSwapBuffers();
  707. Sleep(2000); /* for visual feedback */
  708. }
  709. exit(0);
  710. }
  711. static void perfline(void)
  712. {
  713. int i,k;
  714. char pbuf[256];
  715. float *vp=v;
  716. if (mod_dashed) {
  717. glEnable(GL_LINE_STIPPLE);
  718. glLineStipple(1, 0x5555);
  719. }
  720. if (mod_width) {
  721. glLineWidth(line_width);
  722. }
  723. /*** ANTI_ALIAS LINES *****/
  724. if (mod_aa) {
  725. glEnable(GL_LINE_SMOOTH);
  726. if (mod_cmode) {
  727. makeramp(240,0,0,0,255,255,255,16);
  728. glClearIndex(240);
  729. glClear(GL_COLOR_BUFFER_BIT);
  730. glIndexi(240);
  731. } else {
  732. glBlendFunc(GL_SRC_ALPHA, GL_ONE_MINUS_SRC_ALPHA);
  733. }
  734. }
  735. /*** DEPTHCUED LINES *****/
  736. /*
  737. * OpenGL has no depth cueing, we'll use linear fog instead.
  738. */
  739. if (mod_depth) {
  740. glEnable(GL_FOG);
  741. glFogi(GL_FOG_MODE, GL_LINEAR);
  742. glDepthRange(0.0, 1.0);
  743. glFogf(GL_FOG_START, 0.0);
  744. glFogf(GL_FOG_END, 1.0);
  745. if (mod_cmode) {
  746. makeramp(240,250,250,250,255,255,0,16);
  747. glIndexi(240);
  748. glFogf(GL_FOG_INDEX, 16);
  749. } else
  750. glFogfv(GL_FOG_COLOR, &c[16]);
  751. sum_secs = 0.0;
  752. sum_n = 0;
  753. vp[4] -= 1.0; /* make lines 10 pixels instead of 11 */
  754. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  755. glPushMatrix();
  756. glRotatef(angle, 0, 0, 1);
  757. /****** Calibration Loop ******/
  758. secs = 0.0; rate = 125;
  759. while (secs < (secspertest/4.0)) {
  760. rate = rate*2;
  761. starttest(0);
  762. glBegin(GL_LINE_STRIP);
  763. /* No 2D depth cued lines - Go straight to 3D */
  764. for(i=(rate)/2; i; i--) {
  765. glVertex3fv(vp);
  766. glVertex3fv(vp+4);
  767. }
  768. glEnd();
  769. secs = timer(1);
  770. }
  771. rate = rate * (secspertest/secs);
  772. rate = 10 * (rate/10);
  773. for (k=0; k<loopcount; k++) {
  774. if (starttest(k)) {
  775. glBegin(GL_LINE_STRIP);
  776. for(i=(rate)/10; i; i--) {
  777. glVertex3fv(vp);
  778. glVertex3fv(vp+4);
  779. glVertex3fv(vp);
  780. glVertex3fv(vp+4);
  781. glVertex3fv(vp);
  782. glVertex3fv(vp+4);
  783. glVertex3fv(vp);
  784. glVertex3fv(vp+4);
  785. glVertex3fv(vp);
  786. glVertex3fv(vp+4);
  787. }
  788. glEnd();
  789. }
  790. if (!mod_average)
  791. sprintf(pbuf, "Angle %6.2f", angle);
  792. endtest(pbuf, rate, 0);
  793. }
  794. glPopMatrix();
  795. }
  796. printaverage();
  797. if (mod_doublebuffer) {
  798. auxSwapBuffers();
  799. Sleep(2000); /* for visual feedback */
  800. }
  801. exit(0);
  802. }
  803. if (!mod_shade) {
  804. /**** Flat shaded RGB or Color mapped lines ****/
  805. /**** Color should already be set ****/
  806. sum_secs = 0.0;
  807. sum_n = 0;
  808. vp[4] -= 1.0; /* make lines 10 pixels instead of 11 */
  809. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  810. glPushMatrix();
  811. glRotatef(angle, 0, 0, 1);
  812. /****** Calibration Loop ******/
  813. secs = 0.0; rate = 125;
  814. while (secs < (secspertest/4.0)) {
  815. rate = rate*2;
  816. starttest(0);
  817. glBegin(GL_LINE_STRIP);
  818. if (mod_2d) {
  819. for(i=(rate)/2; i; i--) {
  820. glVertex2fv(vp);
  821. glVertex2fv(vp+4);
  822. }
  823. } else {
  824. for(i=(rate)/2; i; i--) {
  825. glVertex3fv(vp);
  826. glVertex3fv(vp+4);
  827. }
  828. }
  829. glEnd();
  830. secs = timer(1);
  831. }
  832. rate = rate * (secspertest/secs);
  833. rate = 10 * (rate/10);
  834. for (k=0; k<loopcount; k++) {
  835. if (starttest(k)) {
  836. glBegin(GL_LINE_STRIP);
  837. if (mod_2d) {
  838. for(i=(rate)/10; i; i--) {
  839. glVertex2fv(vp);
  840. glVertex2fv(vp+4);
  841. glVertex2fv(vp);
  842. glVertex2fv(vp+4);
  843. glVertex2fv(vp);
  844. glVertex2fv(vp+4);
  845. glVertex2fv(vp);
  846. glVertex2fv(vp+4);
  847. glVertex2fv(vp);
  848. glVertex2fv(vp+4);
  849. }
  850. } else {
  851. for(i=(rate)/10; i; i--) {
  852. glVertex3fv(vp);
  853. glVertex3fv(vp+4);
  854. glVertex3fv(vp);
  855. glVertex3fv(vp+4);
  856. glVertex3fv(vp);
  857. glVertex3fv(vp+4);
  858. glVertex3fv(vp);
  859. glVertex3fv(vp+4);
  860. glVertex3fv(vp);
  861. glVertex3fv(vp+4);
  862. }
  863. }
  864. glEnd();
  865. }
  866. if (!mod_average)
  867. sprintf(pbuf, "Angle %6.2f", angle);
  868. endtest(pbuf, rate, 0);
  869. }
  870. glPopMatrix();
  871. }
  872. printaverage();
  873. } else {
  874. if (mod_cmode) {
  875. /**** Gouraud Color mapped lines ****/
  876. makeramp(240,255,0,0,0,0,255,16);
  877. sum_secs = 0.0;
  878. sum_n = 0;
  879. vp[4] -= 1.0; /* make lines 10 pixels instead of 11 */
  880. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  881. glPushMatrix();
  882. glRotatef(angle, 0, 0, 1);
  883. /****** Calibration Loop ******/
  884. secs = 0.0; rate = 125;
  885. while (secs < (secspertest/4.0)) {
  886. rate = rate*2;
  887. starttest(0);
  888. glBegin(GL_LINE_STRIP);
  889. if (mod_2d) {
  890. for(i=(rate)/2; i; i--) {
  891. glIndexi(240);
  892. glVertex2fv(vp);
  893. glIndexi(255);
  894. glVertex2fv(vp+4);
  895. }
  896. } else {
  897. for(i=(rate)/2; i; i--) {
  898. glIndexi(240);
  899. glVertex3fv(vp);
  900. glIndexi(255);
  901. glVertex3fv(vp+4);
  902. }
  903. }
  904. glEnd();
  905. secs = timer(1);
  906. }
  907. rate = rate * (secspertest/secs);
  908. rate = 10 * (rate/10);
  909. for (k=0; k<loopcount; k++) {
  910. if (starttest(k)) {
  911. glBegin(GL_LINE_STRIP);
  912. if (mod_2d) {
  913. for(i=(rate)/10; i; i--) {
  914. glIndexi(240);
  915. glVertex2fv(vp);
  916. glIndexi(255);
  917. glVertex2fv(vp+4);
  918. glIndexi(240);
  919. glVertex2fv(vp);
  920. glIndexi(255);
  921. glVertex2fv(vp+4);
  922. glIndexi(240);
  923. glVertex2fv(vp);
  924. glIndexi(255);
  925. glVertex2fv(vp+4);
  926. glIndexi(240);
  927. glVertex2fv(vp);
  928. glIndexi(255);
  929. glVertex2fv(vp+4);
  930. glIndexi(240);
  931. glVertex2fv(vp);
  932. glIndexi(255);
  933. glVertex2fv(vp+4);
  934. }
  935. } else {
  936. for(i=(rate)/10; i; i--) {
  937. glIndexi(240);
  938. glVertex2fv(vp);
  939. glIndexi(255);
  940. glVertex2fv(vp+4);
  941. glIndexi(240);
  942. glVertex2fv(vp);
  943. glIndexi(255);
  944. glVertex2fv(vp+4);
  945. glIndexi(240);
  946. glVertex2fv(vp);
  947. glIndexi(255);
  948. glVertex2fv(vp+4);
  949. glIndexi(240);
  950. glVertex2fv(vp);
  951. glIndexi(255);
  952. glVertex2fv(vp+4);
  953. glIndexi(240);
  954. glVertex2fv(vp);
  955. glIndexi(255);
  956. glVertex2fv(vp+4);
  957. }
  958. }
  959. glEnd();
  960. }
  961. if (!mod_average)
  962. sprintf (pbuf, "Angle %6.2f", angle);
  963. endtest(pbuf, rate, 0);
  964. }
  965. glPopMatrix();
  966. }
  967. printaverage();
  968. } else {
  969. /**** Gouraud shaded RGB index lines ****/
  970. sum_secs = 0.0;
  971. sum_n = 0;
  972. vp[4] -= 1.0; /* make lines 10 pixels instead of 11 */
  973. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  974. glPushMatrix();
  975. glRotatef(angle, 0, 0, 1);
  976. /****** Calibration Loop ******/
  977. secs = 0.0; rate = 125;
  978. while (secs < (secspertest/4.0)) {
  979. rate = rate*2;
  980. starttest(0);
  981. glBegin(GL_LINE_STRIP);
  982. if (mod_2d) {
  983. for(i=(rate)/2; i; i--) {
  984. glColor3fv(&c[12]);
  985. glVertex2fv(vp);
  986. glColor3fv(&c[8]);
  987. glVertex2fv(vp+4);
  988. }
  989. } else {
  990. for(i=(rate)/2; i; i--) {
  991. glColor3fv(&c[12]);
  992. glVertex3fv(vp);
  993. glColor3fv(&c[8]);
  994. glVertex3fv(vp+4);
  995. }
  996. }
  997. glEnd();
  998. secs = timer(1);
  999. }
  1000. rate = rate * (secspertest/secs);
  1001. rate = 10 * (rate/10);
  1002. for (k=0; k<loopcount; k++) {
  1003. if (starttest(k)) {
  1004. glBegin(GL_LINE_STRIP);
  1005. if (mod_2d) {
  1006. for(i=(rate)/10; i; i--) {
  1007. glColor3fv(&c[12]);
  1008. glVertex2fv(vp);
  1009. glColor3fv(&c[8]);
  1010. glVertex2fv(vp+4);
  1011. glColor3fv(&c[12]);
  1012. glVertex2fv(vp);
  1013. glColor3fv(&c[8]);
  1014. glVertex2fv(vp+4);
  1015. glColor3fv(&c[12]);
  1016. glVertex2fv(vp);
  1017. glColor3fv(&c[8]);
  1018. glVertex2fv(vp+4);
  1019. glColor3fv(&c[12]);
  1020. glVertex2fv(vp);
  1021. glColor3fv(&c[8]);
  1022. glVertex2fv(vp+4);
  1023. glColor3fv(&c[12]);
  1024. glVertex2fv(vp);
  1025. glColor3fv(&c[8]);
  1026. glVertex2fv(vp+4);
  1027. }
  1028. } else {
  1029. for(i=(rate)/10; i; i--) {
  1030. glColor3fv(&c[12]);
  1031. glVertex2fv(vp);
  1032. glColor3fv(&c[8]);
  1033. glVertex2fv(vp+4);
  1034. glColor3fv(&c[12]);
  1035. glVertex2fv(vp);
  1036. glColor3fv(&c[8]);
  1037. glVertex2fv(vp+4);
  1038. glColor3fv(&c[12]);
  1039. glVertex2fv(vp);
  1040. glColor3fv(&c[8]);
  1041. glVertex2fv(vp+4);
  1042. glColor3fv(&c[12]);
  1043. glVertex2fv(vp);
  1044. glColor3fv(&c[8]);
  1045. glVertex2fv(vp+4);
  1046. glColor3fv(&c[12]);
  1047. glVertex2fv(vp);
  1048. glColor3fv(&c[8]);
  1049. glVertex2fv(vp+4);
  1050. }
  1051. }
  1052. glEnd();
  1053. }
  1054. if (!mod_average)
  1055. sprintf (pbuf, "Angle %6.2f", angle);
  1056. endtest(pbuf, rate, 0);
  1057. }
  1058. glPopMatrix();
  1059. }
  1060. printaverage();
  1061. }
  1062. }
  1063. if (mod_doublebuffer) {
  1064. auxSwapBuffers();
  1065. Sleep(2000); /* for visual feedback */
  1066. }
  1067. exit(0);
  1068. }
  1069. static void perfchar(void)
  1070. {
  1071. int i,k;
  1072. /*** CHARACTERS *****/
  1073. #ifdef PORTME
  1074. /* create the bitmaps */
  1075. glXUseXFont(theFont, '0', 10, '0');
  1076. #endif
  1077. glListBase(0);
  1078. /****** Calibration Loop ******/
  1079. secs = 0.0; rate = 125;
  1080. while (secs < (secspertest/4.0)) {
  1081. rate = rate*2;
  1082. starttest(0);
  1083. for(i=(rate)/50; i; i--) {
  1084. glRasterPos3i(10-(WINWIDTH/2), 10, 0);
  1085. glCallLists(strlen(fiftychars), GL_UNSIGNED_BYTE, fiftychars);
  1086. }
  1087. secs = timer(1);
  1088. }
  1089. rate = rate * (secspertest/secs);
  1090. rate = 50 * (rate/50);
  1091. for (k=0; k<loopcount; k++) {
  1092. if (starttest(k)) {
  1093. for(i=(rate)/50; i; i--) {
  1094. glRasterPos3i(10-(WINWIDTH/2), 10, 0);
  1095. glCallLists(strlen(fiftychars), GL_UNSIGNED_BYTE, fiftychars);
  1096. }
  1097. }
  1098. endtest("", rate, 1);
  1099. }
  1100. }
  1101. static void perftmesh(void)
  1102. {
  1103. int i,j,k;
  1104. float *vtx = &v[0];
  1105. char pbuf[256];
  1106. int cVert = 60;
  1107. /* Triangle mesh tests: Each tmesh contains 62 vertices, or */
  1108. /* 60 triangles. To make the calculation exact, the rate */
  1109. /* must be a multiple of 60. */
  1110. if (mod_backface){
  1111. glEnable(GL_CULL_FACE);
  1112. glCullFace(GL_FRONT);
  1113. }
  1114. if (mod_bigger) {
  1115. vtx = &mv[0];
  1116. printf("bigger in tmesh\n");
  1117. }
  1118. /* If the triangle size is specified, set the size of the triangle mesh to
  1119. ** fit the window. The number of vertices must be a multiple of four (due
  1120. ** to code below), and it must not exceed 60.
  1121. */
  1122. if (mod_size) {
  1123. cVert = (int) (MINDIMENSION*2 / prim_size) - 2;
  1124. if (cVert & 1) cVert++;
  1125. cVert &= ~3;
  1126. if (cVert < 4) cVert = 4;
  1127. if (cVert > 60) cVert = 60;
  1128. }
  1129. for(i=0; i<NVERT; i++) {
  1130. vtx[i*4+1] -= ((cVert+2)/4.0 * prim_size);
  1131. }
  1132. if (!mod_2d) {
  1133. if (mod_cmode && mod_shade) {
  1134. /*** GOURAUD SHADED CMODE TMESH ***/
  1135. /* 255 = r, 240 = g, 255 = b */
  1136. makeramp(208,255,0,0,0,0,255,16);
  1137. makeramp(224,0,0,255,255,255,0,16);
  1138. makeramp(240,255,255,0,255,0,255,16);
  1139. sum_secs = 0.0;
  1140. sum_n = 0;
  1141. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  1142. if (!mod_average)
  1143. sprintf(pbuf, "Angle %6.2f", angle);
  1144. glPushMatrix();
  1145. glRotatef(angle-90.0, 0, 0, 1);
  1146. /****** Calibration Loop ******/
  1147. secs = 0.0; rate = 125;
  1148. while (secs < (secspertest/4.0)) {
  1149. rate = rate*2;
  1150. starttest(0);
  1151. for(i=(rate)/cVert; i; i--) {
  1152. glBegin(GL_TRIANGLE_STRIP);
  1153. for (j=0; j<cVert; j+=4) {
  1154. glIndexi(255);
  1155. glVertex3fv(&vtx[j*4]);
  1156. glIndexi(240);
  1157. glVertex3fv(&vtx[(j+1)*4]);
  1158. glIndexi(223);
  1159. glVertex3fv(&vtx[(j+2)*4]);
  1160. glIndexi(208);
  1161. glVertex3fv(&vtx[(j+3)*4]);
  1162. }
  1163. glIndexi(255);
  1164. glVertex3fv(&vtx[j*4]);
  1165. glIndexi(240);
  1166. glVertex3fv(&vtx[(j+1)*4]);
  1167. glEnd();
  1168. }
  1169. secs = timer(1);
  1170. }
  1171. rate = rate * (secspertest/secs);
  1172. rate = cVert * (rate/cVert);
  1173. /* Do the real thing GOURAUD shaded Cmode tmesh */
  1174. for (k=0; k<loopcount; k++) {
  1175. if (starttest(k)) {
  1176. for(i=(rate)/cVert; i; i--) {
  1177. glBegin(GL_TRIANGLE_STRIP);
  1178. for (j=0; j<cVert; j+=4) {
  1179. glIndexi(255);
  1180. glVertex3fv(&vtx[j*4]);
  1181. glIndexi(240);
  1182. glVertex3fv(&vtx[(j+1)*4]);
  1183. glIndexi(223);
  1184. glVertex3fv(&vtx[(j+2)*4]);
  1185. glIndexi(208);
  1186. glVertex3fv(&vtx[(j+3)*4]);
  1187. }
  1188. glIndexi(255);
  1189. glVertex3fv(&vtx[j*4]);
  1190. glIndexi(240);
  1191. glVertex3fv(&vtx[(j+1)*4]);
  1192. glEnd();
  1193. }
  1194. }
  1195. endtest(pbuf, rate, 0);
  1196. }
  1197. glPopMatrix();
  1198. }
  1199. printaverage();
  1200. } else if (!mod_light && !mod_shade) {
  1201. /*** FLAT SHADED TMESH ***/
  1202. sum_secs = 0.0;
  1203. sum_n = 0;
  1204. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  1205. if (!mod_average)
  1206. sprintf(pbuf, "Angle %6.2f", angle);
  1207. glPushMatrix();
  1208. glRotatef(angle-90.0, 0, 0, 1);
  1209. /****** Calibration Loop ******/
  1210. secs = 0.0; rate = 125;
  1211. while (secs < (secspertest/4.0)) {
  1212. rate = rate*2;
  1213. starttest(0);
  1214. for(i=(rate)/cVert; i; i--) {
  1215. glBegin(GL_TRIANGLE_STRIP);
  1216. for (j=0; j<cVert+2; j++) {
  1217. glVertex3fv(&vtx[j*4]);
  1218. }
  1219. glEnd();
  1220. }
  1221. secs = timer(1);
  1222. }
  1223. rate = rate * (secspertest/secs);
  1224. rate = cVert * (rate/cVert);
  1225. /* Do the real thing - FLAT shaded tmesh */
  1226. for (k=0; k<loopcount; k++) {
  1227. if (starttest(k)) {
  1228. for(i=(rate)/cVert; i; i--) {
  1229. glBegin(GL_TRIANGLE_STRIP);
  1230. for (j=0; j<cVert+2; j++) {
  1231. glVertex3fv(&vtx[j*4]);
  1232. }
  1233. glEnd();
  1234. }
  1235. }
  1236. endtest(pbuf, rate, 0);
  1237. }
  1238. glPopMatrix();
  1239. }
  1240. printaverage();
  1241. } else if (!mod_cmode && mod_light) {
  1242. /*** LIGHTED RGB MESH ***/
  1243. glLoadIdentity();
  1244. glMatrixMode(GL_PROJECTION);
  1245. glLoadIdentity();
  1246. glOrtho(-0.5*xsize,0.5*xsize,-0.5*ysize,0.5*ysize,1.0,-1.0);
  1247. glMatrixMode(GL_MODELVIEW);
  1248. /* set lights */
  1249. setLightingParameters();
  1250. sum_secs = 0.0;
  1251. sum_n = 0;
  1252. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  1253. if (!mod_average)
  1254. sprintf (pbuf, "Angle %6.2f", angle);
  1255. glPushMatrix();
  1256. glRotatef(angle-90.0, 0, 0, 1);
  1257. /****** Calibration Loop ******/
  1258. secs = 0.0; rate = 125;
  1259. while (secs < (secspertest/4.0)) {
  1260. rate = rate*2;
  1261. if (mod_lmcolor) {
  1262. starttest(0);
  1263. for(i=(rate)/cVert; i; i--) {
  1264. glBegin(GL_TRIANGLE_STRIP);
  1265. for (j=0; j<cVert; j+=4) {
  1266. glColor3fv(&c[16]);
  1267. glNormal3fv(&n[0]);
  1268. glVertex3fv(&vtx[j*4]);
  1269. glColor3fv(&c[20]);
  1270. glNormal3fv(&n[4]);
  1271. glVertex3fv(&vtx[(j+1)*4]);
  1272. glColor3fv(&c[4]);
  1273. glNormal3fv(&n[8]);
  1274. glVertex3fv(&vtx[(j+2)*4]);
  1275. glColor3fv(&c[8]);
  1276. glNormal3fv(&n[12]);
  1277. glVertex3fv(&vtx[(j+3)*4]);
  1278. }
  1279. glColor3fv(&c[16]);
  1280. glNormal3fv(&n[0]);
  1281. glVertex3fv(&vtx[j*4]);
  1282. glColor3fv(&c[20]);
  1283. glNormal3fv(&n[4]);
  1284. glVertex3fv(&vtx[(j+1)*4]);
  1285. glEnd();
  1286. }
  1287. secs = timer(1);
  1288. }
  1289. else {
  1290. starttest(0);
  1291. for(i=(rate)/cVert; i; i--) {
  1292. glBegin(GL_TRIANGLE_STRIP);
  1293. for (j=0; j<cVert; j+=4) {
  1294. glNormal3fv(&n[0]);
  1295. glVertex3fv(&vtx[j*4]);
  1296. glNormal3fv(&n[4]);
  1297. glVertex3fv(&vtx[(j+1)*4]);
  1298. glNormal3fv(&n[8]);
  1299. glVertex3fv(&vtx[(j+2)*4]);
  1300. glNormal3fv(&n[12]);
  1301. glVertex3fv(&vtx[(j+3)*4]);
  1302. }
  1303. glNormal3fv(&n[0]);
  1304. glVertex3fv(&vtx[j*4]);
  1305. glNormal3fv(&n[4]);
  1306. glVertex3fv(&vtx[(j+1)*4]);
  1307. glEnd();
  1308. }
  1309. secs = timer(1);
  1310. }
  1311. }
  1312. rate = rate * (secspertest/secs);
  1313. rate = cVert * (rate/cVert);
  1314. for (k=0; k<loopcount; k++) {
  1315. if (mod_lmcolor) {
  1316. if (starttest(k)) {
  1317. for(i=(rate)/cVert; i; i--) {
  1318. glBegin(GL_TRIANGLE_STRIP);
  1319. for (j=0; j<cVert; j+=4) {
  1320. glColor3fv(&c[16]);
  1321. glNormal3fv(&n[0]);
  1322. glVertex3fv(&vtx[j*4]);
  1323. glColor3fv(&c[20]);
  1324. glNormal3fv(&n[4]);
  1325. glVertex3fv(&vtx[(j+1)*4]);
  1326. glColor3fv(&c[4]);
  1327. glNormal3fv(&n[8]);
  1328. glVertex3fv(&vtx[(j+2)*4]);
  1329. glColor3fv(&c[8]);
  1330. glNormal3fv(&n[12]);
  1331. glVertex3fv(&vtx[(j+3)*4]);
  1332. }
  1333. glColor3fv(&c[16]);
  1334. glNormal3fv(&n[0]);
  1335. glVertex3fv(&vtx[j*4]);
  1336. glColor3fv(&c[20]);
  1337. glNormal3fv(&n[4]);
  1338. glVertex3fv(&vtx[(j+1)*4]);
  1339. glEnd();
  1340. }
  1341. }
  1342. endtest(pbuf, rate, 0);
  1343. }
  1344. else {
  1345. if (starttest(k)) {
  1346. for(i=(rate)/cVert; i; i--) {
  1347. glBegin(GL_TRIANGLE_STRIP);
  1348. for (j=0; j<cVert; j+=4) {
  1349. glNormal3fv(&n[0]);
  1350. glVertex3fv(&vtx[j*4]);
  1351. glNormal3fv(&n[4]);
  1352. glVertex3fv(&vtx[(j+1)*4]);
  1353. glNormal3fv(&n[8]);
  1354. glVertex3fv(&vtx[(j+2)*4]);
  1355. glNormal3fv(&n[12]);
  1356. glVertex3fv(&vtx[(j+3)*4]);
  1357. }
  1358. glNormal3fv(&n[0]);
  1359. glVertex3fv(&vtx[j*4]);
  1360. glNormal3fv(&n[4]);
  1361. glVertex3fv(&vtx[(j+1)*4]);
  1362. glEnd();
  1363. }
  1364. }
  1365. endtest(pbuf, rate, 0);
  1366. }
  1367. }
  1368. glPopMatrix();
  1369. }
  1370. printaverage();
  1371. } else if (!mod_cmode && mod_shade) {
  1372. /*** GOURAUD SHADED RGB TMESH ***/
  1373. sum_secs = 0.0;
  1374. sum_n = 0;
  1375. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  1376. if (!mod_average)
  1377. sprintf(pbuf, "Angle %6.2f", angle);
  1378. glPushMatrix();
  1379. glRotatef(angle-90.0, 0, 0, 1);
  1380. /****** Calibration Loop ******/
  1381. secs = 0.0; rate = 125;
  1382. while (secs < (secspertest/4.0)) {
  1383. rate = rate*2;
  1384. starttest(0);
  1385. for(i=(rate)/cVert; i; i--) {
  1386. glBegin(GL_TRIANGLE_STRIP);
  1387. for (j=0; j<cVert; j+=4) {
  1388. glColor3fv(&c[4]);
  1389. glVertex3fv(&vtx[j*4]);
  1390. glColor3fv(&c[8]);
  1391. glVertex3fv(&vtx[(j+1)*4]);
  1392. glColor3fv(&c[12]);
  1393. glVertex3fv(&vtx[(j+2)*4]);
  1394. glColor3fv(&c[16]);
  1395. glVertex3fv(&vtx[(j+3)*4]);
  1396. }
  1397. glColor3fv(&c[4]);
  1398. glVertex3fv(&vtx[j*4]);
  1399. glColor3fv(&c[8]);
  1400. glVertex3fv(&vtx[(j+1)*4]);
  1401. glEnd();
  1402. }
  1403. secs = timer(1);
  1404. }
  1405. rate = rate * (secspertest/secs);
  1406. rate = cVert * (rate/cVert);
  1407. /* Do the real thing GOURAUD shaded tmesh */
  1408. for (k=0; k<loopcount; k++) {
  1409. if (starttest(k)) {
  1410. for(i=(rate)/cVert; i; i--) {
  1411. glBegin(GL_TRIANGLE_STRIP);
  1412. for (j=0; j<cVert; j+=4) {
  1413. glColor3fv(&c[4]);
  1414. glVertex3fv(&vtx[j*4]);
  1415. glColor3fv(&c[8]);
  1416. glVertex3fv(&vtx[(j+1)*4]);
  1417. glColor3fv(&c[12]);
  1418. glVertex3fv(&vtx[(j+2)*4]);
  1419. glColor3fv(&c[16]);
  1420. glVertex3fv(&vtx[(j+3)*4]);
  1421. }
  1422. glColor3fv(&c[4]);
  1423. glVertex3fv(&vtx[j*4]);
  1424. glColor3fv(&c[8]);
  1425. glVertex3fv(&vtx[(j+1)*4]);
  1426. glEnd();
  1427. }
  1428. }
  1429. endtest(pbuf, rate, 0);
  1430. }
  1431. glPopMatrix();
  1432. }
  1433. printaverage();
  1434. }
  1435. } else { /* must be 2d */
  1436. if (mod_cmode && mod_shade) { /* color map lighting yet */
  1437. /*** GOURAUD SHADED CMODE TMESH ***/
  1438. /* 255 = r, 240 = g, 255 = b */
  1439. makeramp(208,255,0,0,0,0,255,16);
  1440. makeramp(224,0,0,255,255,255,0,16);
  1441. makeramp(240,255,255,0,255,0,255,16);
  1442. sum_secs = 0.0;
  1443. sum_n = 0;
  1444. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  1445. if (!mod_average)
  1446. sprintf(pbuf, "Angle %6.2f", angle);
  1447. glPushMatrix();
  1448. glRotatef(angle-90.0, 0, 0, 1);
  1449. /****** Calibration Loop ******/
  1450. secs = 0.0; rate = 125;
  1451. while (secs < (secspertest/4.0)) {
  1452. rate = rate*2;
  1453. starttest(0);
  1454. for(i=(rate)/cVert; i; i--) {
  1455. glBegin(GL_TRIANGLE_STRIP);
  1456. for (j=0; j<cVert; j+=4) {
  1457. glIndexi(255);
  1458. glVertex2fv(&vtx[j*4]);
  1459. glIndexi(240);
  1460. glVertex2fv(&vtx[(j+1)*4]);
  1461. glIndexi(223);
  1462. glVertex3fv(&vtx[(j+2)*4]);
  1463. glIndexi(208);
  1464. glVertex3fv(&vtx[(j+3)*4]);
  1465. }
  1466. glIndexi(255);
  1467. glVertex3fv(&vtx[j*4]);
  1468. glIndexi(240);
  1469. glVertex3fv(&vtx[(j+1)*4]);
  1470. glEnd();
  1471. }
  1472. secs = timer(1);
  1473. }
  1474. rate = rate * (secspertest/secs);
  1475. rate = cVert * (rate/cVert);
  1476. /* Do the real thing GOURAUD shaded Cmode tmesh */
  1477. for (k=0; k<loopcount; k++) {
  1478. if (starttest(k)) {
  1479. for(i=(rate)/cVert; i; i--) {
  1480. glBegin(GL_TRIANGLE_STRIP);
  1481. for (j=0; j<cVert; j+=4) {
  1482. glIndexi(255);
  1483. glVertex2fv(&vtx[j*4]);
  1484. glIndexi(240);
  1485. glVertex2fv(&vtx[(j+1)*4]);
  1486. glIndexi(223);
  1487. glVertex3fv(&vtx[(j+2)*4]);
  1488. glIndexi(208);
  1489. glVertex3fv(&vtx[(j+3)*4]);
  1490. }
  1491. glIndexi(255);
  1492. glVertex3fv(&vtx[j*4]);
  1493. glIndexi(240);
  1494. glVertex3fv(&vtx[(j+1)*4]);
  1495. glEnd();
  1496. }
  1497. }
  1498. endtest(pbuf, rate, 0);
  1499. }
  1500. glPopMatrix();
  1501. }
  1502. printaverage();
  1503. } else if (!mod_light && !mod_shade) {
  1504. /*** FLAT SHADED TMESH ***/
  1505. sum_secs = 0.0;
  1506. sum_n = 0;
  1507. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  1508. if (!mod_average)
  1509. sprintf(pbuf, "Angle %6.2f", angle);
  1510. glPushMatrix();
  1511. glRotatef(angle-90.0, 0, 0, 1);
  1512. /****** Calibration Loop ******/
  1513. secs = 0.0; rate = 125;
  1514. while (secs < (secspertest/4.0)) {
  1515. rate = rate*2;
  1516. starttest(0);
  1517. for(i=(rate)/cVert; i; i--) {
  1518. glBegin(GL_TRIANGLE_STRIP);
  1519. for (j=0; j<cVert+2; j++) {
  1520. glVertex2fv(&vtx[j*4]);
  1521. }
  1522. glEnd();
  1523. }
  1524. secs = timer(1);
  1525. }
  1526. rate = rate * (secspertest/secs);
  1527. rate = cVert * (rate/cVert);
  1528. /* Do the real thing - FLAT shaded tmesh */
  1529. for (k=0; k<loopcount; k++) {
  1530. if (starttest(k)) {
  1531. for(i=(rate)/cVert; i; i--) {
  1532. glBegin(GL_TRIANGLE_STRIP);
  1533. for (j=0; j<cVert+2; j++) {
  1534. glVertex2fv(&vtx[j*4]);
  1535. }
  1536. glEnd();
  1537. }
  1538. }
  1539. endtest(pbuf, rate, 0);
  1540. }
  1541. glPopMatrix();
  1542. }
  1543. printaverage();
  1544. } else if (!mod_cmode && mod_light) {
  1545. /*** LIGHTED RGB MESH ***/
  1546. glLoadIdentity();
  1547. glMatrixMode(GL_PROJECTION);
  1548. glLoadIdentity();
  1549. glOrtho(-0.5*xsize,0.5*xsize,-0.5*ysize,0.5*ysize,1.0,-1.0);
  1550. glMatrixMode(GL_MODELVIEW);
  1551. /* set lights */
  1552. setLightingParameters();
  1553. sum_secs = 0.0;
  1554. sum_n = 0;
  1555. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  1556. if (!mod_average)
  1557. sprintf (pbuf, "Angle %6.2f", angle);
  1558. glPushMatrix();
  1559. glRotatef(angle-90.0, 0, 0, 1);
  1560. /****** Calibration Loop ******/
  1561. secs = 0.0; rate = 125;
  1562. while (secs < (secspertest/4.0)) {
  1563. rate = rate*2;
  1564. if (mod_lmcolor) {
  1565. starttest(0);
  1566. for(i=(rate)/cVert; i; i--) {
  1567. glBegin(GL_TRIANGLE_STRIP);
  1568. for (j=0; j<cVert; j+=4) {
  1569. glColor3fv(&c[16]);
  1570. glNormal3fv(&n[0]);
  1571. glVertex3fv(&vtx[j*4]);
  1572. glColor3fv(&c[20]);
  1573. glNormal3fv(&n[4]);
  1574. glVertex3fv(&vtx[(j+1)*4]);
  1575. glColor3fv(&c[4]);
  1576. glNormal3fv(&n[8]);
  1577. glVertex3fv(&vtx[(j+2)*4]);
  1578. glColor3fv(&c[8]);
  1579. glNormal3fv(&n[12]);
  1580. glVertex3fv(&vtx[(j+3)*4]);
  1581. }
  1582. glColor3fv(&c[16]);
  1583. glNormal3fv(&n[0]);
  1584. glVertex3fv(&vtx[j*4]);
  1585. glColor3fv(&c[20]);
  1586. glNormal3fv(&n[4]);
  1587. glVertex3fv(&vtx[(j+1)*4]);
  1588. glEnd();
  1589. }
  1590. secs = timer(1);
  1591. }
  1592. else {
  1593. starttest(0);
  1594. for(i=(rate)/cVert; i; i--) {
  1595. glBegin(GL_TRIANGLE_STRIP);
  1596. for (j=0; j<cVert; j+=4) {
  1597. glNormal3fv(&n[0]);
  1598. glVertex3fv(&vtx[j*4]);
  1599. glNormal3fv(&n[4]);
  1600. glVertex3fv(&vtx[(j+1)*4]);
  1601. glNormal3fv(&n[8]);
  1602. glVertex3fv(&vtx[(j+2)*4]);
  1603. glNormal3fv(&n[12]);
  1604. glVertex3fv(&vtx[(j+3)*4]);
  1605. }
  1606. glNormal3fv(&n[0]);
  1607. glVertex3fv(&vtx[j*4]);
  1608. glNormal3fv(&n[4]);
  1609. glVertex3fv(&vtx[(j+1)*4]);
  1610. glEnd();
  1611. }
  1612. secs = timer(1);
  1613. }
  1614. }
  1615. rate = rate * (secspertest/secs);
  1616. rate = cVert * (rate/cVert);
  1617. for (k=0; k<loopcount; k++) {
  1618. if (mod_lmcolor) {
  1619. if (starttest(k)) {
  1620. for(i=(rate)/cVert; i; i--) {
  1621. glBegin(GL_TRIANGLE_STRIP);
  1622. for (j=0; j<cVert; j+=4) {
  1623. glColor3fv(&c[16]);
  1624. glNormal3fv(&n[0]);
  1625. glVertex3fv(&vtx[j*4]);
  1626. glColor3fv(&c[20]);
  1627. glNormal3fv(&n[4]);
  1628. glVertex3fv(&vtx[(j+1)*4]);
  1629. glColor3fv(&c[4]);
  1630. glNormal3fv(&n[8]);
  1631. glVertex3fv(&vtx[(j+2)*4]);
  1632. glColor3fv(&c[8]);
  1633. glNormal3fv(&n[12]);
  1634. glVertex3fv(&vtx[(j+3)*4]);
  1635. }
  1636. glColor3fv(&c[16]);
  1637. glNormal3fv(&n[0]);
  1638. glVertex3fv(&vtx[j*4]);
  1639. glColor3fv(&c[20]);
  1640. glNormal3fv(&n[4]);
  1641. glVertex3fv(&vtx[(j+1)*4]);
  1642. glEnd();
  1643. }
  1644. }
  1645. endtest(pbuf, rate, 0);
  1646. }
  1647. else {
  1648. if (starttest(k)) {
  1649. for(i=(rate)/cVert; i; i--) {
  1650. glBegin(GL_TRIANGLE_STRIP);
  1651. for (j=0; j<cVert; j+=4) {
  1652. glNormal3fv(&n[0]);
  1653. glVertex3fv(&vtx[j*4]);
  1654. glNormal3fv(&n[4]);
  1655. glVertex3fv(&vtx[(j+1)*4]);
  1656. glNormal3fv(&n[8]);
  1657. glVertex3fv(&vtx[(j+2)*4]);
  1658. glNormal3fv(&n[12]);
  1659. glVertex3fv(&vtx[(j+3)*4]);
  1660. }
  1661. glNormal3fv(&n[0]);
  1662. glVertex3fv(&vtx[j*4]);
  1663. glNormal3fv(&n[4]);
  1664. glVertex3fv(&vtx[(j+1)*4]);
  1665. glEnd();
  1666. }
  1667. }
  1668. endtest(pbuf, rate, 0);
  1669. }
  1670. }
  1671. glPopMatrix();
  1672. }
  1673. printaverage();
  1674. } else if (!mod_cmode && mod_shade) {
  1675. /*** GOURAUD SHADED RGB TMESH ***/
  1676. sum_secs = 0.0;
  1677. sum_n = 0;
  1678. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  1679. if (!mod_average)
  1680. sprintf(pbuf, "Angle %6.2f", angle);
  1681. glPushMatrix();
  1682. glRotatef(angle-90.0, 0, 0, 1);
  1683. /****** Calibration Loop ******/
  1684. secs = 0.0; rate = 125;
  1685. while (secs < (secspertest/4.0)) {
  1686. rate = rate*2;
  1687. starttest(0);
  1688. for(i=(rate)/cVert; i; i--) {
  1689. glBegin(GL_TRIANGLE_STRIP);
  1690. for (j=0; j<cVert; j+=4) {
  1691. glColor3fv(&c[4]);
  1692. glVertex3fv(&vtx[j*4]);
  1693. glColor3fv(&c[8]);
  1694. glVertex3fv(&vtx[(j+1)*4]);
  1695. glColor3fv(&c[12]);
  1696. glVertex3fv(&vtx[(j+2)*4]);
  1697. glColor3fv(&c[16]);
  1698. glVertex3fv(&vtx[(j+3)*4]);
  1699. }
  1700. glColor3fv(&c[4]);
  1701. glVertex3fv(&vtx[j*4]);
  1702. glColor3fv(&c[8]);
  1703. glVertex3fv(&vtx[(j+1)*4]);
  1704. glEnd();
  1705. }
  1706. secs = timer(1);
  1707. }
  1708. rate = rate * (secspertest/secs);
  1709. rate = cVert * (rate/cVert);
  1710. /* Do the real thing GOURAUD shaded tmesh */
  1711. for (k=0; k<loopcount; k++) {
  1712. if (starttest(k)) {
  1713. for(i=(rate)/cVert; i; i--) {
  1714. glBegin(GL_TRIANGLE_STRIP);
  1715. for (j=0; j<cVert; j+=4) {
  1716. glColor3fv(&c[4]);
  1717. glVertex3fv(&vtx[j*4]);
  1718. glColor3fv(&c[8]);
  1719. glVertex3fv(&vtx[(j+1)*4]);
  1720. glColor3fv(&c[12]);
  1721. glVertex3fv(&vtx[(j+2)*4]);
  1722. glColor3fv(&c[16]);
  1723. glVertex3fv(&vtx[(j+3)*4]);
  1724. }
  1725. glColor3fv(&c[4]);
  1726. glVertex3fv(&vtx[j*4]);
  1727. glColor3fv(&c[8]);
  1728. glVertex3fv(&vtx[(j+1)*4]);
  1729. glEnd();
  1730. }
  1731. }
  1732. endtest(pbuf, rate, 0);
  1733. }
  1734. glPopMatrix();
  1735. }
  1736. printaverage();
  1737. }
  1738. }
  1739. if (mod_doublebuffer) {
  1740. auxSwapBuffers();
  1741. Sleep(2000); /* for visual feedback */
  1742. }
  1743. exit(0);
  1744. }
  1745. static void perfpoly(void)
  1746. {
  1747. float *vtx = &v[0];
  1748. int i, k;
  1749. char pbuf[256];
  1750. int cPoly;
  1751. if (mod_pattern) {
  1752. glEnable(GL_POLYGON_STIPPLE);
  1753. glPolygonStipple((GLubyte *) pattern);
  1754. }
  1755. /* If the polygon size is specified, set the number of polygons to
  1756. ** fit the window. The maximum number of polygons is 5.
  1757. */
  1758. cPoly = 5;
  1759. if (mod_size) {
  1760. cPoly = (int) (MINDIMENSION/2 / prim_size);
  1761. if (cPoly < 1) cPoly = 1;
  1762. if (cPoly > 5) cPoly = 5;
  1763. }
  1764. if (!mod_2d) {
  1765. /**** 3D POLYGONS ****/
  1766. if (mod_light && !mod_cmode) {
  1767. /*** POLYGONS (LIGHTED) *****/
  1768. glLoadIdentity();
  1769. glMatrixMode(GL_PROJECTION);
  1770. glLoadIdentity();
  1771. glOrtho(-0.5*xsize, 0.5*xsize,-0.5*ysize, 0.5*ysize,1.0, -1.0);
  1772. glMatrixMode(GL_MODELVIEW);
  1773. /* set lights */
  1774. setLightingParameters();
  1775. sum_secs = 0.0;
  1776. sum_n = 0;
  1777. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  1778. if (!mod_average)
  1779. sprintf (pbuf, "Angle %6.2f", angle);
  1780. glPushMatrix();
  1781. glRotatef(angle-90.0, 0, 0, 1);
  1782. /****** Calibration Loop ******/
  1783. secs = 0.0; rate = 125;
  1784. while (secs < (secspertest/4.0)) {
  1785. rate = rate*2;
  1786. if (mod_lmcolor) {
  1787. starttest(0);
  1788. for(i=(rate)/cPoly; i; i--) {
  1789. glBegin(GL_QUADS);
  1790. switch (cPoly) {
  1791. case 5:
  1792. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  1793. glVertex3fv(vtx+32);
  1794. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  1795. glVertex3fv(vtx+36);
  1796. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  1797. glVertex3fv(vtx+44);
  1798. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  1799. glVertex3fv(vtx+40);
  1800. case 4:
  1801. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  1802. glVertex3fv(vtx+24);
  1803. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  1804. glVertex3fv(vtx+28);
  1805. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  1806. glVertex3fv(vtx+36);
  1807. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  1808. glVertex3fv(vtx+32);
  1809. case 3:
  1810. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  1811. glVertex3fv(vtx+16);
  1812. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  1813. glVertex3fv(vtx+20);
  1814. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  1815. glVertex3fv(vtx+28);
  1816. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  1817. glVertex3fv(vtx+24);
  1818. case 2:
  1819. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  1820. glVertex3fv(vtx+8);
  1821. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  1822. glVertex3fv(vtx+12);
  1823. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  1824. glVertex3fv(vtx+20);
  1825. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  1826. glVertex3fv(vtx+16);
  1827. case 1:
  1828. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  1829. glVertex3fv(vtx);
  1830. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  1831. glVertex3fv(vtx+4);
  1832. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  1833. glVertex3fv(vtx+12);
  1834. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  1835. glVertex3fv(vtx+8);
  1836. }
  1837. glEnd();
  1838. }
  1839. secs = timer(1);
  1840. }
  1841. else {
  1842. starttest(0);
  1843. for(i=(rate)/cPoly; i; i--) {
  1844. glBegin(GL_QUADS);
  1845. switch (cPoly) {
  1846. case 5:
  1847. glNormal3fv(&n[0]); glVertex3fv(vtx+32);
  1848. glNormal3fv(&n[4]); glVertex3fv(vtx+36);
  1849. glNormal3fv(&n[8]); glVertex3fv(vtx+44);
  1850. glNormal3fv(&n[12]); glVertex3fv(vtx+40);
  1851. case 4:
  1852. glNormal3fv(&n[0]); glVertex3fv(vtx+24);
  1853. glNormal3fv(&n[4]); glVertex3fv(vtx+28);
  1854. glNormal3fv(&n[8]); glVertex3fv(vtx+36);
  1855. glNormal3fv(&n[12]); glVertex3fv(vtx+32);
  1856. case 3:
  1857. glNormal3fv(&n[0]); glVertex3fv(vtx+16);
  1858. glNormal3fv(&n[4]); glVertex3fv(vtx+20);
  1859. glNormal3fv(&n[8]); glVertex3fv(vtx+28);
  1860. glNormal3fv(&n[12]); glVertex3fv(vtx+24);
  1861. case 2:
  1862. glNormal3fv(&n[0]); glVertex3fv(vtx+8);
  1863. glNormal3fv(&n[4]); glVertex3fv(vtx+12);
  1864. glNormal3fv(&n[8]); glVertex3fv(vtx+20);
  1865. glNormal3fv(&n[12]); glVertex3fv(vtx+16);
  1866. case 1:
  1867. glNormal3fv(&n[0]); glVertex3fv(vtx);
  1868. glNormal3fv(&n[4]); glVertex3fv(vtx+4);
  1869. glNormal3fv(&n[8]); glVertex3fv(vtx+12);
  1870. glNormal3fv(&n[12]); glVertex3fv(vtx+8);
  1871. }
  1872. glEnd();
  1873. }
  1874. secs = timer(1);
  1875. }
  1876. }
  1877. rate = rate * (secspertest/secs);
  1878. rate = cPoly * (rate/cPoly);
  1879. for (k=0; k<loopcount; k++) {
  1880. if (mod_lmcolor) {
  1881. if (starttest(k)) {
  1882. for(i=(rate)/cPoly; i; i--) {
  1883. glBegin(GL_QUADS);
  1884. switch (cPoly) {
  1885. case 5:
  1886. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  1887. glVertex3fv(vtx+32);
  1888. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  1889. glVertex3fv(vtx+36);
  1890. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  1891. glVertex3fv(vtx+44);
  1892. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  1893. glVertex3fv(vtx+40);
  1894. case 4:
  1895. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  1896. glVertex3fv(vtx+24);
  1897. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  1898. glVertex3fv(vtx+28);
  1899. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  1900. glVertex3fv(vtx+36);
  1901. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  1902. glVertex3fv(vtx+32);
  1903. case 3:
  1904. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  1905. glVertex3fv(vtx+16);
  1906. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  1907. glVertex3fv(vtx+20);
  1908. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  1909. glVertex3fv(vtx+28);
  1910. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  1911. glVertex3fv(vtx+24);
  1912. case 2:
  1913. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  1914. glVertex3fv(vtx+8);
  1915. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  1916. glVertex3fv(vtx+12);
  1917. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  1918. glVertex3fv(vtx+20);
  1919. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  1920. glVertex3fv(vtx+16);
  1921. case 1:
  1922. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  1923. glVertex3fv(vtx);
  1924. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  1925. glVertex3fv(vtx+4);
  1926. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  1927. glVertex3fv(vtx+12);
  1928. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  1929. glVertex3fv(vtx+8);
  1930. }
  1931. glEnd();
  1932. }
  1933. }
  1934. endtest(pbuf, rate, 0);
  1935. }
  1936. else {
  1937. if (starttest(k)) {
  1938. for(i=(rate)/cPoly; i; i--) {
  1939. glBegin(GL_QUADS);
  1940. switch (cPoly) {
  1941. case 5:
  1942. glNormal3fv(&n[0]); glVertex3fv(vtx+32);
  1943. glNormal3fv(&n[4]); glVertex3fv(vtx+36);
  1944. glNormal3fv(&n[8]); glVertex3fv(vtx+44);
  1945. glNormal3fv(&n[12]); glVertex3fv(vtx+40);
  1946. case 4:
  1947. glNormal3fv(&n[0]); glVertex3fv(vtx+24);
  1948. glNormal3fv(&n[4]); glVertex3fv(vtx+28);
  1949. glNormal3fv(&n[8]); glVertex3fv(vtx+36);
  1950. glNormal3fv(&n[12]); glVertex3fv(vtx+32);
  1951. case 3:
  1952. glNormal3fv(&n[0]); glVertex3fv(vtx+16);
  1953. glNormal3fv(&n[4]); glVertex3fv(vtx+20);
  1954. glNormal3fv(&n[8]); glVertex3fv(vtx+28);
  1955. glNormal3fv(&n[12]); glVertex3fv(vtx+24);
  1956. case 2:
  1957. glNormal3fv(&n[0]); glVertex3fv(vtx+8);
  1958. glNormal3fv(&n[4]); glVertex3fv(vtx+12);
  1959. glNormal3fv(&n[8]); glVertex3fv(vtx+20);
  1960. glNormal3fv(&n[12]); glVertex3fv(vtx+16);
  1961. case 1:
  1962. glNormal3fv(&n[0]); glVertex3fv(vtx);
  1963. glNormal3fv(&n[4]); glVertex3fv(vtx+4);
  1964. glNormal3fv(&n[8]); glVertex3fv(vtx+12);
  1965. glNormal3fv(&n[12]); glVertex3fv(vtx+8);
  1966. }
  1967. glEnd();
  1968. }
  1969. }
  1970. endtest(pbuf, rate, 0);
  1971. }
  1972. }
  1973. glPopMatrix();
  1974. }
  1975. printaverage();
  1976. } else if (mod_shade && !mod_cmode) {
  1977. /*** POLYGONS (SHADED RGB) *****/
  1978. sum_secs = 0.0;
  1979. sum_n = 0;
  1980. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  1981. if (!mod_average)
  1982. sprintf(pbuf, "Angle %6.2f", angle);
  1983. glPushMatrix();
  1984. glRotatef(angle-90.0, 0, 0, 1);
  1985. /****** Calibration Loop ******/
  1986. secs = 0.0; rate = 125;
  1987. while (secs < (secspertest/4.0)) {
  1988. rate = rate*2;
  1989. starttest(0);
  1990. for(i=(rate)/cPoly; i; i--) {
  1991. glBegin(GL_QUADS);
  1992. switch (cPoly) {
  1993. case 5:
  1994. glColor3fv(&c[4]); glVertex3fv(vtx+32);
  1995. glColor3fv(&c[16]); glVertex3fv(vtx+36);
  1996. glColor3fv(&c[8]); glVertex3fv(vtx+44);
  1997. glColor3fv(&c[8]); glVertex3fv(vtx+40);
  1998. case 4:
  1999. glColor3fv(&c[4]); glVertex3fv(vtx+24);
  2000. glColor3fv(&c[16]); glVertex3fv(vtx+28);
  2001. glColor3fv(&c[8]); glVertex3fv(vtx+36);
  2002. glColor3fv(&c[8]); glVertex3fv(vtx+32);
  2003. case 3:
  2004. glColor3fv(&c[4]); glVertex3fv(vtx+16);
  2005. glColor3fv(&c[16]); glVertex3fv(vtx+20);
  2006. glColor3fv(&c[8]); glVertex3fv(vtx+28);
  2007. glColor3fv(&c[8]); glVertex3fv(vtx+24);
  2008. case 2:
  2009. glColor3fv(&c[4]); glVertex3fv(vtx+8);
  2010. glColor3fv(&c[16]); glVertex3fv(vtx+12);
  2011. glColor3fv(&c[8]); glVertex3fv(vtx+20);
  2012. glColor3fv(&c[8]); glVertex3fv(vtx+16);
  2013. case 1:
  2014. glColor3fv(&c[4]); glVertex3fv(vtx);
  2015. glColor3fv(&c[16]); glVertex3fv(vtx+4);
  2016. glColor3fv(&c[8]); glVertex3fv(vtx+12);
  2017. glColor3fv(&c[8]); glVertex3fv(vtx+8);
  2018. }
  2019. glEnd();
  2020. }
  2021. secs = timer(1);
  2022. }
  2023. rate = rate * (secspertest/secs);
  2024. rate = cPoly * (rate/cPoly);
  2025. for (k=0; k<loopcount; k++) {
  2026. if (starttest(k)) {
  2027. for(i=(rate)/cPoly; i; i--) {
  2028. glBegin(GL_QUADS);
  2029. switch (cPoly) {
  2030. case 5:
  2031. glColor3fv(&c[4]); glVertex3fv(vtx+32);
  2032. glColor3fv(&c[16]); glVertex3fv(vtx+36);
  2033. glColor3fv(&c[8]); glVertex3fv(vtx+44);
  2034. glColor3fv(&c[8]); glVertex3fv(vtx+40);
  2035. case 4:
  2036. glColor3fv(&c[4]); glVertex3fv(vtx+24);
  2037. glColor3fv(&c[16]); glVertex3fv(vtx+28);
  2038. glColor3fv(&c[8]); glVertex3fv(vtx+36);
  2039. glColor3fv(&c[8]); glVertex3fv(vtx+32);
  2040. case 3:
  2041. glColor3fv(&c[4]); glVertex3fv(vtx+16);
  2042. glColor3fv(&c[16]); glVertex3fv(vtx+20);
  2043. glColor3fv(&c[8]); glVertex3fv(vtx+28);
  2044. glColor3fv(&c[8]); glVertex3fv(vtx+24);
  2045. case 2:
  2046. glColor3fv(&c[4]); glVertex3fv(vtx+8);
  2047. glColor3fv(&c[16]); glVertex3fv(vtx+12);
  2048. glColor3fv(&c[8]); glVertex3fv(vtx+20);
  2049. glColor3fv(&c[8]); glVertex3fv(vtx+16);
  2050. case 1:
  2051. glColor3fv(&c[4]); glVertex3fv(vtx);
  2052. glColor3fv(&c[16]); glVertex3fv(vtx+4);
  2053. glColor3fv(&c[8]); glVertex3fv(vtx+12);
  2054. glColor3fv(&c[8]); glVertex3fv(vtx+8);
  2055. }
  2056. glEnd();
  2057. }
  2058. }
  2059. endtest(pbuf, rate, 0);
  2060. }
  2061. glPopMatrix();
  2062. }
  2063. printaverage();
  2064. } else if (mod_shade && mod_cmode) {
  2065. /*** POLYGONS (SHADED COLOR MAPPED) *****/
  2066. /* 255 = r, 240 = g, 255 = b */
  2067. makeramp(208, 255, 0, 0, 0, 0, 255, 16);
  2068. makeramp(224, 0, 0, 255, 255, 255, 0, 16);
  2069. makeramp(240, 255, 255, 0, 255, 0, 255, 16);
  2070. sum_secs = 0.0;
  2071. sum_n = 0;
  2072. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  2073. if (!mod_average)
  2074. sprintf(pbuf, "Angle %6.2f", angle);
  2075. glPushMatrix();
  2076. glRotatef(angle-90.0, 0, 0, 1);
  2077. /****** Calibration Loop ******/
  2078. secs = 0.0; rate = 125;
  2079. while (secs < (secspertest/4.0)) {
  2080. rate = rate*2;
  2081. starttest(0);
  2082. for(i=(rate)/cPoly; i; i--) {
  2083. glBegin(GL_QUADS);
  2084. switch (cPoly) {
  2085. case 5:
  2086. glIndexi(255); glVertex3fv(vtx+32);
  2087. glIndexi(240); glVertex3fv(vtx+36);
  2088. glIndexi(223); glVertex3fv(vtx+44);
  2089. glIndexi(208); glVertex3fv(vtx+40);
  2090. case 4:
  2091. glIndexi(255); glVertex3fv(vtx+24);
  2092. glIndexi(240); glVertex3fv(vtx+28);
  2093. glIndexi(223); glVertex3fv(vtx+36);
  2094. glIndexi(208); glVertex3fv(vtx+32);
  2095. case 3:
  2096. glIndexi(255); glVertex3fv(vtx+16);
  2097. glIndexi(240); glVertex3fv(vtx+20);
  2098. glIndexi(223); glVertex3fv(vtx+28);
  2099. glIndexi(208); glVertex3fv(vtx+24);
  2100. case 2:
  2101. glIndexi(255); glVertex3fv(vtx+8);
  2102. glIndexi(240); glVertex3fv(vtx+12);
  2103. glIndexi(223); glVertex3fv(vtx+20);
  2104. glIndexi(208); glVertex3fv(vtx+16);
  2105. case 1:
  2106. glIndexi(255); glVertex3fv(vtx);
  2107. glIndexi(240); glVertex3fv(vtx+4);
  2108. glIndexi(223); glVertex3fv(vtx+12);
  2109. glIndexi(208); glVertex3fv(vtx+8);
  2110. }
  2111. glEnd();
  2112. }
  2113. secs = timer(1);
  2114. }
  2115. rate = rate * (secspertest/secs);
  2116. rate = cPoly * (rate/cPoly);
  2117. for (k=0; k<loopcount; k++) {
  2118. if (starttest(k)) {
  2119. for(i=(rate)/cPoly; i; i--) {
  2120. glBegin(GL_QUADS);
  2121. switch (cPoly) {
  2122. case 5:
  2123. glIndexi(255); glVertex3fv(vtx+32);
  2124. glIndexi(240); glVertex3fv(vtx+36);
  2125. glIndexi(223); glVertex3fv(vtx+44);
  2126. glIndexi(208); glVertex3fv(vtx+40);
  2127. case 4:
  2128. glIndexi(255); glVertex3fv(vtx+24);
  2129. glIndexi(240); glVertex3fv(vtx+28);
  2130. glIndexi(223); glVertex3fv(vtx+36);
  2131. glIndexi(208); glVertex3fv(vtx+32);
  2132. case 3:
  2133. glIndexi(255); glVertex3fv(vtx+16);
  2134. glIndexi(240); glVertex3fv(vtx+20);
  2135. glIndexi(223); glVertex3fv(vtx+28);
  2136. glIndexi(208); glVertex3fv(vtx+24);
  2137. case 2:
  2138. glIndexi(255); glVertex3fv(vtx+8);
  2139. glIndexi(240); glVertex3fv(vtx+12);
  2140. glIndexi(223); glVertex3fv(vtx+20);
  2141. glIndexi(208); glVertex3fv(vtx+16);
  2142. case 1:
  2143. glIndexi(255); glVertex3fv(vtx);
  2144. glIndexi(240); glVertex3fv(vtx+4);
  2145. glIndexi(223); glVertex3fv(vtx+12);
  2146. glIndexi(208); glVertex3fv(vtx+8);
  2147. }
  2148. glEnd();
  2149. }
  2150. }
  2151. endtest(pbuf, rate, 0);
  2152. }
  2153. glPopMatrix();
  2154. }
  2155. printaverage();
  2156. } else if (!mod_light && !mod_shade) {
  2157. /*** POLYGONS (FLAT SHADED) *****/
  2158. sum_secs = 0.0;
  2159. sum_n = 0;
  2160. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  2161. if (!mod_average)
  2162. sprintf(pbuf, "Angle %6.2f", angle);
  2163. glPushMatrix();
  2164. glRotatef(angle-90.0, 0, 0, 1);
  2165. /****** Calibration Loop ******/
  2166. secs = 0.0; rate = 125;
  2167. while (secs < (secspertest/4.0)) {
  2168. rate = rate*2;
  2169. starttest(0);
  2170. for(i=(rate)/cPoly; i; i--) {
  2171. glBegin(GL_QUADS);
  2172. switch (cPoly) {
  2173. case 5:
  2174. glVertex3fv(vtx+32); glVertex3fv(vtx+36);
  2175. glVertex3fv(vtx+44); glVertex3fv(vtx+40);
  2176. case 4:
  2177. glVertex3fv(vtx+24); glVertex3fv(vtx+28);
  2178. glVertex3fv(vtx+36); glVertex3fv(vtx+32);
  2179. case 3:
  2180. glVertex3fv(vtx+16); glVertex3fv(vtx+20);
  2181. glVertex3fv(vtx+28); glVertex3fv(vtx+24);
  2182. case 2:
  2183. glVertex3fv(vtx+8); glVertex3fv(vtx+12);
  2184. glVertex3fv(vtx+20); glVertex3fv(vtx+16);
  2185. case 1:
  2186. glVertex3fv(vtx); glVertex3fv(vtx+4);
  2187. glVertex3fv(vtx+12); glVertex3fv(vtx+8);
  2188. }
  2189. glEnd();
  2190. }
  2191. secs = timer(1);
  2192. }
  2193. rate = rate * (secspertest/secs);
  2194. rate = cPoly * (rate/cPoly);
  2195. for (k=0; k<loopcount; k++) {
  2196. if (starttest(k)) {
  2197. for(i=(rate)/cPoly; i; i--) {
  2198. glBegin(GL_QUADS);
  2199. switch (cPoly) {
  2200. case 5:
  2201. glVertex3fv(vtx+32); glVertex3fv(vtx+36);
  2202. glVertex3fv(vtx+44); glVertex3fv(vtx+40);
  2203. case 4:
  2204. glVertex3fv(vtx+24); glVertex3fv(vtx+28);
  2205. glVertex3fv(vtx+36); glVertex3fv(vtx+32);
  2206. case 3:
  2207. glVertex3fv(vtx+16); glVertex3fv(vtx+20);
  2208. glVertex3fv(vtx+28); glVertex3fv(vtx+24);
  2209. case 2:
  2210. glVertex3fv(vtx+8); glVertex3fv(vtx+12);
  2211. glVertex3fv(vtx+20); glVertex3fv(vtx+16);
  2212. case 1:
  2213. glVertex3fv(vtx+0); glVertex3fv(vtx+4);
  2214. glVertex3fv(vtx+12); glVertex3fv(vtx+8);
  2215. }
  2216. glEnd();
  2217. }
  2218. }
  2219. endtest(pbuf, rate, 0);
  2220. }
  2221. glPopMatrix();
  2222. }
  2223. printaverage();
  2224. }
  2225. } else {
  2226. /**** 2D POLYGONS ****/
  2227. if (mod_light && !mod_cmode) {
  2228. /*** POLYGONS (LIGHTED) *****/
  2229. glLoadIdentity();
  2230. glMatrixMode(GL_PROJECTION);
  2231. glLoadIdentity();
  2232. gluOrtho2D(-0.5*xsize, 0.5*xsize,-0.5*ysize, 0.5*ysize);
  2233. glMatrixMode(GL_MODELVIEW);
  2234. /* set lights */
  2235. setLightingParameters();
  2236. sum_secs = 0.0;
  2237. sum_n = 0;
  2238. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  2239. if (!mod_average)
  2240. sprintf(pbuf, "Angle %6.2f", angle);
  2241. glPushMatrix();
  2242. glRotatef(angle-90.0, 0, 0, 1);
  2243. /****** Calibration Loop ******/
  2244. secs = 0.0; rate = 125;
  2245. while (secs < (secspertest/4.0)) {
  2246. rate = rate*2;
  2247. if (mod_lmcolor) {
  2248. starttest(0);
  2249. for(i=(rate)/cPoly; i; i--) {
  2250. glBegin(GL_QUADS);
  2251. switch (cPoly) {
  2252. case 5:
  2253. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  2254. glVertex2fv(vtx+32);
  2255. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  2256. glVertex2fv(vtx+36);
  2257. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  2258. glVertex2fv(vtx+44);
  2259. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  2260. glVertex2fv(vtx+40);
  2261. case 4:
  2262. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  2263. glVertex2fv(vtx+24);
  2264. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  2265. glVertex2fv(vtx+28);
  2266. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  2267. glVertex2fv(vtx+36);
  2268. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  2269. glVertex2fv(vtx+32);
  2270. case 3:
  2271. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  2272. glVertex2fv(vtx+16);
  2273. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  2274. glVertex2fv(vtx+20);
  2275. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  2276. glVertex2fv(vtx+28);
  2277. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  2278. glVertex2fv(vtx+24);
  2279. case 2:
  2280. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  2281. glVertex2fv(vtx+8);
  2282. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  2283. glVertex2fv(vtx+12);
  2284. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  2285. glVertex2fv(vtx+20);
  2286. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  2287. glVertex2fv(vtx+16);
  2288. case 1:
  2289. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  2290. glVertex2fv(vtx);
  2291. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  2292. glVertex2fv(vtx+4);
  2293. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  2294. glVertex2fv(vtx+12);
  2295. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  2296. glVertex2fv(vtx+8);
  2297. }
  2298. glEnd();
  2299. }
  2300. secs = timer(1);
  2301. }
  2302. else {
  2303. starttest(0);
  2304. for(i=(rate)/cPoly; i; i--) {
  2305. glBegin(GL_QUADS);
  2306. switch (cPoly) {
  2307. case 5:
  2308. glNormal3fv(&n[0]); glVertex2fv(vtx+32);
  2309. glNormal3fv(&n[4]); glVertex2fv(vtx+36);
  2310. glNormal3fv(&n[8]); glVertex2fv(vtx+44);
  2311. glNormal3fv(&n[12]); glVertex2fv(vtx+40);
  2312. case 4:
  2313. glNormal3fv(&n[0]); glVertex2fv(vtx+24);
  2314. glNormal3fv(&n[4]); glVertex2fv(vtx+28);
  2315. glNormal3fv(&n[8]); glVertex2fv(vtx+36);
  2316. glNormal3fv(&n[12]); glVertex2fv(vtx+32);
  2317. case 3:
  2318. glNormal3fv(&n[0]); glVertex2fv(vtx+16);
  2319. glNormal3fv(&n[4]); glVertex2fv(vtx+20);
  2320. glNormal3fv(&n[8]); glVertex2fv(vtx+28);
  2321. glNormal3fv(&n[12]); glVertex2fv(vtx+24);
  2322. case 2:
  2323. glNormal3fv(&n[0]); glVertex2fv(vtx+8);
  2324. glNormal3fv(&n[4]); glVertex2fv(vtx+12);
  2325. glNormal3fv(&n[8]); glVertex2fv(vtx+20);
  2326. glNormal3fv(&n[12]); glVertex2fv(vtx+16);
  2327. case 1:
  2328. glNormal3fv(&n[0]); glVertex2fv(vtx);
  2329. glNormal3fv(&n[4]); glVertex2fv(vtx+4);
  2330. glNormal3fv(&n[8]); glVertex2fv(vtx+12);
  2331. glNormal3fv(&n[12]); glVertex2fv(vtx+8);
  2332. }
  2333. glEnd();
  2334. }
  2335. secs = timer(1);
  2336. }
  2337. }
  2338. rate = rate * (secspertest/secs);
  2339. rate = cPoly * (rate/cPoly);
  2340. for (k=0; k<loopcount; k++) {
  2341. if (mod_lmcolor) {
  2342. if (starttest(k)) {
  2343. for(i=(rate)/cPoly; i; i--) {
  2344. glBegin(GL_QUADS);
  2345. switch (cPoly) {
  2346. case 5:
  2347. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  2348. glVertex2fv(vtx+32);
  2349. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  2350. glVertex2fv(vtx+36);
  2351. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  2352. glVertex2fv(vtx+44);
  2353. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  2354. glVertex2fv(vtx+40);
  2355. case 4:
  2356. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  2357. glVertex2fv(vtx+24);
  2358. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  2359. glVertex2fv(vtx+28);
  2360. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  2361. glVertex2fv(vtx+36);
  2362. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  2363. glVertex2fv(vtx+32);
  2364. case 3:
  2365. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  2366. glVertex2fv(vtx+16);
  2367. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  2368. glVertex2fv(vtx+20);
  2369. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  2370. glVertex2fv(vtx+28);
  2371. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  2372. glVertex2fv(vtx+24);
  2373. case 2:
  2374. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  2375. glVertex2fv(vtx+8);
  2376. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  2377. glVertex2fv(vtx+12);
  2378. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  2379. glVertex2fv(vtx+20);
  2380. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  2381. glVertex2fv(vtx+16);
  2382. case 1:
  2383. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  2384. glVertex2fv(vtx);
  2385. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  2386. glVertex2fv(vtx+4);
  2387. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  2388. glVertex2fv(vtx+12);
  2389. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  2390. glVertex2fv(vtx+8);
  2391. }
  2392. glEnd();
  2393. }
  2394. }
  2395. endtest(pbuf, rate, 0);
  2396. }
  2397. else {
  2398. if (starttest(k)) {
  2399. for(i=(rate)/cPoly; i; i--) {
  2400. glBegin(GL_QUADS);
  2401. switch (cPoly) {
  2402. case 5:
  2403. glNormal3fv(&n[0]); glVertex2fv(vtx+32);
  2404. glNormal3fv(&n[4]); glVertex2fv(vtx+36);
  2405. glNormal3fv(&n[8]); glVertex2fv(vtx+44);
  2406. glNormal3fv(&n[12]); glVertex2fv(vtx+40);
  2407. case 4:
  2408. glNormal3fv(&n[0]); glVertex2fv(vtx+24);
  2409. glNormal3fv(&n[4]); glVertex2fv(vtx+28);
  2410. glNormal3fv(&n[8]); glVertex2fv(vtx+36);
  2411. glNormal3fv(&n[12]); glVertex2fv(vtx+32);
  2412. case 3:
  2413. glNormal3fv(&n[0]); glVertex2fv(vtx+16);
  2414. glNormal3fv(&n[4]); glVertex2fv(vtx+20);
  2415. glNormal3fv(&n[8]); glVertex2fv(vtx+28);
  2416. glNormal3fv(&n[12]); glVertex2fv(vtx+24);
  2417. case 2:
  2418. glNormal3fv(&n[0]); glVertex2fv(vtx+8);
  2419. glNormal3fv(&n[4]); glVertex2fv(vtx+12);
  2420. glNormal3fv(&n[8]); glVertex2fv(vtx+20);
  2421. glNormal3fv(&n[12]); glVertex2fv(vtx+16);
  2422. case 1:
  2423. glNormal3fv(&n[0]); glVertex2fv(vtx);
  2424. glNormal3fv(&n[4]); glVertex2fv(vtx+4);
  2425. glNormal3fv(&n[8]); glVertex2fv(vtx+12);
  2426. glNormal3fv(&n[12]); glVertex2fv(vtx+8);
  2427. }
  2428. glEnd();
  2429. }
  2430. }
  2431. endtest(pbuf, rate, 0);
  2432. }
  2433. }
  2434. glPopMatrix();
  2435. }
  2436. printaverage();
  2437. } else if (mod_shade && !mod_cmode) {
  2438. /*** POLYGONS (SHADED RGB) *****/
  2439. sum_secs = 0.0;
  2440. sum_n = 0;
  2441. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  2442. if (!mod_average)
  2443. sprintf(pbuf, "Angle %6.2f", angle);
  2444. glPushMatrix();
  2445. glRotatef(angle-90.0, 0, 0, 1);
  2446. /****** Calibration Loop ******/
  2447. secs = 0.0; rate = 125;
  2448. while (secs < (secspertest/4.0)) {
  2449. rate = rate*2;
  2450. starttest(0);
  2451. for(i=(rate)/cPoly; i; i--) {
  2452. glBegin(GL_QUADS);
  2453. switch (cPoly) {
  2454. case 5:
  2455. glColor3fv(&c[4]); glVertex2fv(vtx+32);
  2456. glColor3fv(&c[16]); glVertex2fv(vtx+36);
  2457. glColor3fv(&c[8]); glVertex2fv(vtx+44);
  2458. glColor3fv(&c[8]); glVertex2fv(vtx+40);
  2459. case 4:
  2460. glColor3fv(&c[4]); glVertex2fv(vtx+24);
  2461. glColor3fv(&c[16]); glVertex2fv(vtx+28);
  2462. glColor3fv(&c[8]); glVertex2fv(vtx+36);
  2463. glColor3fv(&c[8]); glVertex2fv(vtx+32);
  2464. case 3:
  2465. glColor3fv(&c[4]); glVertex2fv(vtx+16);
  2466. glColor3fv(&c[16]); glVertex2fv(vtx+20);
  2467. glColor3fv(&c[8]); glVertex2fv(vtx+28);
  2468. glColor3fv(&c[8]); glVertex2fv(vtx+24);
  2469. case 2:
  2470. glColor3fv(&c[4]); glVertex2fv(vtx+8);
  2471. glColor3fv(&c[16]); glVertex2fv(vtx+12);
  2472. glColor3fv(&c[8]); glVertex2fv(vtx+20);
  2473. glColor3fv(&c[8]); glVertex2fv(vtx+16);
  2474. case 1:
  2475. glColor3fv(&c[4]); glVertex2fv(vtx);
  2476. glColor3fv(&c[16]); glVertex2fv(vtx+4);
  2477. glColor3fv(&c[8]); glVertex2fv(vtx+12);
  2478. glColor3fv(&c[8]); glVertex2fv(vtx+8);
  2479. }
  2480. glEnd();
  2481. }
  2482. secs = timer(1);
  2483. }
  2484. rate = rate * (secspertest/secs);
  2485. rate = cPoly * (rate/cPoly);
  2486. for (k=0; k<loopcount; k++) {
  2487. if (starttest(k)) {
  2488. for(i=(rate)/cPoly; i; i--) {
  2489. glBegin(GL_QUADS);
  2490. switch (cPoly) {
  2491. case 5:
  2492. glColor3fv(&c[4]); glVertex2fv(vtx+32);
  2493. glColor3fv(&c[16]); glVertex2fv(vtx+36);
  2494. glColor3fv(&c[8]); glVertex2fv(vtx+44);
  2495. glColor3fv(&c[8]); glVertex2fv(vtx+40);
  2496. case 4:
  2497. glColor3fv(&c[4]); glVertex2fv(vtx+24);
  2498. glColor3fv(&c[16]); glVertex2fv(vtx+28);
  2499. glColor3fv(&c[8]); glVertex2fv(vtx+36);
  2500. glColor3fv(&c[8]); glVertex2fv(vtx+32);
  2501. case 3:
  2502. glColor3fv(&c[4]); glVertex2fv(vtx+16);
  2503. glColor3fv(&c[16]); glVertex2fv(vtx+20);
  2504. glColor3fv(&c[8]); glVertex2fv(vtx+28);
  2505. glColor3fv(&c[8]); glVertex2fv(vtx+24);
  2506. case 2:
  2507. glColor3fv(&c[4]); glVertex2fv(vtx+8);
  2508. glColor3fv(&c[16]); glVertex2fv(vtx+12);
  2509. glColor3fv(&c[8]); glVertex2fv(vtx+20);
  2510. glColor3fv(&c[8]); glVertex2fv(vtx+16);
  2511. case 1:
  2512. glColor3fv(&c[4]); glVertex2fv(vtx);
  2513. glColor3fv(&c[16]); glVertex2fv(vtx+4);
  2514. glColor3fv(&c[8]); glVertex2fv(vtx+12);
  2515. glColor3fv(&c[8]); glVertex2fv(vtx+8);
  2516. }
  2517. glEnd();
  2518. }
  2519. }
  2520. endtest(pbuf, rate, 0);
  2521. }
  2522. glPopMatrix();
  2523. }
  2524. printaverage();
  2525. } else if (mod_shade && mod_cmode) {
  2526. /*** POLYGONS (SHADED COLOR MAPPED) *****/
  2527. /* 255 = r, 240 = g, 255 = b */
  2528. makeramp(208, 255, 0, 0, 0, 0, 255, 16);
  2529. makeramp(224, 0, 0, 255, 255, 255, 0, 16);
  2530. makeramp(240, 255, 255, 0, 255, 0, 255, 16);
  2531. sum_secs = 0.0;
  2532. sum_n = 0;
  2533. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  2534. if (!mod_average)
  2535. sprintf(pbuf, "Angle %6.2f", angle);
  2536. glPushMatrix();
  2537. glRotatef(angle-90.0, 0, 0, 1);
  2538. /****** Calibration Loop ******/
  2539. secs = 0.0; rate = 125;
  2540. while (secs < (secspertest/4.0)) {
  2541. rate = rate*2;
  2542. starttest(0);
  2543. for(i=(rate)/cPoly; i; i--) {
  2544. glBegin(GL_QUADS);
  2545. switch (cPoly) {
  2546. case 5:
  2547. glIndexi(255); glVertex2fv(vtx+32);
  2548. glIndexi(240); glVertex2fv(vtx+36);
  2549. glIndexi(223); glVertex2fv(vtx+44);
  2550. glIndexi(208); glVertex2fv(vtx+40);
  2551. case 4:
  2552. glIndexi(255); glVertex2fv(vtx+24);
  2553. glIndexi(240); glVertex2fv(vtx+28);
  2554. glIndexi(223); glVertex2fv(vtx+36);
  2555. glIndexi(208); glVertex2fv(vtx+32);
  2556. case 3:
  2557. glIndexi(255); glVertex2fv(vtx+16);
  2558. glIndexi(240); glVertex2fv(vtx+20);
  2559. glIndexi(223); glVertex2fv(vtx+28);
  2560. glIndexi(208); glVertex2fv(vtx+24);
  2561. case 2:
  2562. glIndexi(255); glVertex2fv(vtx+8);
  2563. glIndexi(240); glVertex2fv(vtx+12);
  2564. glIndexi(223); glVertex2fv(vtx+20);
  2565. glIndexi(208); glVertex2fv(vtx+16);
  2566. case 1:
  2567. glIndexi(255); glVertex2fv(vtx);
  2568. glIndexi(240); glVertex2fv(vtx+4);
  2569. glIndexi(223); glVertex2fv(vtx+12);
  2570. glIndexi(208); glVertex2fv(vtx+8);
  2571. }
  2572. glEnd();
  2573. }
  2574. secs = timer(1);
  2575. }
  2576. rate = rate * (secspertest/secs);
  2577. rate = cPoly * (rate/cPoly);
  2578. for (k=0; k<loopcount; k++) {
  2579. if (starttest(k)) {
  2580. for(i=(rate)/cPoly; i; i--) {
  2581. glBegin(GL_QUADS);
  2582. switch (cPoly) {
  2583. case 5:
  2584. glIndexi(255); glVertex2fv(vtx+32);
  2585. glIndexi(240); glVertex2fv(vtx+36);
  2586. glIndexi(223); glVertex2fv(vtx+44);
  2587. glIndexi(208); glVertex2fv(vtx+40);
  2588. case 4:
  2589. glIndexi(255); glVertex2fv(vtx+24);
  2590. glIndexi(240); glVertex2fv(vtx+28);
  2591. glIndexi(223); glVertex2fv(vtx+36);
  2592. glIndexi(208); glVertex2fv(vtx+32);
  2593. case 3:
  2594. glIndexi(255); glVertex2fv(vtx+16);
  2595. glIndexi(240); glVertex2fv(vtx+20);
  2596. glIndexi(223); glVertex2fv(vtx+28);
  2597. glIndexi(208); glVertex2fv(vtx+24);
  2598. case 2:
  2599. glIndexi(255); glVertex2fv(vtx+8);
  2600. glIndexi(240); glVertex2fv(vtx+12);
  2601. glIndexi(223); glVertex2fv(vtx+20);
  2602. glIndexi(208); glVertex2fv(vtx+16);
  2603. case 1:
  2604. glIndexi(255); glVertex2fv(vtx);
  2605. glIndexi(240); glVertex2fv(vtx+4);
  2606. glIndexi(223); glVertex2fv(vtx+12);
  2607. glIndexi(208); glVertex2fv(vtx+8);
  2608. }
  2609. glEnd();
  2610. }
  2611. }
  2612. endtest(pbuf, rate, 0);
  2613. }
  2614. glPopMatrix();
  2615. }
  2616. printaverage();
  2617. } else if (!mod_light && !mod_shade) {
  2618. /*** POLYGONS (FLAT SHADED) *****/
  2619. sum_secs = 0.0;
  2620. sum_n = 0;
  2621. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  2622. if (!mod_average)
  2623. sprintf(pbuf, "Angle %6.2f", angle);
  2624. glPushMatrix();
  2625. glRotatef(angle-90.0, 0, 0, 1);
  2626. /****** Calibration Loop ******/
  2627. secs = 0.0; rate = 125;
  2628. while (secs < (secspertest/4.0)) {
  2629. rate = rate*2;
  2630. starttest(0);
  2631. for(i=(rate)/cPoly; i; i--) {
  2632. glBegin(GL_QUADS);
  2633. switch (cPoly) {
  2634. case 5:
  2635. glVertex2fv(vtx+32); glVertex2fv(vtx+36);
  2636. glVertex2fv(vtx+44); glVertex2fv(vtx+40);
  2637. case 4:
  2638. glVertex2fv(vtx+24); glVertex2fv(vtx+28);
  2639. glVertex2fv(vtx+36); glVertex2fv(vtx+32);
  2640. case 3:
  2641. glVertex2fv(vtx+16); glVertex2fv(vtx+20);
  2642. glVertex2fv(vtx+28); glVertex2fv(vtx+24);
  2643. case 2:
  2644. glVertex2fv(vtx+8); glVertex2fv(vtx+12);
  2645. glVertex2fv(vtx+20); glVertex2fv(vtx+16);
  2646. case 1:
  2647. glVertex2fv(vtx); glVertex2fv(vtx+4);
  2648. glVertex2fv(vtx+12); glVertex2fv(vtx+8);
  2649. }
  2650. glEnd();
  2651. }
  2652. secs = timer(1);
  2653. }
  2654. rate = rate * (secspertest/secs);
  2655. rate = cPoly * (rate/cPoly);
  2656. for (k=0; k<loopcount; k++) {
  2657. if (starttest(k)) {
  2658. for(i=(rate)/cPoly; i; i--) {
  2659. glBegin(GL_QUADS);
  2660. switch (cPoly) {
  2661. case 5:
  2662. glVertex2fv(vtx+32); glVertex2fv(vtx+36);
  2663. glVertex2fv(vtx+44); glVertex2fv(vtx+40);
  2664. case 4:
  2665. glVertex2fv(vtx+24); glVertex2fv(vtx+28);
  2666. glVertex2fv(vtx+36); glVertex2fv(vtx+32);
  2667. case 3:
  2668. glVertex2fv(vtx+16); glVertex2fv(vtx+20);
  2669. glVertex2fv(vtx+28); glVertex2fv(vtx+24);
  2670. case 2:
  2671. glVertex2fv(vtx+8); glVertex2fv(vtx+12);
  2672. glVertex2fv(vtx+20); glVertex2fv(vtx+16);
  2673. case 1:
  2674. glVertex2fv(vtx); glVertex2fv(vtx+4);
  2675. glVertex2fv(vtx+12); glVertex2fv(vtx+8);
  2676. }
  2677. glEnd();
  2678. }
  2679. }
  2680. endtest(pbuf, rate, 0);
  2681. }
  2682. glPopMatrix();
  2683. }
  2684. printaverage();
  2685. }
  2686. }
  2687. if (mod_doublebuffer) {
  2688. auxSwapBuffers();
  2689. Sleep(2000); /* for visual feedback */
  2690. }
  2691. exit(0);
  2692. }
  2693. /* original fill rate was 25 */
  2694. #define FILL_RATE 1
  2695. static void perffill(void)
  2696. {
  2697. int i, j, k;
  2698. float boxx[5], boxy[5];
  2699. int boxsizes = 5; /* must be same a boxx, and boxy
  2700. * size */
  2701. boxx[0] = boxy[0] = 10;
  2702. boxx[1] = boxy[1] = 100;
  2703. boxx[2] = boxy[2] = 500;
  2704. boxx[3] = 640;
  2705. boxy[3] = 480;
  2706. boxx[4] = xsize;
  2707. boxy[4] = ysize;
  2708. if (mod_z) {
  2709. glEnable(GL_DEPTH_TEST);
  2710. glClear(GL_DEPTH_BUFFER_BIT);
  2711. }
  2712. if (mod_pattern) {
  2713. glEnable(GL_POLYGON_STIPPLE);
  2714. glPolygonStipple((GLubyte *) pattern);
  2715. }
  2716. glLoadIdentity();
  2717. glMatrixMode(GL_PROJECTION);
  2718. glLoadIdentity();
  2719. if (mod_2d)
  2720. gluOrtho2D(0.0, xsize, 0.0, ysize);
  2721. else
  2722. glOrtho(0.0, xsize, 0.0, ysize, 1.0, -1.0);
  2723. glMatrixMode(GL_MODELVIEW);
  2724. for (j = 0; j < boxsizes; j++) {
  2725. v[0] = 0.0;
  2726. v[1] = 0.0;
  2727. v[2] = 0.0;
  2728. v[4] = boxx[j];
  2729. v[5] = 0.0;
  2730. v[6] = 0.0; /* why the X.01? */
  2731. v[8] = boxx[j];
  2732. v[9] = boxy[j];
  2733. v[10] = 0.0;
  2734. v[12] = 0.0;
  2735. v[13] = boxy[j];
  2736. v[14] = 0.0;
  2737. if (mod_2d && !mod_z && !mod_shade && !mod_light) {
  2738. printf("Using FLAT shaded 2D screen aligned rectangles - no transforms\n");
  2739. fflush(stdout);
  2740. Sleep(250);
  2741. /*** RECTANGLES (SCREEN ALIGNED, FLAT SHADED) *****/
  2742. /****** Calibration Loop ******/
  2743. secs = 0.0;
  2744. rate = FILL_RATE;
  2745. while (secs < (secspertest/4.0)) {
  2746. rate = rate * 2;
  2747. starttest(0);
  2748. for (i = (rate); i; i--)
  2749. glRectf(0.0, 0.0, v[8], v[9]);
  2750. secs = timer(1);
  2751. }
  2752. rate = rate * (secspertest / secs);
  2753. if (rate < 1) rate = 1;
  2754. for (k = 0; k < loopcount; k++) {
  2755. if (starttest(k)) {
  2756. for (i = (rate); i; i--)
  2757. glRectf(0.0, 0.0, v[8], v[9]);
  2758. }
  2759. pixendtest("glRect() fill", rate, (int) boxx[j], (int) boxy[j]);
  2760. }
  2761. }
  2762. if (!mod_2d) {
  2763. /***** 3D DRAWING *****/
  2764. if (mod_cmode && mod_shade) {
  2765. /*** GOURAUD SHADED CMODE RECTANGLES, SCREEN ALIGNED ***/
  2766. /* 255 = r, 240 = g, 255 = b */
  2767. makeramp(208, 255, 0, 0, 0, 0, 255, 16);
  2768. makeramp(224, 0, 0, 255, 255, 255, 0, 16);
  2769. makeramp(240, 255, 255, 0, 255, 0, 255, 16);
  2770. secs = 0.0;
  2771. rate = FILL_RATE;
  2772. while (secs < (secspertest/4.0)) {
  2773. rate = rate * 2;
  2774. starttest(0);
  2775. for (i = (rate); i; i--) {
  2776. glBegin(GL_POLYGON);
  2777. glIndexi(255);
  2778. glVertex3fv(&v[0]);
  2779. glIndexi(240);
  2780. glVertex3fv(&v[4]);
  2781. glIndexi(223);
  2782. glVertex3fv(&v[8]);
  2783. glIndexi(208);
  2784. glVertex3fv(&v[12]);
  2785. glEnd();
  2786. }
  2787. secs = timer(1);
  2788. }
  2789. rate = rate * (secspertest / secs);
  2790. if (rate < 1) rate = 1;
  2791. for (k = 0; k < loopcount; k++) {
  2792. if (starttest(k)) {
  2793. for (i = (rate); i; i--) {
  2794. glBegin(GL_POLYGON);
  2795. glIndexi(255);
  2796. glVertex3fv(&v[0]);
  2797. glIndexi(240);
  2798. glVertex3fv(&v[4]);
  2799. glIndexi(223);
  2800. glVertex3fv(&v[8]);
  2801. glIndexi(208);
  2802. glVertex3fv(&v[12]);
  2803. glEnd();
  2804. }
  2805. }
  2806. pixendtest("rectangle fill", rate, (int) boxx[j], (int) boxy[j]);
  2807. }
  2808. } else if (!mod_shade && !mod_light) {
  2809. /*** RECTANGLES (SCREEN ALIGNED, FLAT SHADED) *****/
  2810. /****** Calibration Loop ******/
  2811. secs = 0.0;
  2812. rate = FILL_RATE;
  2813. while (secs < (secspertest/
  2814. 4.0)) {
  2815. rate = rate * 2;
  2816. starttest(0);
  2817. for (i = (rate); i; i--) {
  2818. glBegin(GL_POLYGON);
  2819. glVertex3fv(&v[0]);
  2820. glVertex3fv(&v[4]);
  2821. glVertex3fv(&v[8]);
  2822. glVertex3fv(&v[12]);
  2823. glEnd();
  2824. }
  2825. secs = timer(1);
  2826. }
  2827. rate = rate * (secspertest / secs);
  2828. if (rate < 1) rate = 1;
  2829. for (k = 0; k < loopcount; k++) {
  2830. if (starttest(k)) {
  2831. for (i = (rate); i; i--) {
  2832. glBegin(GL_POLYGON);
  2833. glVertex3fv(&v[0]);
  2834. glVertex3fv(&v[4]);
  2835. glVertex3fv(&v[8]);
  2836. glVertex3fv(&v[12]);
  2837. glEnd();
  2838. }
  2839. }
  2840. pixendtest("rectangle fill", rate, (int) boxx[j], (int) boxy[j]);
  2841. }
  2842. } else if (!mod_cmode && mod_light) {
  2843. /*** RECTANGLES (LIGHTED GOURAUD SHADED RBG SCREEN ALIGNED) ***/
  2844. glLoadIdentity();
  2845. glMatrixMode(GL_PROJECTION);
  2846. glLoadIdentity();
  2847. glOrtho(0.0, xsize, 0.0, ysize, 1.0, -1.0);
  2848. glMatrixMode(GL_MODELVIEW);
  2849. /* set lights */
  2850. setLightingParameters();
  2851. /****** Calibration Loop ******/
  2852. secs = 0.0;
  2853. rate = FILL_RATE;
  2854. while (secs < (secspertest/4.0)) {
  2855. rate = rate * 2;
  2856. starttest(0);
  2857. for (i = (rate); i; i--) {
  2858. glBegin(GL_POLYGON);
  2859. glNormal3fv(&n[0]);
  2860. glVertex3fv(&v[0]);
  2861. glNormal3fv(&n[4]);
  2862. glVertex3fv(&v[4]);
  2863. glNormal3fv(&n[8]);
  2864. glVertex3fv(&v[8]);
  2865. glNormal3fv(&n[12]);
  2866. glVertex3fv(&v[12]);
  2867. glEnd();
  2868. }
  2869. secs = timer(1);
  2870. }
  2871. rate = rate * (secspertest / secs);
  2872. if (rate < 1) rate = 1;
  2873. for (k = 0; k < loopcount; k++) {
  2874. if (starttest(k)) {
  2875. for (i = (rate); i; i--) {
  2876. glBegin(GL_POLYGON);
  2877. glNormal3fv(&n[0]);
  2878. glVertex3fv(&v[0]);
  2879. glNormal3fv(&n[4]);
  2880. glVertex3fv(&v[4]);
  2881. glNormal3fv(&n[8]);
  2882. glVertex3fv(&v[8]);
  2883. glNormal3fv(&n[12]);
  2884. glVertex3fv(&v[12]);
  2885. glEnd();
  2886. }
  2887. }
  2888. pixendtest("rectangle fill", rate, (int) boxx[j], (int) boxy[j]);
  2889. }
  2890. } else if (!mod_cmode && mod_shade) {
  2891. /*** RECTANGLES (SCREEN ALIGNED, RGB GOURAUD SHADED) *****/
  2892. /****** Calibration Loop ******/
  2893. secs = 0.0;
  2894. rate = FILL_RATE;
  2895. while (secs < (secspertest/4.0)) {
  2896. rate = rate * 2;
  2897. starttest(0);
  2898. for (i = (rate); i; i--) {
  2899. glBegin(GL_POLYGON);
  2900. glColor3fv(&c[4]);
  2901. glVertex3fv(&v[0]);
  2902. glColor3fv(&c[8]);
  2903. glVertex3fv(&v[4]);
  2904. glColor3fv(&c[12]);
  2905. glVertex3fv(&v[8]);
  2906. glColor3fv(&c[16]);
  2907. glVertex3fv(&v[12]);
  2908. glEnd();
  2909. }
  2910. secs = timer(1);
  2911. }
  2912. rate = rate * (secspertest / secs);
  2913. if (rate < 1) rate = 1;
  2914. for (k = 0; k < loopcount; k++) {
  2915. if (starttest(k)) {
  2916. for (i = (rate); i; i--) {
  2917. glBegin(GL_POLYGON);
  2918. glColor3fv(&c[4]);
  2919. glVertex3fv(&v[0]);
  2920. glColor3fv(&c[8]);
  2921. glVertex3fv(&v[4]);
  2922. glColor3fv(&c[12]);
  2923. glVertex3fv(&v[8]);
  2924. glColor3fv(&c[16]);
  2925. glVertex3fv(&v[12]);
  2926. glEnd();
  2927. }
  2928. }
  2929. pixendtest("rectangle fill", rate, (int) boxx[j], (int) boxy[j]);
  2930. }
  2931. }
  2932. } else { /***** 2D DRAWING *****/
  2933. if (mod_cmode && mod_shade) {
  2934. /*** GOURAUD SHADED CMODE SCREEN ALIGNED RECTANGLES ***/
  2935. /* 255 = r, 240 = g, 255 = b */
  2936. makeramp(208, 255, 0, 0, 0, 0, 255, 16);
  2937. makeramp(224, 0, 0, 255, 255, 255, 0, 16);
  2938. makeramp(240, 255, 255, 0, 255, 0, 255, 16);
  2939. secs = 0.0;
  2940. rate = FILL_RATE;
  2941. while (secs < (secspertest/4.0)) {
  2942. rate = rate * 2;
  2943. starttest(0);
  2944. for (i = (rate); i; i--) {
  2945. glBegin(GL_POLYGON);
  2946. glIndexi(255);
  2947. glVertex2fv(&v[0]);
  2948. glIndexi(240);
  2949. glVertex2fv(&v[4]);
  2950. glIndexi(223);
  2951. glVertex2fv(&v[8]);
  2952. glIndexi(208);
  2953. glVertex2fv(&v[12]);
  2954. glEnd();
  2955. }
  2956. secs = timer(1);
  2957. }
  2958. rate = rate * (secspertest / secs);
  2959. if (rate < 1) rate = 1;
  2960. for (k = 0; k < loopcount; k++) {
  2961. if (starttest(k)) {
  2962. for (i = (rate); i; i--) {
  2963. glBegin(GL_POLYGON);
  2964. glIndexi(255);
  2965. glVertex2fv(&v[0]);
  2966. glIndexi(240);
  2967. glVertex2fv(&v[4]);
  2968. glIndexi(223);
  2969. glVertex2fv(&v[8]);
  2970. glIndexi(208);
  2971. glVertex2fv(&v[12]);
  2972. glEnd();
  2973. }
  2974. }
  2975. pixendtest("rectangle fill", rate, (int) boxx[j], (int) boxy[j]);
  2976. }
  2977. } else if (!mod_shade && !mod_light) {
  2978. /*** RECTANGLES (SCREEN ALIGNED, FLAT SHADED) *****/
  2979. /****** Calibration Loop ******/
  2980. secs = 0.0;
  2981. rate = FILL_RATE;
  2982. while (secs < (secspertest/4.0)) {
  2983. rate = rate * 2;
  2984. starttest(0);
  2985. for (i = (rate); i; i--) {
  2986. glBegin(GL_POLYGON);
  2987. glVertex2fv(&v[0]);
  2988. glVertex2fv(&v[4]);
  2989. glVertex2fv(&v[8]);
  2990. glVertex2fv(&v[12]);
  2991. glEnd();
  2992. }
  2993. secs = timer(1);
  2994. }
  2995. rate = rate * (secspertest / secs);
  2996. if (rate < 1) rate = 1;
  2997. for (k = 0; k < loopcount; k++) {
  2998. if (starttest(k)) {
  2999. for (i = (rate); i; i--) {
  3000. glBegin(GL_POLYGON);
  3001. glVertex2fv(&v[0]);
  3002. glVertex2fv(&v[4]);
  3003. glVertex2fv(&v[8]);
  3004. glVertex2fv(&v[12]);
  3005. glEnd();
  3006. }
  3007. }
  3008. pixendtest("rectangle fill", rate, (int) boxx[j], (int) boxy[j]);
  3009. }
  3010. } else if (!mod_cmode && mod_light) {
  3011. /*** RECTANGLES (LIGHTED GOURAUD SHADED RBG SCREEN ALIGNED) ***/
  3012. glLoadIdentity();
  3013. glMatrixMode(GL_PROJECTION);
  3014. glLoadIdentity();
  3015. glOrtho(0.0, xsize, 0.0, ysize, 1.0, -1.0);
  3016. glMatrixMode(GL_MODELVIEW);
  3017. /* set lights */
  3018. setLightingParameters();
  3019. /****** Calibration Loop ******/
  3020. secs = 0.0;
  3021. rate = FILL_RATE;
  3022. while (secs < (secspertest/4.0)) {
  3023. rate = rate * 2;
  3024. starttest(0);
  3025. for (i = (rate); i; i--) {
  3026. glBegin(GL_POLYGON);
  3027. glNormal3fv(&n[0]);
  3028. glVertex2fv(&v[0]);
  3029. glNormal3fv(&n[4]);
  3030. glVertex2fv(&v[4]);
  3031. glNormal3fv(&n[8]);
  3032. glVertex2fv(&v[8]);
  3033. glNormal3fv(&n[12]);
  3034. glVertex2fv(&v[12]);
  3035. glEnd();
  3036. }
  3037. secs = timer(1);
  3038. }
  3039. rate = rate * (secspertest / secs);
  3040. if (rate < 1) rate = 1;
  3041. for (k = 0; k < loopcount; k++) {
  3042. if (starttest(k)) {
  3043. for (i = (rate); i; i--) {
  3044. glBegin(GL_POLYGON);
  3045. glNormal3fv(&n[0]);
  3046. glVertex2fv(&v[0]);
  3047. glNormal3fv(&n[4]);
  3048. glVertex2fv(&v[4]);
  3049. glNormal3fv(&n[8]);
  3050. glVertex2fv(&v[8]);
  3051. glNormal3fv(&n[12]);
  3052. glVertex2fv(&v[12]);
  3053. glEnd();
  3054. }
  3055. }
  3056. pixendtest("rectangle fill", rate, (int) boxx[j], (int) boxy[j]);
  3057. }
  3058. } else if (!mod_cmode && mod_shade) {
  3059. /*** RECTANGLES (SCREEN ALIGNED, RGB GOURAUD SHADED) *****/
  3060. /****** Calibration Loop ******/
  3061. secs = 0.0;
  3062. rate = FILL_RATE;
  3063. while (secs < (secspertest/4.0)) {
  3064. rate = rate * 2;
  3065. starttest(0);
  3066. for (i = (rate); i; i--) {
  3067. glBegin(GL_POLYGON);
  3068. glColor3fv(&c[4]);
  3069. glVertex2fv(&v[0]);
  3070. glColor3fv(&c[8]);
  3071. glVertex2fv(&v[4]);
  3072. glColor3fv(&c[12]);
  3073. glVertex2fv(&v[8]);
  3074. glColor3fv(&c[16]);
  3075. glVertex2fv(&v[12]);
  3076. glEnd();
  3077. }
  3078. secs = timer(1);
  3079. }
  3080. rate = rate * (secspertest / secs);
  3081. if (rate < 1) rate = 1;
  3082. for (k = 0; k < loopcount; k++) {
  3083. if (starttest(k)) {
  3084. for (i = (rate); i; i--) {
  3085. glBegin(GL_POLYGON);
  3086. glColor3fv(&c[4]);
  3087. glVertex2fv(&v[0]);
  3088. glColor3fv(&c[8]);
  3089. glVertex2fv(&v[4]);
  3090. glColor3fv(&c[12]);
  3091. glVertex2fv(&v[8]);
  3092. glColor3fv(&c[16]);
  3093. glVertex2fv(&v[12]);
  3094. glEnd();
  3095. }
  3096. }
  3097. pixendtest("rectangle fill", rate, (int) boxx[j], (int) boxy[j]);
  3098. }
  3099. }
  3100. }
  3101. }
  3102. exit(0);
  3103. }
  3104. static void perfpixels(void)
  3105. {
  3106. long i, k;
  3107. long iw, ih;
  3108. unsigned long *pixels;
  3109. unsigned long pix;
  3110. long npixels, j, imgwid[5], imght[5], numimges = 5;
  3111. imgwid[0] = imght[0] = 10;
  3112. imgwid[1] = imght[1] = 100;
  3113. imgwid[2] = imght[2] = 500;
  3114. imgwid[3] = 640; imght[3] = 480;
  3115. imgwid[4] = xsize; imght[4] = ysize;
  3116. npixels = xsize * ysize;
  3117. pixels = (unsigned long *) malloc(npixels * sizeof(unsigned long));
  3118. printf("DMA test. No modifiers have any effect\n");
  3119. printf("Pixel Writes:\n");
  3120. fflush(stdout);
  3121. Sleep(250);
  3122. for (i = 0, pix = 0x7b8c9eaf; i < npixels; i++) {
  3123. pix = (pix * 8191) + 0x70615243;
  3124. pixels[i] = pix;
  3125. }
  3126. /* fill from top to bottom */
  3127. /* pixmode(PM_TTOB,1); not available in OpenGL */
  3128. glClearColor(c[0], c[1], c[2], c[3]);
  3129. /**** 32 BIT PIXEL WRITES ****/
  3130. for (j = 0; j < numimges; j++) {
  3131. iw = imgwid[j];
  3132. ih = imght[j];
  3133. glClear(GL_COLOR_BUFFER_BIT);
  3134. /****** Calibration Loop ******/
  3135. secs = 0.0;
  3136. rate = 15;
  3137. while (secs < (secspertest/4.0)) {
  3138. rate = rate * 2;
  3139. starttest(0);
  3140. for (i = (rate); i; i--) {
  3141. /* lrectwrite(1, 1, iw, ih, pixels); */
  3142. glRasterPos2f(-0.5 * xsize, -0.5 * ysize);
  3143. glDrawPixels(iw, ih, GL_RGBA, GL_BYTE, pixels);
  3144. }
  3145. secs = timer(1);
  3146. }
  3147. rate = rate * (secspertest / secs);
  3148. for (k = 0; k < loopcount; k++) {
  3149. if (starttest(k)) {
  3150. for (i = (rate); i; i--) {
  3151. glRasterPos2f(-0.5 * xsize, -0.5 * ysize);
  3152. glDrawPixels(iw, ih, GL_RGBA, GL_BYTE, pixels);
  3153. }
  3154. }
  3155. pixendtest("32-bit Pixel Write", rate, iw, ih);
  3156. }
  3157. }
  3158. printf("\n");
  3159. fflush(stdout);
  3160. Sleep(250);
  3161. /*
  3162. * This is not quite right. I think the correct way would be to get
  3163. * a colorindex visual and use that as the target of our writes.
  3164. */
  3165. /**** 8 BIT PIXEL WRITES ****/
  3166. for (j = 0; j < numimges; j++) {
  3167. iw = imgwid[j];
  3168. ih = imght[j];
  3169. glClear(GL_COLOR_BUFFER_BIT);
  3170. /****** Calibration Loop ******/
  3171. secs = 0.0;
  3172. rate = 15;
  3173. while (secs < (secspertest/4.0)) {
  3174. rate = rate * 2;
  3175. starttest(0);
  3176. for (i = (rate); i; i--) {
  3177. glRasterPos2i(1, 1);
  3178. glDrawPixels(iw, ih, GL_RED, GL_BYTE, pixels);
  3179. }
  3180. secs = timer(1);
  3181. }
  3182. rate = rate * (secspertest / secs);
  3183. for (k = 0; k < loopcount; k++) {
  3184. if (starttest(k)) {
  3185. for (i = (rate); i; i--) {
  3186. glRasterPos2i(1, 1);
  3187. glDrawPixels(iw, ih, GL_RED, GL_BYTE, pixels);
  3188. }
  3189. }
  3190. pixendtest("8-bit Pixel Write", rate, iw, ih);
  3191. }
  3192. }
  3193. printf("\n");
  3194. printf("Pixel Reads:\n");
  3195. fflush(stdout);
  3196. Sleep(250);
  3197. for (i=0; i< npixels; i++) {
  3198. pixels[i] = 0;
  3199. }
  3200. /**** PIXEL READS *****/
  3201. /* make a polygon to read */
  3202. {
  3203. float myv1[3], myv2[3], myv3[3], myv4[3];
  3204. myv1[0] = myv4[0] = -0.5*xsize,
  3205. myv2[0] = myv3[0] = 0.5*xsize;
  3206. myv1[1] = myv2[1] = -0.5*ysize;
  3207. myv3[1] = myv4[1] = 0.5*ysize;
  3208. myv1[2] = myv2[2] = myv3[2] = myv4[2] = 0.0;
  3209. glBegin(GL_POLYGON);
  3210. glColor3fv(&c[4]);
  3211. glVertex3fv(myv1);
  3212. glColor3fv(&c[8]);
  3213. glVertex3fv(myv2);
  3214. glColor3fv(&c[12]);
  3215. glVertex3fv(myv3);
  3216. glColor3fv(&c[28]);
  3217. glVertex3fv(myv4);
  3218. glEnd();
  3219. }
  3220. /**** 32 BIT PIXEL READS ****/
  3221. for (j = 0; j < numimges; j++) {
  3222. iw = imgwid[j];
  3223. ih = imght[j];
  3224. /****** Calibration Loop ******/
  3225. secs = 0.0;
  3226. rate = 15;
  3227. while (secs < (secspertest/4.0)) {
  3228. rate = rate*2;
  3229. starttest(0);
  3230. for(i=(rate); i; i--) {
  3231. /* lrectread(1, 1, iw, ih, pixels); */
  3232. glReadPixels(-0.5 * xsize, -0.5 * ysize, iw, ih,
  3233. GL_RGBA, GL_BYTE, pixels);
  3234. }
  3235. secs = timer(1);
  3236. }
  3237. rate = rate * (secspertest/secs);
  3238. for (k=0; k<loopcount; k++) {
  3239. if (starttest(k)) {
  3240. for(i=(rate); i; i--) {
  3241. glReadPixels(-0.5 * xsize, -0.5 * ysize, iw, ih,
  3242. GL_RGBA, GL_BYTE, pixels);
  3243. }
  3244. }
  3245. pixendtest ("32-bit Pixel Read", rate, iw, ih);
  3246. }
  3247. }
  3248. printf("\n");
  3249. fflush(stdout);
  3250. Sleep(250);
  3251. /*** 8 BIT PIXEL READS ******/
  3252. for (j = 0; j < numimges; j++) {
  3253. iw = imgwid[j];
  3254. ih = imght[j];
  3255. /****** Calibration Loop ******/
  3256. secs = 0.0;
  3257. rate = 15;
  3258. while (secs < (secspertest/4.0)) {
  3259. rate = rate*2;
  3260. starttest(0);
  3261. for(i=(rate); i; i--) {
  3262. glReadPixels(-0.5 * xsize, -0.5 * ysize, iw, ih,
  3263. GL_RED, GL_BYTE, pixels);
  3264. }
  3265. secs = timer(1);
  3266. }
  3267. rate = rate * (secspertest/secs);
  3268. for (k=0; k<loopcount; k++) {
  3269. if (starttest(k)) {
  3270. for(i=(rate); i; i--) {
  3271. glReadPixels(-0.5 * xsize, -0.5 * ysize, iw, ih,
  3272. GL_RED, GL_BYTE, pixels);
  3273. }
  3274. }
  3275. pixendtest("8-bit Pixel Read", rate, iw, ih);
  3276. }
  3277. }
  3278. }
  3279. static void perfclear(void)
  3280. {
  3281. long viewwd, viewht;
  3282. long winwd[5], winht[5];
  3283. long numscreens = 5; /* should be same size as win arrays */
  3284. long zval;
  3285. int i, j, k;
  3286. char pbuf[256];
  3287. winwd[0] = 100;
  3288. winht[0] = 100;
  3289. winwd[1] = 500;
  3290. winht[1] = 500;
  3291. winwd[2] = 640;
  3292. winht[2] = 480;
  3293. winwd[3] = xsize;
  3294. winht[3] = ysize;
  3295. winwd[4] = 1;
  3296. winht[4] = 1;
  3297. glDisable(GL_DITHER);
  3298. for (j = 0; j < numscreens; j++) {
  3299. viewwd = winwd[j];
  3300. viewht = winht[j];
  3301. glEnable(GL_SCISSOR_TEST);
  3302. glScissor(0, 0, viewwd - 1, viewht - 1);
  3303. if (mod_z) { /* include clearing the zbuffer */
  3304. glClearDepth(1.0);
  3305. /** USING glClear(COLOR); glClear(DEPTH) **/
  3306. if (!mod_cmode) {
  3307. glClearColor(c[16], c[17], c[18], c[19]);
  3308. } else {
  3309. glClearIndex(YELLOW);
  3310. }
  3311. glFlush();
  3312. sum_secs = 0.0;
  3313. sum_n = 0;
  3314. /****** Calibration Loop ******/
  3315. secs = 0.0;
  3316. rate = 125;
  3317. while (secs < (secspertest/4.0)) {
  3318. rate = rate * 2;
  3319. starttest(0);
  3320. for (i = (rate); i; i--) {
  3321. glClear(GL_COLOR_BUFFER_BIT);
  3322. glClear(GL_DEPTH_BUFFER_BIT);
  3323. }
  3324. secs = timer(1);
  3325. }
  3326. /** Do the real thing **/
  3327. rate = rate * (secspertest / secs);
  3328. for (k = 0; k < loopcount; k++) {
  3329. if (starttest(k)) {
  3330. for (i = rate; i; i--) {
  3331. glClear(GL_COLOR_BUFFER_BIT);
  3332. glClear(GL_DEPTH_BUFFER_BIT);
  3333. }
  3334. sprintf(pbuf, "glClear(COLOR); glClear(DEPTH); clear screen size %ld %ld",
  3335. viewwd, viewht);
  3336. }
  3337. clearendtest(pbuf, rate, viewwd * viewht);
  3338. }
  3339. glFlush();
  3340. sum_secs = 0.0;
  3341. sum_n = 0;
  3342. /****** Calibration Loop ******/
  3343. /** USING glClear(COLOR|DEPTH) **/
  3344. if (!mod_cmode) {
  3345. glClearColor(c[8], c[9], c[10], c[11]);
  3346. } else {
  3347. glClearIndex(BLUE);
  3348. }
  3349. secs = 0.0;
  3350. rate = 125;
  3351. while (secs < (secspertest/4.0)) {
  3352. rate = rate * 2;
  3353. starttest(0);
  3354. for (i = (rate); i; i--) {
  3355. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  3356. }
  3357. secs = timer(1);
  3358. }
  3359. rate = rate * (secspertest / secs);
  3360. for (k = 0; k < loopcount; k++) {
  3361. if (starttest(k)) {
  3362. for (i = (rate); i; i--) {
  3363. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  3364. }
  3365. sprintf(pbuf, "glClear(COLOR|DEPTH) clear screen size %ld %ld",
  3366. viewwd, viewht);
  3367. }
  3368. clearendtest(pbuf, rate, viewwd * viewht);
  3369. }
  3370. } else { /* no z buffering */
  3371. /** JUST PLAIN OLD CLEAR() */
  3372. if (mod_cmode) {
  3373. glClearIndex(CYAN);
  3374. } else {
  3375. glClearColor(c[24], c[25], c[26], c[27]);
  3376. }
  3377. sum_secs = 0.0;
  3378. sum_n = 0;
  3379. sprintf(pbuf, "clear screen size %ld %ld", viewwd, viewht);
  3380. /****** Calibration Loop ******/
  3381. secs = 0.0;
  3382. rate = 125;
  3383. while (secs < (secspertest/4.0)) {
  3384. rate = rate * 2;
  3385. starttest(0);
  3386. for (i = (rate); i; i--)
  3387. glClear(GL_COLOR_BUFFER_BIT);
  3388. secs = timer(1);
  3389. }
  3390. rate = rate * (secspertest / secs);
  3391. for (k = 0; k < loopcount; k++) {
  3392. if (starttest(k)) {
  3393. for (i = (rate); i; i--)
  3394. glClear(GL_COLOR_BUFFER_BIT);
  3395. }
  3396. clearendtest(pbuf, rate, viewwd * viewht);
  3397. }
  3398. }
  3399. if (mod_cmode) {
  3400. glClearIndex(BLACK);
  3401. } else {
  3402. glClearColor(c[0], c[1], c[2], c[3]);
  3403. }
  3404. glClear(GL_COLOR_BUFFER_BIT);
  3405. }
  3406. exit(0);
  3407. }
  3408. static void perfqstrip(void)
  3409. {
  3410. int i,j,k;
  3411. char pbuf[256];
  3412. int cVert = 60;
  3413. int cVertDiv2 = 30;
  3414. /* Triangle mesh tests: Each qstrip contains 62 vertices, or */
  3415. /* 60 triangles. To make the calculation exact, the rate */
  3416. /* must be a multiple of 60. */
  3417. /* If the quad size is specified, set the size of the quad strip to
  3418. ** fit the window. The number of vertices must be a multiple of four (due
  3419. ** to code below), and it must not exceed 60.
  3420. */
  3421. if (mod_size) {
  3422. cVert = (int) (MINDIMENSION*2 / prim_size) - 2;
  3423. if (cVert & 1) cVert++;
  3424. cVert &= ~3;
  3425. if (cVert < 4) cVert = 4;
  3426. if (cVert > 60) cVert = 60;
  3427. }
  3428. cVertDiv2 = cVert >> 1;
  3429. if (!mod_2d) {
  3430. if (mod_cmode && mod_shade) {
  3431. /*** GOURAUD SHADED CMODE QSTRIP ***/
  3432. /* 255 = r, 240 = g, 255 = b */
  3433. makeramp(208,255,0,0,0,0,255,16);
  3434. makeramp(224,0,0,255,255,255,0,16);
  3435. makeramp(240,255,255,0,255,0,255,16);
  3436. sum_secs = 0.0;
  3437. sum_n = 0;
  3438. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  3439. glPushMatrix();
  3440. glRotatef(angle-90.0, 0, 0, 1);
  3441. /****** Calibration Loop ******/
  3442. secs = 0.0; rate = 125;
  3443. while (secs < (secspertest/4.0)) {
  3444. rate = rate*2;
  3445. starttest(0);
  3446. for(i=(rate)/cVertDiv2; i; i--) {
  3447. glBegin(GL_QUAD_STRIP);
  3448. for (j=0; j<=cVertDiv2; j+=2) {
  3449. glIndexi(255);
  3450. glVertex3fv(&v[j*4]);
  3451. glIndexi(240);
  3452. glVertex3fv(&v[(j+1)*4]);
  3453. }
  3454. for (j=cVertDiv2-2; j>=0; j-=2) {
  3455. glIndexi(223);
  3456. glVertex3fv(&v[j*4]);
  3457. glIndexi(208);
  3458. glVertex3fv(&v[(j+1)*4]);
  3459. }
  3460. glEnd();
  3461. }
  3462. secs = timer(1);
  3463. }
  3464. rate = rate * (secspertest/secs);
  3465. rate = cVert * (rate/cVertDiv2);
  3466. /* Do the real thing GOURAUD shaded Cmode qstrip */
  3467. for (k=0; k<loopcount; k++) {
  3468. if (starttest(k)) {
  3469. for(i=(rate)/cVertDiv2; i; i--) {
  3470. glBegin(GL_QUAD_STRIP);
  3471. for (j=0; j<=cVertDiv2; j+=2) {
  3472. glIndexi(255);
  3473. glVertex3fv(&v[j*4]);
  3474. glIndexi(240);
  3475. glVertex3fv(&v[(j+1)*4]);
  3476. }
  3477. for (j=cVertDiv2-2; j>=0; j-=2) {
  3478. glIndexi(223);
  3479. glVertex3fv(&v[j*4]);
  3480. glIndexi(208);
  3481. glVertex3fv(&v[(j+1)*4]);
  3482. }
  3483. glEnd();
  3484. }
  3485. if (!mod_average)
  3486. sprintf (pbuf, "Angle %6.2f", angle);
  3487. }
  3488. endtest(pbuf, rate, 0);
  3489. }
  3490. glPopMatrix();
  3491. }
  3492. printaverage ();
  3493. } else if (!mod_light && !mod_shade) {
  3494. /*** FLAT SHADED QSTRIP ***/
  3495. sum_secs = 0.0;
  3496. sum_n = 0;
  3497. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  3498. glPushMatrix();
  3499. glRotatef(angle-90.0, 0, 0, 1);
  3500. /****** Calibration Loop ******/
  3501. secs = 0.0; rate = 125;
  3502. while (secs < (secspertest/4.0)) {
  3503. rate = rate*2;
  3504. starttest(0);
  3505. for(i=(rate)/cVertDiv2; i; i--) {
  3506. glBegin(GL_QUAD_STRIP);
  3507. for (j=0; j<=cVertDiv2; j++) {
  3508. glVertex3fv(&v[j*4]);
  3509. }
  3510. for (j=cVertDiv2-2; j>=0; j-=2) {
  3511. glVertex3fv(&v[j*4]);
  3512. glVertex3fv(&v[(j+1)*4]);
  3513. }
  3514. glEnd();
  3515. }
  3516. secs = timer(1);
  3517. }
  3518. rate = rate * (secspertest/secs);
  3519. rate = cVert * (rate/cVertDiv2);
  3520. /* Do the real thing - FLAT shaded qstrip */
  3521. for (k=0; k<loopcount; k++) {
  3522. if (starttest(k)) {
  3523. for(i=(rate)/cVertDiv2; i; i--) {
  3524. glBegin(GL_QUAD_STRIP);
  3525. for (j=0; j<=cVertDiv2; j++) {
  3526. glVertex3fv(&v[j*4]);
  3527. }
  3528. for (j=cVertDiv2-2; j>=0; j-=2) {
  3529. glVertex3fv(&v[j*4]);
  3530. glVertex3fv(&v[(j+1)*4]);
  3531. }
  3532. glEnd();
  3533. }
  3534. if (!mod_average)
  3535. sprintf(pbuf, "Angle %6.2f", angle);
  3536. }
  3537. endtest(pbuf, rate, 0);
  3538. }
  3539. glPopMatrix();
  3540. }
  3541. printaverage();
  3542. } else if (!mod_cmode && mod_light) {
  3543. /*** LIGHTED RGB QSTRIP ***/
  3544. glLoadIdentity();
  3545. glMatrixMode(GL_PROJECTION);
  3546. glLoadIdentity();
  3547. glOrtho(-0.5*xsize,0.5*xsize,-0.5*ysize,0.5*ysize,1.0,-1.0);
  3548. glMatrixMode(GL_MODELVIEW);
  3549. /* set lights */
  3550. setLightingParameters();
  3551. sum_secs = 0.0;
  3552. sum_n = 0;
  3553. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  3554. glPushMatrix();
  3555. glRotatef(angle-90.0, 0, 0, 1);
  3556. /****** Calibration Loop ******/
  3557. secs = 0.0; rate = 125;
  3558. while (secs < (secspertest/4.0)) {
  3559. rate = rate*2;
  3560. starttest(0);
  3561. for(i=(rate)/cVertDiv2; i; i--) {
  3562. glBegin(GL_QUAD_STRIP);
  3563. for (j=0; j<=cVertDiv2; j+=2) {
  3564. glNormal3fv(&n[0]);
  3565. glVertex3fv(&v[j*4]);
  3566. glNormal3fv(&n[4]);
  3567. glVertex3fv(&v[(j+1)*4]);
  3568. }
  3569. for (j=cVertDiv2-2; j>=0; j-=2) {
  3570. glNormal3fv(&n[8]);
  3571. glVertex3fv(&v[j*4]);
  3572. glNormal3fv(&n[12]);
  3573. glVertex3fv(&v[(j+1)*4]);
  3574. }
  3575. glEnd();
  3576. }
  3577. secs = timer(1);
  3578. }
  3579. rate = rate * (secspertest/secs);
  3580. rate = cVert * (rate/cVertDiv2);
  3581. for (k=0; k<loopcount; k++) {
  3582. if (starttest(k)) {
  3583. for(i=(rate)/cVertDiv2; i; i--) {
  3584. glBegin(GL_QUAD_STRIP);
  3585. for (j=0; j<=cVertDiv2; j+=2) {
  3586. glNormal3fv(&n[0]);
  3587. glVertex3fv(&v[j*4]);
  3588. glNormal3fv(&n[4]);
  3589. glVertex3fv(&v[(j+1)*4]);
  3590. }
  3591. for (j=cVertDiv2-2; j>=0; j-=2) {
  3592. glNormal3fv(&n[8]);
  3593. glVertex3fv(&v[j*4]);
  3594. glNormal3fv(&n[12]);
  3595. glVertex3fv(&v[(j+1)*4]);
  3596. }
  3597. glEnd();
  3598. }
  3599. if (!mod_average)
  3600. sprintf(pbuf, "Angle %6.2f", angle);
  3601. }
  3602. endtest(pbuf, rate, 0);
  3603. }
  3604. glPopMatrix();
  3605. }
  3606. printaverage();
  3607. } else if (!mod_cmode && mod_shade) {
  3608. /*** GOURAUD SHADED RGB TMESH ***/
  3609. sum_secs = 0.0;
  3610. sum_n = 0;
  3611. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  3612. glPushMatrix();
  3613. glRotatef(angle-90.0, 0, 0, 1);
  3614. /****** Calibration Loop ******/
  3615. secs = 0.0; rate = 125;
  3616. while (secs < (secspertest/4.0)) {
  3617. rate = rate*2;
  3618. starttest(0);
  3619. for(i=(rate)/cVertDiv2; i; i--) {
  3620. glBegin(GL_QUAD_STRIP);
  3621. for (j=0; j<=cVertDiv2; j+=2) {
  3622. glColor3fv(&c[16]);
  3623. glVertex3fv(&v[j*4]);
  3624. glColor3fv(&c[20]);
  3625. glVertex3fv(&v[(j+1)*4]);
  3626. }
  3627. for (j=cVertDiv2-2; j>=0; j-=2) {
  3628. glColor3fv(&c[4]);
  3629. glVertex3fv(&v[j*4]);
  3630. glColor3fv(&c[8]);
  3631. glVertex3fv(&v[(j+1)*4]);
  3632. }
  3633. glEnd();
  3634. }
  3635. secs = timer(1);
  3636. }
  3637. rate = rate * (secspertest/secs);
  3638. rate = cVert * (rate/cVertDiv2);
  3639. /* Do the real thing GOURAUD shaded qstrip */
  3640. for (k=0; k<loopcount; k++) {
  3641. if (starttest(k)) {
  3642. for(i=(rate)/cVertDiv2; i; i--) {
  3643. glBegin(GL_QUAD_STRIP);
  3644. for (j=0; j<=cVertDiv2; j+=2) {
  3645. glColor3fv(&c[16]);
  3646. glVertex3fv(&v[j*4]);
  3647. glColor3fv(&c[20]);
  3648. glVertex3fv(&v[(j+1)*4]);
  3649. }
  3650. for (j=cVertDiv2-2; j>=0; j-=2) {
  3651. glColor3fv(&c[4]);
  3652. glVertex3fv(&v[j*4]);
  3653. glColor3fv(&c[8]);
  3654. glVertex3fv(&v[(j+1)*4]);
  3655. }
  3656. glEnd();
  3657. }
  3658. }
  3659. if (!mod_average)
  3660. sprintf(pbuf, "Angle %6.2f", angle);
  3661. endtest(pbuf, rate, 0);
  3662. }
  3663. glPopMatrix();
  3664. }
  3665. printaverage();
  3666. }
  3667. } else { /* must be 2d */
  3668. if (mod_cmode && mod_shade) { /* color map lighting yet */
  3669. /*** GOURAUD SHADED CMODE TMESH ***/
  3670. /* 255 = r, 240 = g, 255 = b */
  3671. makeramp(208,255,0,0,0,0,255,16);
  3672. makeramp(224,0,0,255,255,255,0,16);
  3673. makeramp(240,255,255,0,255,0,255,16);
  3674. sum_secs = 0.0;
  3675. sum_n = 0;
  3676. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  3677. glPushMatrix();
  3678. glRotatef(angle-90.0, 0, 0, 1);
  3679. /****** Calibration Loop ******/
  3680. secs = 0.0; rate = 125;
  3681. while (secs < (secspertest/4.0)) {
  3682. rate = rate*2;
  3683. starttest(0);
  3684. for(i=(rate)/cVertDiv2; i; i--) {
  3685. glBegin(GL_QUAD_STRIP);
  3686. for (j=0; j<=cVertDiv2; j+=2) {
  3687. glIndexi(255);
  3688. glVertex2fv(&v[j*4]);
  3689. glIndexi(240);
  3690. glVertex2fv(&v[(j+1)*4]);
  3691. }
  3692. for (j=cVertDiv2-2; j>=0; j-=2) {
  3693. glIndexi(223);
  3694. glVertex2fv(&v[j*4]);
  3695. glIndexi(208);
  3696. glVertex2fv(&v[(j+1)*4]);
  3697. }
  3698. glEnd();
  3699. }
  3700. secs = timer(1);
  3701. }
  3702. rate = rate * (secspertest/secs);
  3703. rate = cVert * (rate/cVertDiv2);
  3704. /* Do the real thing GOURAUD shaded Cmode qstrip */
  3705. for (k=0; k<loopcount; k++) {
  3706. if (starttest(k)) {
  3707. for(i=(rate)/cVertDiv2; i; i--) {
  3708. glBegin(GL_QUAD_STRIP);
  3709. for (j=0; j<=cVertDiv2; j+=2) {
  3710. glIndexi(255);
  3711. glVertex2fv(&v[j*4]);
  3712. glIndexi(240);
  3713. glVertex2fv(&v[(j+1)*4]);
  3714. }
  3715. for (j=cVertDiv2-2; j>=0; j-=2) {
  3716. glIndexi(223);
  3717. glVertex2fv(&v[j*4]);
  3718. glIndexi(208);
  3719. glVertex2fv(&v[(j+1)*4]);
  3720. }
  3721. glEnd();
  3722. }
  3723. }
  3724. if (!mod_average)
  3725. sprintf(pbuf, "Angle %6.2f", angle);
  3726. endtest(pbuf, rate, 0);
  3727. }
  3728. glPopMatrix();
  3729. }
  3730. printaverage();
  3731. } else if (!mod_light && !mod_shade) {
  3732. /*** FLAT SHADED QSTRIP ***/
  3733. sum_secs = 0.0;
  3734. sum_n = 0;
  3735. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  3736. glPushMatrix();
  3737. glRotatef(angle-90.0, 0, 0, 1);
  3738. /****** Calibration Loop ******/
  3739. secs = 0.0; rate = 125;
  3740. while (secs < (secspertest/4.0)) {
  3741. rate = rate*2;
  3742. starttest(0);
  3743. for(i=(rate)/cVertDiv2; i; i--) {
  3744. glBegin(GL_QUAD_STRIP);
  3745. for (j=0; j<=cVertDiv2; j++) {
  3746. glVertex2fv(&v[j*4]);
  3747. }
  3748. for (j=cVertDiv2-2; j>=0; j-=2) {
  3749. glVertex2fv(&v[j*4]);
  3750. glVertex2fv(&v[(j+1)*4]);
  3751. }
  3752. glEnd();
  3753. }
  3754. secs = timer(1);
  3755. }
  3756. rate = rate * (secspertest/secs);
  3757. rate = cVert * (rate/cVertDiv2);
  3758. /* Do the real thing - FLAT shaded qstrip */
  3759. for (k=0; k<loopcount; k++) {
  3760. if (starttest(k)) {
  3761. for(i=(rate)/cVertDiv2; i; i--) {
  3762. glBegin(GL_QUAD_STRIP);
  3763. for (j=0; j<=cVertDiv2; j++) {
  3764. glVertex2fv(&v[j*4]);
  3765. }
  3766. for (j=cVertDiv2-2; j>=0; j-=2) {
  3767. glVertex2fv(&v[j*4]);
  3768. glVertex2fv(&v[(j+1)*4]);
  3769. }
  3770. glEnd();
  3771. }
  3772. }
  3773. if (!mod_average)
  3774. sprintf(pbuf, "Angle %6.2f", angle);
  3775. endtest(pbuf, rate, 0);
  3776. }
  3777. glPopMatrix();
  3778. }
  3779. printaverage();
  3780. } else if (!mod_cmode && mod_light) {
  3781. /*** LIGHTED RGB QSTRIP ***/
  3782. glLoadIdentity();
  3783. glMatrixMode(GL_PROJECTION);
  3784. glLoadIdentity();
  3785. glOrtho(-0.5*xsize,0.5*xsize,-0.5*ysize,0.5*ysize,1.0,-1.0);
  3786. glMatrixMode(GL_MODELVIEW);
  3787. /* set lights */
  3788. setLightingParameters();
  3789. sum_secs = 0.0;
  3790. sum_n = 0;
  3791. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  3792. glPushMatrix();
  3793. glRotatef(angle-90.0, 0, 0, 1);
  3794. /****** Calibration Loop ******/
  3795. secs = 0.0; rate = 125;
  3796. while (secs < (secspertest/4.0)) {
  3797. rate = rate*2;
  3798. starttest(0);
  3799. for(i=(rate)/cVertDiv2; i; i--) {
  3800. glBegin(GL_QUAD_STRIP);
  3801. for (j=0; j<=cVertDiv2; j+=2) {
  3802. glNormal3fv(&n[0]);
  3803. glVertex2fv(&v[j*4]);
  3804. glNormal3fv(&n[4]);
  3805. glVertex2fv(&v[(j+1)*4]);
  3806. }
  3807. for (j=cVertDiv2-2; j>=0; j-=2) {
  3808. glNormal3fv(&n[8]);
  3809. glVertex2fv(&v[j*4]);
  3810. glNormal3fv(&n[12]);
  3811. glVertex2fv(&v[(j+1)*4]);
  3812. }
  3813. glEnd();
  3814. }
  3815. secs = timer(1);
  3816. }
  3817. rate = rate * (secspertest/secs);
  3818. rate = cVert * (rate/cVertDiv2);
  3819. for (k=0; k<loopcount; k++) {
  3820. if (starttest(k)) {
  3821. for(i=(rate)/cVertDiv2; i; i--) {
  3822. glBegin(GL_QUAD_STRIP);
  3823. for (j=0; j<=cVertDiv2; j+=2) {
  3824. glNormal3fv(&n[0]);
  3825. glVertex2fv(&v[j*4]);
  3826. glNormal3fv(&n[4]);
  3827. glVertex2fv(&v[(j+1)*4]);
  3828. }
  3829. for (j=cVertDiv2-2; j>=0; j-=2) {
  3830. glNormal3fv(&n[8]);
  3831. glVertex2fv(&v[j*4]);
  3832. glNormal3fv(&n[12]);
  3833. glVertex2fv(&v[(j+1)*4]);
  3834. }
  3835. glEnd();
  3836. }
  3837. }
  3838. if (!mod_average)
  3839. sprintf(pbuf, "Angle %6.2f", angle);
  3840. endtest(pbuf, rate, 0);
  3841. }
  3842. glPopMatrix();
  3843. }
  3844. printaverage();
  3845. } else if (!mod_cmode && mod_shade) {
  3846. /*** GOURAUD SHADED RGB TMESH ***/
  3847. sum_secs = 0.0;
  3848. sum_n = 0;
  3849. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  3850. glPushMatrix();
  3851. glRotatef(angle-90.0, 0, 0, 1);
  3852. /****** Calibration Loop ******/
  3853. secs = 0.0; rate = 125;
  3854. while (secs < (secspertest/4.0)) {
  3855. rate = rate*2;
  3856. starttest(0);
  3857. for(i=(rate)/cVertDiv2; i; i--) {
  3858. glBegin(GL_QUAD_STRIP);
  3859. for (j=0; j<=cVertDiv2; j+=2) {
  3860. glColor3fv(&c[16]);
  3861. glVertex2fv(&v[j*4]);
  3862. glColor3fv(&c[20]);
  3863. glVertex2fv(&v[(j+1)*4]);
  3864. }
  3865. for (j=cVertDiv2-2; j>=0; j-=2) {
  3866. glColor3fv(&c[4]);
  3867. glVertex2fv(&v[j*4]);
  3868. glColor3fv(&c[8]);
  3869. glVertex2fv(&v[(j+1)*4]);
  3870. }
  3871. glEnd();
  3872. }
  3873. secs = timer(1);
  3874. }
  3875. rate = rate * (secspertest/secs);
  3876. rate = cVert * (rate/cVertDiv2);
  3877. /* Do the real thing GOURAUD shaded qstrip */
  3878. for (k=0; k<loopcount; k++) {
  3879. if (starttest(k)) {
  3880. for(i=(rate)/cVertDiv2; i; i--) {
  3881. glBegin(GL_QUAD_STRIP);
  3882. for (j=0; j<=cVertDiv2; j+=2) {
  3883. glColor3fv(&c[16]);
  3884. glVertex2fv(&v[j*4]);
  3885. glColor3fv(&c[20]);
  3886. glVertex2fv(&v[(j+1)*4]);
  3887. }
  3888. for (j=cVertDiv2-2; j>=0; j-=2) {
  3889. glColor3fv(&c[4]);
  3890. glVertex2fv(&v[j*4]);
  3891. glColor3fv(&c[8]);
  3892. glVertex2fv(&v[(j+1)*4]);
  3893. }
  3894. glEnd();
  3895. }
  3896. }
  3897. if (!mod_average)
  3898. sprintf(pbuf, "Angle %6.2f", angle);
  3899. endtest(pbuf, rate, 0);
  3900. }
  3901. glPopMatrix();
  3902. }
  3903. printaverage();
  3904. }
  3905. }
  3906. if (mod_doublebuffer) {
  3907. auxSwapBuffers();
  3908. Sleep(2000); /* for visual feedback */
  3909. }
  3910. exit(0);
  3911. }
  3912. static void perfqstriptex(void)
  3913. {
  3914. int i,j,k, ti;
  3915. char pbuf[256];
  3916. int cVert = 60;
  3917. int cVertDiv2 = 30;
  3918. if (mod_texfile) MyLoadImage();
  3919. else CreateImage();
  3920. InitTexParams();
  3921. /* Triangle mesh tests: Each qstrip contains 62 vertices, or */
  3922. /* 60 triangles. To make the calculation exact, the rate */
  3923. /* must be a multiple of 60. */
  3924. /* If the quad size is specified, set the size of the quad strip to
  3925. ** fit the window. The number of vertices must be a multiple of four (due
  3926. ** to code below), and it must not exceed 60.
  3927. */
  3928. if (mod_size) {
  3929. cVert = (int) (MINDIMENSION*2 / prim_size) - 2;
  3930. if (cVert & 1) cVert++;
  3931. cVert &= ~3;
  3932. if (cVert < 4) cVert = 4;
  3933. if (cVert > 60) cVert = 60;
  3934. }
  3935. cVertDiv2 = cVert >> 1;
  3936. if (!mod_2d) {
  3937. if (mod_cmode && mod_shade) {
  3938. /*** GOURAUD SHADED CMODE QSTRIP ***/
  3939. /* 255 = r, 240 = g, 255 = b */
  3940. makeramp(208,255,0,0,0,0,255,16);
  3941. makeramp(224,0,0,255,255,255,0,16);
  3942. makeramp(240,255,255,0,255,0,255,16);
  3943. sum_secs = 0.0;
  3944. sum_n = 0;
  3945. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  3946. glPushMatrix();
  3947. glRotatef(angle-90.0, 0, 0, 1);
  3948. /****** Calibration Loop ******/
  3949. secs = 0.0; rate = 125;
  3950. while (secs < (secspertest/4.0)) {
  3951. rate = rate*2;
  3952. starttest(0);
  3953. for(i=(rate)/cVertDiv2; i; i--) {
  3954. glBegin(GL_QUAD_STRIP);
  3955. for (j=0, ti=0; j<=cVertDiv2; j+=2, ti = ti%4 ) {
  3956. glIndexi(255);
  3957. glTexCoord2fv (&t[ti++]);
  3958. glVertex3fv(&v[j*4]);
  3959. glIndexi(240);
  3960. glTexCoord2fv (&t[ti++]);
  3961. glVertex3fv(&v[(j+1)*4]);
  3962. }
  3963. for (j=cVertDiv2-2, ti=0; j>=0; j-=2, ti = ti%4 ) {
  3964. glIndexi(223);
  3965. glTexCoord2fv (&t[ti++]);
  3966. glVertex3fv(&v[j*4]);
  3967. glIndexi(208);
  3968. glTexCoord2fv (&t[ti++]);
  3969. glVertex3fv(&v[(j+1)*4]);
  3970. }
  3971. glEnd();
  3972. }
  3973. secs = timer(1);
  3974. }
  3975. rate = rate * (secspertest/secs);
  3976. rate = cVert * (rate/cVertDiv2);
  3977. /* Do the real thing GOURAUD shaded Cmode qstrip */
  3978. for (k=0; k<loopcount; k++) {
  3979. if (starttest(k)) {
  3980. for(i=(rate)/cVertDiv2; i; i--) {
  3981. glBegin(GL_QUAD_STRIP);
  3982. for (j=0, ti=0; j<=cVertDiv2; j+=2, ti = ti%4 ) {
  3983. glIndexi(255);
  3984. glTexCoord2fv (&t[ti++]);
  3985. glVertex3fv(&v[j*4]);
  3986. glIndexi(240);
  3987. glTexCoord2fv (&t[ti++]);
  3988. glVertex3fv(&v[(j+1)*4]);
  3989. }
  3990. for (j=cVertDiv2-2, ti=0; j>=0; j-=2, ti = ti%4 ) {
  3991. glIndexi(223);
  3992. glTexCoord2fv (&t[ti++]);
  3993. glVertex3fv(&v[j*4]);
  3994. glIndexi(208);
  3995. glTexCoord2fv (&t[ti++]);
  3996. glVertex3fv(&v[(j+1)*4]);
  3997. }
  3998. glEnd();
  3999. }
  4000. if (!mod_average)
  4001. sprintf (pbuf, "Angle %6.2f", angle);
  4002. }
  4003. endtest(pbuf, rate, 0);
  4004. }
  4005. glPopMatrix();
  4006. }
  4007. printaverage ();
  4008. } else if (!mod_light && !mod_shade) {
  4009. /*** FLAT SHADED QSTRIP ***/
  4010. sum_secs = 0.0;
  4011. sum_n = 0;
  4012. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  4013. glPushMatrix();
  4014. glRotatef(angle-90.0, 0, 0, 1);
  4015. /****** Calibration Loop ******/
  4016. secs = 0.0; rate = 125;
  4017. while (secs < (secspertest/4.0)) {
  4018. rate = rate*2;
  4019. starttest(0);
  4020. for(i=(rate)/cVertDiv2; i; i--) {
  4021. glBegin(GL_QUAD_STRIP);
  4022. for (j=0, ti=0; j<=cVertDiv2; j++, ti=ti%4 ) {
  4023. glTexCoord2fv (&t[ti++]);
  4024. glVertex3fv(&v[j*4]);
  4025. }
  4026. for (j=cVertDiv2-2, ti=0; j>=0; j-=2, ti=ti%4 ) {
  4027. glTexCoord2fv (&t[ti++]);
  4028. glVertex3fv(&v[j*4]);
  4029. glTexCoord2fv (&t[ti++]);
  4030. glVertex3fv(&v[(j+1)*4]);
  4031. }
  4032. glEnd();
  4033. }
  4034. secs = timer(1);
  4035. }
  4036. rate = rate * (secspertest/secs);
  4037. rate = cVert * (rate/cVertDiv2);
  4038. /* Do the real thing - FLAT shaded qstrip */
  4039. for (k=0; k<loopcount; k++) {
  4040. if (starttest(k)) {
  4041. for(i=(rate)/cVertDiv2; i; i--) {
  4042. glBegin(GL_QUAD_STRIP);
  4043. for (j=0, ti=0; j<=cVertDiv2; j++,ti=ti%4 ) {
  4044. glTexCoord2fv (&t[ti++]);
  4045. glVertex3fv(&v[j*4]);
  4046. }
  4047. for (j=cVertDiv2-2, ti=0; j>=0; j-=2, ti=ti%4 ) {
  4048. glTexCoord2fv (&t[ti++]);
  4049. glVertex3fv(&v[j*4]);
  4050. glTexCoord2fv (&t[ti++]);
  4051. glVertex3fv(&v[(j+1)*4]);
  4052. }
  4053. glEnd();
  4054. }
  4055. if (!mod_average)
  4056. sprintf(pbuf, "Angle %6.2f", angle);
  4057. }
  4058. endtest(pbuf, rate, 0);
  4059. }
  4060. glPopMatrix();
  4061. }
  4062. printaverage();
  4063. } else if (!mod_cmode && mod_light) {
  4064. /*** LIGHTED RGB QSTRIP ***/
  4065. glLoadIdentity();
  4066. glMatrixMode(GL_PROJECTION);
  4067. glLoadIdentity();
  4068. glOrtho(-0.5*xsize,0.5*xsize,-0.5*ysize,0.5*ysize,1.0,-1.0);
  4069. glMatrixMode(GL_MODELVIEW);
  4070. /* set lights */
  4071. setLightingParameters();
  4072. sum_secs = 0.0;
  4073. sum_n = 0;
  4074. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  4075. glPushMatrix();
  4076. glRotatef(angle-90.0, 0, 0, 1);
  4077. /****** Calibration Loop ******/
  4078. secs = 0.0; rate = 125;
  4079. while (secs < (secspertest/4.0)) {
  4080. rate = rate*2;
  4081. starttest(0);
  4082. for(i=(rate)/cVertDiv2; i; i--) {
  4083. glBegin(GL_QUAD_STRIP);
  4084. for (j=0, ti=0; j<=cVertDiv2; j+=2, ti=ti%4 ) {
  4085. glNormal3fv(&n[0]);
  4086. glTexCoord2fv (&t[ti++]);
  4087. glVertex3fv(&v[j*4]);
  4088. glNormal3fv(&n[4]);
  4089. glTexCoord2fv (&t[ti++]);
  4090. glVertex3fv(&v[(j+1)*4]);
  4091. }
  4092. for (j=cVertDiv2-2, ti=0; j>=0; j-=2, ti=ti%4 ) {
  4093. glNormal3fv(&n[8]);
  4094. glTexCoord2fv (&t[ti++]);
  4095. glVertex3fv(&v[j*4]);
  4096. glNormal3fv(&n[12]);
  4097. glTexCoord2fv (&t[ti++]);
  4098. glVertex3fv(&v[(j+1)*4]);
  4099. }
  4100. glEnd();
  4101. }
  4102. secs = timer(1);
  4103. }
  4104. rate = rate * (secspertest/secs);
  4105. rate = cVert * (rate/cVertDiv2);
  4106. for (k=0; k<loopcount; k++) {
  4107. if (starttest(k)) {
  4108. for(i=(rate)/cVertDiv2; i; i--) {
  4109. glBegin(GL_QUAD_STRIP);
  4110. for (j=0, ti=0; j<=cVertDiv2; j+=2, ti=ti%4 ) {
  4111. glNormal3fv(&n[0]);
  4112. glTexCoord2fv (&t[ti++]);
  4113. glVertex3fv(&v[j*4]);
  4114. glNormal3fv(&n[4]);
  4115. glTexCoord2fv (&t[ti++]);
  4116. glVertex3fv(&v[(j+1)*4]);
  4117. }
  4118. for (j=cVertDiv2-2, ti=0; j>=0; j-=2, ti=ti%4 ) {
  4119. glTexCoord2fv (&t[ti++]);
  4120. glNormal3fv(&n[8]);
  4121. glVertex3fv(&v[j*4]);
  4122. glNormal3fv(&n[12]);
  4123. glTexCoord2fv (&t[ti++]);
  4124. glVertex3fv(&v[(j+1)*4]);
  4125. }
  4126. glEnd();
  4127. }
  4128. if (!mod_average)
  4129. sprintf(pbuf, "Angle %6.2f", angle);
  4130. }
  4131. endtest(pbuf, rate, 0);
  4132. }
  4133. glPopMatrix();
  4134. }
  4135. printaverage();
  4136. } else if (!mod_cmode && mod_shade) {
  4137. /*** GOURAUD SHADED RGB TMESH ***/
  4138. sum_secs = 0.0;
  4139. sum_n = 0;
  4140. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  4141. glPushMatrix();
  4142. glRotatef(angle-90.0, 0, 0, 1);
  4143. /****** Calibration Loop ******/
  4144. secs = 0.0; rate = 125;
  4145. while (secs < (secspertest/4.0)) {
  4146. rate = rate*2;
  4147. starttest(0);
  4148. for(i=(rate)/cVertDiv2; i; i--) {
  4149. glBegin(GL_QUAD_STRIP);
  4150. for (j=0, ti=0; j<=cVertDiv2; j+=2, ti=ti%4 ) {
  4151. glColor3fv(&c[16]);
  4152. glTexCoord2fv (&t[ti++]);
  4153. glVertex3fv(&v[j*4]);
  4154. glColor3fv(&c[20]);
  4155. glTexCoord2fv (&t[ti++]);
  4156. glVertex3fv(&v[(j+1)*4]);
  4157. }
  4158. for (j=cVertDiv2-2, ti=0; j>=0; j-=2, ti=ti%4 ) {
  4159. glColor3fv(&c[4]);
  4160. glTexCoord2fv (&t[ti++]);
  4161. glVertex3fv(&v[j*4]);
  4162. glColor3fv(&c[8]);
  4163. glTexCoord2fv (&t[ti++]);
  4164. glVertex3fv(&v[(j+1)*4]);
  4165. }
  4166. glEnd();
  4167. }
  4168. secs = timer(1);
  4169. }
  4170. rate = rate * (secspertest/secs);
  4171. rate = cVert * (rate/cVertDiv2);
  4172. /* Do the real thing GOURAUD shaded qstrip */
  4173. for (k=0; k<loopcount; k++) {
  4174. if (starttest(k)) {
  4175. for(i=(rate)/cVertDiv2; i; i--) {
  4176. glBegin(GL_QUAD_STRIP);
  4177. for (j=0, ti=0; j<=cVertDiv2; j+=2, ti=ti%4) {
  4178. glColor3fv(&c[16]);
  4179. glTexCoord2fv (&t[ti++]);
  4180. glVertex3fv(&v[j*4]);
  4181. glColor3fv(&c[20]);
  4182. glTexCoord2fv (&t[ti++]);
  4183. glVertex3fv(&v[(j+1)*4]);
  4184. }
  4185. for (j=cVertDiv2-2, ti=0; j>=0; j-=2, ti=ti%4) {
  4186. glColor3fv(&c[4]);
  4187. glTexCoord2fv (&t[ti++]);
  4188. glVertex3fv(&v[j*4]);
  4189. glColor3fv(&c[8]);
  4190. glTexCoord2fv (&t[ti++]);
  4191. glVertex3fv(&v[(j+1)*4]);
  4192. }
  4193. glEnd();
  4194. }
  4195. }
  4196. if (!mod_average)
  4197. sprintf(pbuf, "Angle %6.2f", angle);
  4198. endtest(pbuf, rate, 0);
  4199. }
  4200. glPopMatrix();
  4201. }
  4202. printaverage();
  4203. }
  4204. } else { /* must be 2d */
  4205. if (mod_cmode && mod_shade) { /* color map lighting yet */
  4206. /*** GOURAUD SHADED CMODE TMESH ***/
  4207. /* 255 = r, 240 = g, 255 = b */
  4208. makeramp(208,255,0,0,0,0,255,16);
  4209. makeramp(224,0,0,255,255,255,0,16);
  4210. makeramp(240,255,255,0,255,0,255,16);
  4211. sum_secs = 0.0;
  4212. sum_n = 0;
  4213. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  4214. glPushMatrix();
  4215. glRotatef(angle-90.0, 0, 0, 1);
  4216. /****** Calibration Loop ******/
  4217. secs = 0.0; rate = 125;
  4218. while (secs < (secspertest/4.0)) {
  4219. rate = rate*2;
  4220. starttest(0);
  4221. for(i=(rate)/cVertDiv2; i; i--) {
  4222. glBegin(GL_QUAD_STRIP);
  4223. for (j=0, ti=0; j<=cVertDiv2; j+=2, ti=ti%4 ) {
  4224. glIndexi(255);
  4225. glTexCoord2fv (&t[ti++]);
  4226. glVertex2fv(&v[j*4]);
  4227. glIndexi(240);
  4228. glTexCoord2fv (&t[ti++]);
  4229. glVertex2fv(&v[(j+1)*4]);
  4230. }
  4231. for (j=cVertDiv2-2, ti=0; j>=0; j-=2, ti=ti%4 ) {
  4232. glIndexi(223);
  4233. glTexCoord2fv (&t[ti++]);
  4234. glVertex2fv(&v[j*4]);
  4235. glIndexi(208);
  4236. glTexCoord2fv (&t[ti++]);
  4237. glVertex2fv(&v[(j+1)*4]);
  4238. }
  4239. glEnd();
  4240. }
  4241. secs = timer(1);
  4242. }
  4243. rate = rate * (secspertest/secs);
  4244. rate = cVert * (rate/cVertDiv2);
  4245. /* Do the real thing GOURAUD shaded Cmode qstrip */
  4246. for (k=0; k<loopcount; k++) {
  4247. if (starttest(k)) {
  4248. for(i=(rate)/cVertDiv2; i; i--) {
  4249. glBegin(GL_QUAD_STRIP);
  4250. for (j=0, ti=0; j<=cVertDiv2; j+=2, ti=ti%4 ) {
  4251. glIndexi(255);
  4252. glTexCoord2fv (&t[ti++]);
  4253. glVertex2fv(&v[j*4]);
  4254. glIndexi(240);
  4255. glTexCoord2fv (&t[ti++]);
  4256. glVertex2fv(&v[(j+1)*4]);
  4257. }
  4258. for (j=cVertDiv2-2, ti=0; j>=0; j-=2, ti=ti%4 ) {
  4259. glIndexi(223);
  4260. glTexCoord2fv (&t[ti++]);
  4261. glVertex2fv(&v[j*4]);
  4262. glIndexi(208);
  4263. glTexCoord2fv (&t[ti++]);
  4264. glVertex2fv(&v[(j+1)*4]);
  4265. }
  4266. glEnd();
  4267. }
  4268. }
  4269. if (!mod_average)
  4270. sprintf(pbuf, "Angle %6.2f", angle);
  4271. endtest(pbuf, rate, 0);
  4272. }
  4273. glPopMatrix();
  4274. }
  4275. printaverage();
  4276. } else if (!mod_light && !mod_shade) {
  4277. /*** FLAT SHADED QSTRIP ***/
  4278. sum_secs = 0.0;
  4279. sum_n = 0;
  4280. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  4281. glPushMatrix();
  4282. glRotatef(angle-90.0, 0, 0, 1);
  4283. /****** Calibration Loop ******/
  4284. secs = 0.0; rate = 125;
  4285. while (secs < (secspertest/4.0)) {
  4286. rate = rate*2;
  4287. starttest(0);
  4288. for(i=(rate)/cVertDiv2; i; i--) {
  4289. glBegin(GL_QUAD_STRIP);
  4290. for (j=0, ti=0; j<=cVertDiv2; j++, ti=ti%4 ) {
  4291. glTexCoord2fv (&t[ti++]);
  4292. glVertex2fv(&v[j*4]);
  4293. }
  4294. for (j=cVertDiv2-2, ti=0; j>=0; j-=2, ti=ti%4 ) {
  4295. glTexCoord2fv (&t[ti++]);
  4296. glVertex2fv(&v[j*4]);
  4297. glTexCoord2fv (&t[ti++]);
  4298. glVertex2fv(&v[(j+1)*4]);
  4299. }
  4300. glEnd();
  4301. }
  4302. secs = timer(1);
  4303. }
  4304. rate = rate * (secspertest/secs);
  4305. rate = cVert * (rate/cVertDiv2);
  4306. /* Do the real thing - FLAT shaded qstrip */
  4307. for (k=0; k<loopcount; k++) {
  4308. if (starttest(k)) {
  4309. for(i=(rate)/cVertDiv2; i; i--) {
  4310. glBegin(GL_QUAD_STRIP);
  4311. for (j=0; j<=cVertDiv2, ti=0; j++, ti=ti%4 ) {
  4312. glTexCoord2fv (&t[ti++]);
  4313. glVertex2fv(&v[j*4]);
  4314. }
  4315. for (j=cVertDiv2-2, ti=0; j>=0; j-=2, ti=ti%4 ) {
  4316. glTexCoord2fv (&t[ti++]);
  4317. glVertex2fv(&v[j*4]);
  4318. glTexCoord2fv (&t[ti++]);
  4319. glVertex2fv(&v[(j+1)*4]);
  4320. }
  4321. glEnd();
  4322. }
  4323. }
  4324. if (!mod_average)
  4325. sprintf(pbuf, "Angle %6.2f", angle);
  4326. endtest(pbuf, rate, 0);
  4327. }
  4328. glPopMatrix();
  4329. }
  4330. printaverage();
  4331. } else if (!mod_cmode && mod_light) {
  4332. /*** LIGHTED RGB QSTRIP ***/
  4333. glLoadIdentity();
  4334. glMatrixMode(GL_PROJECTION);
  4335. glLoadIdentity();
  4336. glOrtho(-0.5*xsize,0.5*xsize,-0.5*ysize,0.5*ysize,1.0,-1.0);
  4337. glMatrixMode(GL_MODELVIEW);
  4338. /* set lights */
  4339. setLightingParameters();
  4340. sum_secs = 0.0;
  4341. sum_n = 0;
  4342. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  4343. glPushMatrix();
  4344. glRotatef(angle-90.0, 0, 0, 1);
  4345. /****** Calibration Loop ******/
  4346. secs = 0.0; rate = 125;
  4347. while (secs < (secspertest/4.0)) {
  4348. rate = rate*2;
  4349. starttest(0);
  4350. for(i=(rate)/cVertDiv2; i; i--) {
  4351. glBegin(GL_QUAD_STRIP);
  4352. for (j=0, ti=0; j<=cVertDiv2; j+=2, ti=ti%4 ) {
  4353. glNormal3fv(&n[0]);
  4354. glTexCoord2fv (&t[ti++]);
  4355. glVertex2fv(&v[j*4]);
  4356. glNormal3fv(&n[4]);
  4357. glTexCoord2fv (&t[ti++]);
  4358. glVertex2fv(&v[(j+1)*4]);
  4359. }
  4360. for (j=cVertDiv2-2, ti=0; j>=0; j-=2, ti=ti%4 ) {
  4361. glNormal3fv(&n[8]);
  4362. glTexCoord2fv (&t[ti++]);
  4363. glVertex2fv(&v[j*4]);
  4364. glNormal3fv(&n[12]);
  4365. glTexCoord2fv (&t[ti++]);
  4366. glVertex2fv(&v[(j+1)*4]);
  4367. }
  4368. glEnd();
  4369. }
  4370. secs = timer(1);
  4371. }
  4372. rate = rate * (secspertest/secs);
  4373. rate = cVert * (rate/cVertDiv2);
  4374. for (k=0; k<loopcount; k++) {
  4375. if (starttest(k)) {
  4376. for(i=(rate)/cVertDiv2, ti=0; i; i--) {
  4377. glBegin(GL_QUAD_STRIP);
  4378. for (j=0; j<=cVertDiv2; j+=2, ti=ti%4 ) {
  4379. glNormal3fv(&n[0]);
  4380. glTexCoord2fv (&t[ti++]);
  4381. glVertex2fv(&v[j*4]);
  4382. glNormal3fv(&n[4]);
  4383. glTexCoord2fv (&t[ti++]);
  4384. glVertex2fv(&v[(j+1)*4]);
  4385. }
  4386. for (j=cVertDiv2-2, ti=0; j>=0; j-=2, ti=ti%4 ) {
  4387. glNormal3fv(&n[8]);
  4388. glTexCoord2fv (&t[ti++]);
  4389. glVertex2fv(&v[j*4]);
  4390. glNormal3fv(&n[12]);
  4391. glTexCoord2fv (&t[ti++]);
  4392. glVertex2fv(&v[(j+1)*4]);
  4393. }
  4394. glEnd();
  4395. }
  4396. }
  4397. if (!mod_average)
  4398. sprintf(pbuf, "Angle %6.2f", angle);
  4399. endtest(pbuf, rate, 0);
  4400. }
  4401. glPopMatrix();
  4402. }
  4403. printaverage();
  4404. } else if (!mod_cmode && mod_shade) {
  4405. /*** GOURAUD SHADED RGB TMESH ***/
  4406. sum_secs = 0.0;
  4407. sum_n = 0;
  4408. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  4409. glPushMatrix();
  4410. glRotatef(angle-90.0, 0, 0, 1);
  4411. /****** Calibration Loop ******/
  4412. secs = 0.0; rate = 125;
  4413. while (secs < (secspertest/4.0)) {
  4414. rate = rate*2;
  4415. starttest(0);
  4416. for(i=(rate)/cVertDiv2; i; i--) {
  4417. glBegin(GL_QUAD_STRIP);
  4418. for (j=0, ti=0; j<=cVertDiv2; j+=2, ti=ti%4 ) {
  4419. glColor3fv(&c[16]);
  4420. glTexCoord2fv (&t[ti++]);
  4421. glVertex2fv(&v[j*4]);
  4422. glColor3fv(&c[20]);
  4423. glTexCoord2fv (&t[ti++]);
  4424. glVertex2fv(&v[(j+1)*4]);
  4425. }
  4426. for (j=cVertDiv2-2, ti=0; j>=0; j-=2, ti=ti%4 ) {
  4427. glColor3fv(&c[4]);
  4428. glTexCoord2fv (&t[ti++]);
  4429. glVertex2fv(&v[j*4]);
  4430. glColor3fv(&c[8]);
  4431. glTexCoord2fv (&t[ti++]);
  4432. glVertex2fv(&v[(j+1)*4]);
  4433. }
  4434. glEnd();
  4435. }
  4436. secs = timer(1);
  4437. }
  4438. rate = rate * (secspertest/secs);
  4439. rate = cVert * (rate/cVertDiv2);
  4440. /* Do the real thing GOURAUD shaded qstrip */
  4441. for (k=0; k<loopcount; k++) {
  4442. if (starttest(k)) {
  4443. for(i=(rate)/cVertDiv2; i; i--) {
  4444. glBegin(GL_QUAD_STRIP);
  4445. for (j=0, ti=0; j<=cVertDiv2; j+=2, ti=ti%4 ) {
  4446. glColor3fv(&c[16]);
  4447. glTexCoord2fv (&t[ti++]);
  4448. glVertex2fv(&v[j*4]);
  4449. glColor3fv(&c[20]);
  4450. glTexCoord2fv (&t[ti++]);
  4451. glVertex2fv(&v[(j+1)*4]);
  4452. }
  4453. for (j=cVertDiv2-2, ti=0; j>=0; j-=2, ti=ti%4 ) {
  4454. glColor3fv(&c[4]);
  4455. glTexCoord2fv (&t[ti++]);
  4456. glVertex2fv(&v[j*4]);
  4457. glColor3fv(&c[8]);
  4458. glTexCoord2fv (&t[ti++]);
  4459. glVertex2fv(&v[(j+1)*4]);
  4460. }
  4461. glEnd();
  4462. }
  4463. }
  4464. if (!mod_average)
  4465. sprintf(pbuf, "Angle %6.2f", angle);
  4466. endtest(pbuf, rate, 0);
  4467. }
  4468. glPopMatrix();
  4469. }
  4470. printaverage();
  4471. }
  4472. }
  4473. if (mod_doublebuffer) {
  4474. auxSwapBuffers();
  4475. Sleep(2000); /* for visual feedback */
  4476. }
  4477. exit(0);
  4478. }
  4479. static void perfpolytex(void)
  4480. {
  4481. float *vtx = &v[0];
  4482. int i, k;
  4483. char pbuf[256];
  4484. int cPoly;
  4485. if (mod_texfile) MyLoadImage();
  4486. else CreateImage();
  4487. InitTexParams();
  4488. /* If the polygon size is specified, set the number of polygons to
  4489. ** fit the window. The maximum number of polygons is 5.
  4490. */
  4491. cPoly = 5;
  4492. if (mod_size) {
  4493. cPoly = (int) (MINDIMENSION/2 / prim_size);
  4494. if (cPoly < 1) cPoly = 1;
  4495. if (cPoly > 5) cPoly = 5;
  4496. }
  4497. if (!mod_2d) {
  4498. /**** 3D POLYGONS ****/
  4499. if (mod_light && !mod_cmode) {
  4500. /*** POLYGONS (LIGHTED) *****/
  4501. glLoadIdentity();
  4502. glMatrixMode(GL_PROJECTION);
  4503. glLoadIdentity();
  4504. glOrtho(-0.5*xsize, 0.5*xsize,-0.5*ysize, 0.5*ysize,1.0, -1.0);
  4505. glMatrixMode(GL_MODELVIEW);
  4506. /* set lights */
  4507. setLightingParameters();
  4508. sum_secs = 0.0;
  4509. sum_n = 0;
  4510. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  4511. if (!mod_average)
  4512. sprintf (pbuf, "Angle %6.2f", angle);
  4513. glPushMatrix();
  4514. glRotatef(angle-90.0, 0, 0, 1);
  4515. /****** Calibration Loop ******/
  4516. secs = 0.0; rate = 125;
  4517. while (secs < (secspertest/4.0)) {
  4518. rate = rate*2;
  4519. if (mod_lmcolor) {
  4520. starttest(0);
  4521. for(i=(rate)/cPoly; i; i--) {
  4522. glBegin(GL_QUADS);
  4523. switch (cPoly) {
  4524. case 5:
  4525. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  4526. glTexCoord2fv(&t[0]); glVertex3fv(vtx+32);
  4527. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  4528. glTexCoord2fv(&t[2]); glVertex3fv(vtx+36);
  4529. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  4530. glTexCoord2fv(&t[4]); glVertex3fv(vtx+44);
  4531. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  4532. glTexCoord2fv(&t[6]); glVertex3fv(vtx+40);
  4533. case 4:
  4534. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  4535. glTexCoord2fv(&t[0]); glVertex3fv(vtx+24);
  4536. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  4537. glTexCoord2fv(&t[2]); glVertex3fv(vtx+28);
  4538. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  4539. glTexCoord2fv(&t[4]); glVertex3fv(vtx+36);
  4540. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  4541. glTexCoord2fv(&t[6]); glVertex3fv(vtx+32);
  4542. case 3:
  4543. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  4544. glTexCoord2fv(&t[0]); glVertex3fv(vtx+16);
  4545. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  4546. glTexCoord2fv(&t[2]); glVertex3fv(vtx+20);
  4547. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  4548. glTexCoord2fv(&t[4]); glVertex3fv(vtx+28);
  4549. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  4550. glTexCoord2fv(&t[6]); glVertex3fv(vtx+24);
  4551. case 2:
  4552. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  4553. glTexCoord2fv(&t[0]); glVertex3fv(vtx+8);
  4554. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  4555. glTexCoord2fv(&t[2]); glVertex3fv(vtx+12);
  4556. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  4557. glTexCoord2fv(&t[4]); glVertex3fv(vtx+20);
  4558. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  4559. glTexCoord2fv(&t[6]); glVertex3fv(vtx+16);
  4560. case 1:
  4561. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  4562. glTexCoord2fv(&t[0]); glVertex3fv(vtx);
  4563. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  4564. glTexCoord2fv(&t[2]); glVertex3fv(vtx+4);
  4565. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  4566. glTexCoord2fv(&t[4]); glVertex3fv(vtx+12);
  4567. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  4568. glTexCoord2fv(&t[6]); glVertex3fv(vtx+8);
  4569. }
  4570. glEnd();
  4571. }
  4572. secs = timer(1);
  4573. }
  4574. else {
  4575. starttest(0);
  4576. for(i=(rate)/cPoly; i; i--) {
  4577. glBegin(GL_QUADS);
  4578. switch (cPoly) {
  4579. case 5:
  4580. glTexCoord2fv(&t[0]);
  4581. glNormal3fv(&n[0]); glVertex3fv(vtx+32);
  4582. glTexCoord2fv(&t[2]);
  4583. glNormal3fv(&n[4]); glVertex3fv(vtx+36);
  4584. glTexCoord2fv(&t[4]);
  4585. glNormal3fv(&n[8]); glVertex3fv(vtx+44);
  4586. glTexCoord2fv(&t[6]);
  4587. glNormal3fv(&n[12]); glVertex3fv(vtx+40);
  4588. case 4:
  4589. glTexCoord2fv(&t[0]);
  4590. glNormal3fv(&n[0]); glVertex3fv(vtx+24);
  4591. glTexCoord2fv(&t[2]);
  4592. glNormal3fv(&n[4]); glVertex3fv(vtx+28);
  4593. glTexCoord2fv(&t[4]);
  4594. glNormal3fv(&n[8]); glVertex3fv(vtx+36);
  4595. glTexCoord2fv(&t[6]);
  4596. glNormal3fv(&n[12]); glVertex3fv(vtx+32);
  4597. case 3:
  4598. glTexCoord2fv(&t[0]);
  4599. glNormal3fv(&n[0]); glVertex3fv(vtx+16);
  4600. glTexCoord2fv(&t[2]);
  4601. glNormal3fv(&n[4]); glVertex3fv(vtx+20);
  4602. glTexCoord2fv(&t[4]);
  4603. glNormal3fv(&n[8]); glVertex3fv(vtx+28);
  4604. glTexCoord2fv(&t[6]);
  4605. glNormal3fv(&n[12]); glVertex3fv(vtx+24);
  4606. case 2:
  4607. glTexCoord2fv(&t[0]);
  4608. glNormal3fv(&n[0]); glVertex3fv(vtx+8);
  4609. glTexCoord2fv(&t[2]);
  4610. glNormal3fv(&n[4]); glVertex3fv(vtx+12);
  4611. glTexCoord2fv(&t[4]);
  4612. glNormal3fv(&n[8]); glVertex3fv(vtx+20);
  4613. glTexCoord2fv(&t[6]);
  4614. glNormal3fv(&n[12]); glVertex3fv(vtx+16);
  4615. case 1:
  4616. glTexCoord2fv(&t[0]);
  4617. glNormal3fv(&n[0]); glVertex3fv(vtx);
  4618. glTexCoord2fv(&t[2]);
  4619. glNormal3fv(&n[4]); glVertex3fv(vtx+4);
  4620. glTexCoord2fv(&t[4]);
  4621. glNormal3fv(&n[8]); glVertex3fv(vtx+12);
  4622. glTexCoord2fv(&t[6]);
  4623. glNormal3fv(&n[12]); glVertex3fv(vtx+8);
  4624. }
  4625. glEnd();
  4626. }
  4627. secs = timer(1);
  4628. }
  4629. }
  4630. rate = rate * (secspertest/secs);
  4631. rate = cPoly * (rate/cPoly);
  4632. for (k=0; k<loopcount; k++) {
  4633. if (mod_lmcolor) {
  4634. if (starttest(k)) {
  4635. for(i=(rate)/cPoly; i; i--) {
  4636. glBegin(GL_QUADS);
  4637. switch (cPoly) {
  4638. case 5:
  4639. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  4640. glTexCoord2fv(&t[0]); glVertex3fv(vtx+32);
  4641. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  4642. glTexCoord2fv(&t[2]); glVertex3fv(vtx+36);
  4643. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  4644. glTexCoord2fv(&t[4]); glVertex3fv(vtx+44);
  4645. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  4646. glTexCoord2fv(&t[6]); glVertex3fv(vtx+40);
  4647. case 4:
  4648. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  4649. glTexCoord2fv(&t[0]); glVertex3fv(vtx+24);
  4650. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  4651. glTexCoord2fv(&t[2]); glVertex3fv(vtx+28);
  4652. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  4653. glTexCoord2fv(&t[4]); glVertex3fv(vtx+36);
  4654. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  4655. glTexCoord2fv(&t[6]); glVertex3fv(vtx+32);
  4656. case 3:
  4657. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  4658. glTexCoord2fv(&t[0]); glVertex3fv(vtx+16);
  4659. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  4660. glTexCoord2fv(&t[2]); glVertex3fv(vtx+20);
  4661. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  4662. glTexCoord2fv(&t[4]); glVertex3fv(vtx+28);
  4663. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  4664. glTexCoord2fv(&t[6]); glVertex3fv(vtx+24);
  4665. case 2:
  4666. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  4667. glTexCoord2fv(&t[0]); glVertex3fv(vtx+8);
  4668. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  4669. glTexCoord2fv(&t[2]); glVertex3fv(vtx+12);
  4670. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  4671. glTexCoord2fv(&t[4]); glVertex3fv(vtx+20);
  4672. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  4673. glTexCoord2fv(&t[6]); glVertex3fv(vtx+16);
  4674. case 1:
  4675. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  4676. glTexCoord2fv(&t[0]); glVertex3fv(vtx);
  4677. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  4678. glTexCoord2fv(&t[2]); glVertex3fv(vtx+4);
  4679. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  4680. glTexCoord2fv(&t[4]); glVertex3fv(vtx+12);
  4681. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  4682. glTexCoord2fv(&t[6]); glVertex3fv(vtx+8);
  4683. }
  4684. glEnd();
  4685. }
  4686. }
  4687. endtest(pbuf, rate, 0);
  4688. }
  4689. else {
  4690. if (starttest(k)) {
  4691. for(i=(rate)/cPoly; i; i--) {
  4692. glBegin(GL_QUADS);
  4693. switch (cPoly) {
  4694. case 5:
  4695. glTexCoord2fv(&t[0]);
  4696. glNormal3fv(&n[0]); glVertex3fv(vtx+32);
  4697. glTexCoord2fv(&t[2]);
  4698. glNormal3fv(&n[4]); glVertex3fv(vtx+36);
  4699. glTexCoord2fv(&t[4]);
  4700. glNormal3fv(&n[8]); glVertex3fv(vtx+44);
  4701. glTexCoord2fv(&t[6]);
  4702. glNormal3fv(&n[12]); glVertex3fv(vtx+40);
  4703. case 4:
  4704. glTexCoord2fv(&t[0]);
  4705. glNormal3fv(&n[0]); glVertex3fv(vtx+24);
  4706. glTexCoord2fv(&t[2]);
  4707. glNormal3fv(&n[4]); glVertex3fv(vtx+28);
  4708. glTexCoord2fv(&t[4]);
  4709. glNormal3fv(&n[8]); glVertex3fv(vtx+36);
  4710. glTexCoord2fv(&t[6]);
  4711. glNormal3fv(&n[12]); glVertex3fv(vtx+32);
  4712. case 3:
  4713. glTexCoord2fv(&t[0]);
  4714. glNormal3fv(&n[0]); glVertex3fv(vtx+16);
  4715. glTexCoord2fv(&t[2]);
  4716. glNormal3fv(&n[4]); glVertex3fv(vtx+20);
  4717. glTexCoord2fv(&t[4]);
  4718. glNormal3fv(&n[8]); glVertex3fv(vtx+28);
  4719. glTexCoord2fv(&t[6]);
  4720. glNormal3fv(&n[12]); glVertex3fv(vtx+24);
  4721. case 2:
  4722. glTexCoord2fv(&t[0]);
  4723. glNormal3fv(&n[0]); glVertex3fv(vtx+8);
  4724. glTexCoord2fv(&t[2]);
  4725. glNormal3fv(&n[4]); glVertex3fv(vtx+12);
  4726. glTexCoord2fv(&t[4]);
  4727. glNormal3fv(&n[8]); glVertex3fv(vtx+20);
  4728. glTexCoord2fv(&t[6]);
  4729. glNormal3fv(&n[12]); glVertex3fv(vtx+16);
  4730. case 1:
  4731. glTexCoord2fv(&t[0]);
  4732. glNormal3fv(&n[0]); glVertex3fv(vtx);
  4733. glTexCoord2fv(&t[2]);
  4734. glNormal3fv(&n[4]); glVertex3fv(vtx+4);
  4735. glTexCoord2fv(&t[4]);
  4736. glNormal3fv(&n[8]); glVertex3fv(vtx+12);
  4737. glTexCoord2fv(&t[6]);
  4738. glNormal3fv(&n[12]); glVertex3fv(vtx+8);
  4739. }
  4740. glEnd();
  4741. }
  4742. }
  4743. endtest(pbuf, rate, 0);
  4744. }
  4745. }
  4746. glPopMatrix();
  4747. }
  4748. printaverage();
  4749. } else if (mod_shade && !mod_cmode) {
  4750. /*** POLYGONS (SHADED RGB) *****/
  4751. sum_secs = 0.0;
  4752. sum_n = 0;
  4753. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  4754. if (!mod_average)
  4755. sprintf(pbuf, "Angle %6.2f", angle);
  4756. glPushMatrix();
  4757. glRotatef(angle-90.0, 0, 0, 1);
  4758. /****** Calibration Loop ******/
  4759. secs = 0.0; rate = 125;
  4760. while (secs < (secspertest/4.0)) {
  4761. rate = rate*2;
  4762. starttest(0);
  4763. for(i=(rate)/cPoly; i; i--) {
  4764. glBegin(GL_QUADS);
  4765. switch (cPoly) {
  4766. case 5:
  4767. glTexCoord2fv(&t[0]);
  4768. glColor3fv(&c[4]); glVertex3fv(vtx+32);
  4769. glTexCoord2fv(&t[2]);
  4770. glColor3fv(&c[16]); glVertex3fv(vtx+36);
  4771. glTexCoord2fv(&t[4]);
  4772. glColor3fv(&c[8]); glVertex3fv(vtx+44);
  4773. glTexCoord2fv(&t[6]);
  4774. glColor3fv(&c[8]); glVertex3fv(vtx+40);
  4775. case 4:
  4776. glTexCoord2fv(&t[0]);
  4777. glColor3fv(&c[4]); glVertex3fv(vtx+24);
  4778. glTexCoord2fv(&t[2]);
  4779. glColor3fv(&c[16]); glVertex3fv(vtx+28);
  4780. glTexCoord2fv(&t[4]);
  4781. glColor3fv(&c[8]); glVertex3fv(vtx+36);
  4782. glTexCoord2fv(&t[6]);
  4783. glColor3fv(&c[8]); glVertex3fv(vtx+32);
  4784. case 3:
  4785. glTexCoord2fv(&t[0]);
  4786. glColor3fv(&c[4]); glVertex3fv(vtx+16);
  4787. glTexCoord2fv(&t[2]);
  4788. glColor3fv(&c[16]); glVertex3fv(vtx+20);
  4789. glTexCoord2fv(&t[4]);
  4790. glColor3fv(&c[8]); glVertex3fv(vtx+28);
  4791. glTexCoord2fv(&t[6]);
  4792. glColor3fv(&c[8]); glVertex3fv(vtx+24);
  4793. case 2:
  4794. glTexCoord2fv(&t[0]);
  4795. glColor3fv(&c[4]); glVertex3fv(vtx+8);
  4796. glTexCoord2fv(&t[2]);
  4797. glColor3fv(&c[16]); glVertex3fv(vtx+12);
  4798. glTexCoord2fv(&t[4]);
  4799. glColor3fv(&c[8]); glVertex3fv(vtx+20);
  4800. glTexCoord2fv(&t[6]);
  4801. glColor3fv(&c[8]); glVertex3fv(vtx+16);
  4802. case 1:
  4803. glTexCoord2fv(&t[0]);
  4804. glColor3fv(&c[4]); glVertex3fv(vtx);
  4805. glTexCoord2fv(&t[2]);
  4806. glColor3fv(&c[16]); glVertex3fv(vtx+4);
  4807. glTexCoord2fv(&t[4]);
  4808. glColor3fv(&c[8]); glVertex3fv(vtx+12);
  4809. glTexCoord2fv(&t[6]);
  4810. glColor3fv(&c[8]); glVertex3fv(vtx+8);
  4811. }
  4812. glEnd();
  4813. }
  4814. secs = timer(1);
  4815. }
  4816. rate = rate * (secspertest/secs);
  4817. rate = cPoly * (rate/cPoly);
  4818. for (k=0; k<loopcount; k++) {
  4819. if (starttest(k)) {
  4820. for(i=(rate)/cPoly; i; i--) {
  4821. glBegin(GL_QUADS);
  4822. switch (cPoly) {
  4823. case 5:
  4824. glTexCoord2fv(&t[0]);
  4825. glColor3fv(&c[4]); glVertex3fv(vtx+32);
  4826. glTexCoord2fv(&t[2]);
  4827. glColor3fv(&c[16]); glVertex3fv(vtx+36);
  4828. glTexCoord2fv(&t[4]);
  4829. glColor3fv(&c[8]); glVertex3fv(vtx+44);
  4830. glTexCoord2fv(&t[6]);
  4831. glColor3fv(&c[8]); glVertex3fv(vtx+40);
  4832. case 4:
  4833. glTexCoord2fv(&t[0]);
  4834. glColor3fv(&c[4]); glVertex3fv(vtx+24);
  4835. glTexCoord2fv(&t[2]);
  4836. glColor3fv(&c[16]); glVertex3fv(vtx+28);
  4837. glTexCoord2fv(&t[4]);
  4838. glColor3fv(&c[8]); glVertex3fv(vtx+36);
  4839. glTexCoord2fv(&t[6]);
  4840. glColor3fv(&c[8]); glVertex3fv(vtx+32);
  4841. case 3:
  4842. glTexCoord2fv(&t[0]);
  4843. glColor3fv(&c[4]); glVertex3fv(vtx+16);
  4844. glTexCoord2fv(&t[2]);
  4845. glColor3fv(&c[16]); glVertex3fv(vtx+20);
  4846. glTexCoord2fv(&t[4]);
  4847. glColor3fv(&c[8]); glVertex3fv(vtx+28);
  4848. glTexCoord2fv(&t[6]);
  4849. glColor3fv(&c[8]); glVertex3fv(vtx+24);
  4850. case 2:
  4851. glTexCoord2fv(&t[0]);
  4852. glColor3fv(&c[4]); glVertex3fv(vtx+8);
  4853. glTexCoord2fv(&t[2]);
  4854. glColor3fv(&c[16]); glVertex3fv(vtx+12);
  4855. glTexCoord2fv(&t[4]);
  4856. glColor3fv(&c[8]); glVertex3fv(vtx+20);
  4857. glTexCoord2fv(&t[6]);
  4858. glColor3fv(&c[8]); glVertex3fv(vtx+16);
  4859. case 1:
  4860. glTexCoord2fv(&t[0]);
  4861. glColor3fv(&c[4]); glVertex3fv(vtx);
  4862. glTexCoord2fv(&t[2]);
  4863. glColor3fv(&c[16]); glVertex3fv(vtx+4);
  4864. glTexCoord2fv(&t[4]);
  4865. glColor3fv(&c[8]); glVertex3fv(vtx+12);
  4866. glTexCoord2fv(&t[6]);
  4867. glColor3fv(&c[8]); glVertex3fv(vtx+8);
  4868. }
  4869. glEnd();
  4870. }
  4871. }
  4872. endtest(pbuf, rate, 0);
  4873. }
  4874. glPopMatrix();
  4875. }
  4876. printaverage();
  4877. } else if (mod_shade && mod_cmode) {
  4878. /*** POLYGONS (SHADED COLOR MAPPED) *****/
  4879. /* 255 = r, 240 = g, 255 = b */
  4880. makeramp(208, 255, 0, 0, 0, 0, 255, 16);
  4881. makeramp(224, 0, 0, 255, 255, 255, 0, 16);
  4882. makeramp(240, 255, 255, 0, 255, 0, 255, 16);
  4883. sum_secs = 0.0;
  4884. sum_n = 0;
  4885. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  4886. if (!mod_average)
  4887. sprintf(pbuf, "Angle %6.2f", angle);
  4888. glPushMatrix();
  4889. glRotatef(angle-90.0, 0, 0, 1);
  4890. /****** Calibration Loop ******/
  4891. secs = 0.0; rate = 125;
  4892. while (secs < (secspertest/4.0)) {
  4893. rate = rate*2;
  4894. starttest(0);
  4895. for(i=(rate)/cPoly; i; i--) {
  4896. glBegin(GL_QUADS);
  4897. switch (cPoly) {
  4898. case 5:
  4899. glTexCoord2fv(&t[0]);
  4900. glIndexi(255); glVertex3fv(vtx+32);
  4901. glTexCoord2fv(&t[2]);
  4902. glIndexi(240); glVertex3fv(vtx+36);
  4903. glTexCoord2fv(&t[4]);
  4904. glIndexi(223); glVertex3fv(vtx+44);
  4905. glTexCoord2fv(&t[6]);
  4906. glIndexi(208); glVertex3fv(vtx+40);
  4907. case 4:
  4908. glTexCoord2fv(&t[0]);
  4909. glIndexi(255); glVertex3fv(vtx+24);
  4910. glTexCoord2fv(&t[2]);
  4911. glIndexi(240); glVertex3fv(vtx+28);
  4912. glTexCoord2fv(&t[4]);
  4913. glIndexi(223); glVertex3fv(vtx+36);
  4914. glTexCoord2fv(&t[6]);
  4915. glIndexi(208); glVertex3fv(vtx+32);
  4916. case 3:
  4917. glTexCoord2fv(&t[0]);
  4918. glIndexi(255); glVertex3fv(vtx+16);
  4919. glTexCoord2fv(&t[2]);
  4920. glIndexi(240); glVertex3fv(vtx+20);
  4921. glTexCoord2fv(&t[4]);
  4922. glIndexi(223); glVertex3fv(vtx+28);
  4923. glTexCoord2fv(&t[6]);
  4924. glIndexi(208); glVertex3fv(vtx+24);
  4925. case 2:
  4926. glTexCoord2fv(&t[0]);
  4927. glIndexi(255); glVertex3fv(vtx+8);
  4928. glTexCoord2fv(&t[2]);
  4929. glIndexi(240); glVertex3fv(vtx+12);
  4930. glTexCoord2fv(&t[4]);
  4931. glIndexi(223); glVertex3fv(vtx+20);
  4932. glTexCoord2fv(&t[6]);
  4933. glIndexi(208); glVertex3fv(vtx+16);
  4934. case 1:
  4935. glTexCoord2fv(&t[0]);
  4936. glIndexi(255); glVertex3fv(vtx);
  4937. glTexCoord2fv(&t[2]);
  4938. glIndexi(240); glVertex3fv(vtx+4);
  4939. glTexCoord2fv(&t[4]);
  4940. glIndexi(223); glVertex3fv(vtx+12);
  4941. glTexCoord2fv(&t[6]);
  4942. glIndexi(208); glVertex3fv(vtx+8);
  4943. }
  4944. glEnd();
  4945. }
  4946. secs = timer(1);
  4947. }
  4948. rate = rate * (secspertest/secs);
  4949. rate = cPoly * (rate/cPoly);
  4950. for (k=0; k<loopcount; k++) {
  4951. if (starttest(k)) {
  4952. for(i=(rate)/cPoly; i; i--) {
  4953. glBegin(GL_QUADS);
  4954. switch (cPoly) {
  4955. case 5:
  4956. glTexCoord2fv(&t[0]);
  4957. glIndexi(255); glVertex3fv(vtx+32);
  4958. glTexCoord2fv(&t[2]);
  4959. glIndexi(240); glVertex3fv(vtx+36);
  4960. glTexCoord2fv(&t[4]);
  4961. glIndexi(223); glVertex3fv(vtx+44);
  4962. glTexCoord2fv(&t[6]);
  4963. glIndexi(208); glVertex3fv(vtx+40);
  4964. case 4:
  4965. glTexCoord2fv(&t[0]);
  4966. glIndexi(255); glVertex3fv(vtx+24);
  4967. glTexCoord2fv(&t[2]);
  4968. glIndexi(240); glVertex3fv(vtx+28);
  4969. glTexCoord2fv(&t[4]);
  4970. glIndexi(223); glVertex3fv(vtx+36);
  4971. glTexCoord2fv(&t[6]);
  4972. glIndexi(208); glVertex3fv(vtx+32);
  4973. case 3:
  4974. glTexCoord2fv(&t[0]);
  4975. glIndexi(255); glVertex3fv(vtx+16);
  4976. glTexCoord2fv(&t[2]);
  4977. glIndexi(240); glVertex3fv(vtx+20);
  4978. glTexCoord2fv(&t[4]);
  4979. glIndexi(223); glVertex3fv(vtx+28);
  4980. glTexCoord2fv(&t[6]);
  4981. glIndexi(208); glVertex3fv(vtx+24);
  4982. case 2:
  4983. glTexCoord2fv(&t[0]);
  4984. glIndexi(255); glVertex3fv(vtx+8);
  4985. glTexCoord2fv(&t[2]);
  4986. glIndexi(240); glVertex3fv(vtx+12);
  4987. glTexCoord2fv(&t[4]);
  4988. glIndexi(223); glVertex3fv(vtx+20);
  4989. glTexCoord2fv(&t[6]);
  4990. glIndexi(208); glVertex3fv(vtx+16);
  4991. case 1:
  4992. glTexCoord2fv(&t[0]);
  4993. glIndexi(255); glVertex3fv(vtx);
  4994. glTexCoord2fv(&t[2]);
  4995. glIndexi(240); glVertex3fv(vtx+4);
  4996. glTexCoord2fv(&t[4]);
  4997. glIndexi(223); glVertex3fv(vtx+12);
  4998. glTexCoord2fv(&t[6]);
  4999. glIndexi(208); glVertex3fv(vtx+8);
  5000. }
  5001. glEnd();
  5002. }
  5003. }
  5004. endtest(pbuf, rate, 0);
  5005. }
  5006. glPopMatrix();
  5007. }
  5008. printaverage();
  5009. } else if (!mod_light && !mod_shade) {
  5010. /*** POLYGONS (FLAT SHADED) *****/
  5011. sum_secs = 0.0;
  5012. sum_n = 0;
  5013. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  5014. if (!mod_average)
  5015. sprintf(pbuf, "Angle %6.2f", angle);
  5016. glPushMatrix();
  5017. glRotatef(angle-90.0, 0, 0, 1);
  5018. /****** Calibration Loop ******/
  5019. secs = 0.0; rate = 125;
  5020. while (secs < (secspertest/4.0)) {
  5021. rate = rate*2;
  5022. starttest(0);
  5023. for(i=(rate)/cPoly; i; i--) {
  5024. glBegin(GL_QUADS);
  5025. switch (cPoly) {
  5026. case 5:
  5027. glTexCoord2fv(&t[0]); glVertex3fv(vtx+32);
  5028. glTexCoord2fv(&t[2]); glVertex3fv(vtx+36);
  5029. glTexCoord2fv(&t[4]); glVertex3fv(vtx+44);
  5030. glTexCoord2fv(&t[6]); glVertex3fv(vtx+40);
  5031. case 4:
  5032. glTexCoord2fv(&t[0]); glVertex3fv(vtx+24);
  5033. glTexCoord2fv(&t[2]); glVertex3fv(vtx+28);
  5034. glTexCoord2fv(&t[4]); glVertex3fv(vtx+36);
  5035. glTexCoord2fv(&t[6]); glVertex3fv(vtx+32);
  5036. case 3:
  5037. glTexCoord2fv(&t[0]); glVertex3fv(vtx+16);
  5038. glTexCoord2fv(&t[2]); glVertex3fv(vtx+20);
  5039. glTexCoord2fv(&t[4]); glVertex3fv(vtx+28);
  5040. glTexCoord2fv(&t[6]); glVertex3fv(vtx+24);
  5041. case 2:
  5042. glTexCoord2fv(&t[0]); glVertex3fv(vtx+8);
  5043. glTexCoord2fv(&t[2]); glVertex3fv(vtx+12);
  5044. glTexCoord2fv(&t[4]); glVertex3fv(vtx+20);
  5045. glTexCoord2fv(&t[6]); glVertex3fv(vtx+16);
  5046. case 1:
  5047. glTexCoord2fv(&t[0]); glVertex3fv(vtx);
  5048. glTexCoord2fv(&t[2]); glVertex3fv(vtx+4);
  5049. glTexCoord2fv(&t[4]); glVertex3fv(vtx+12);
  5050. glTexCoord2fv(&t[6]); glVertex3fv(vtx+8);
  5051. }
  5052. glEnd();
  5053. }
  5054. secs = timer(1);
  5055. }
  5056. rate = rate * (secspertest/secs);
  5057. rate = cPoly * (rate/cPoly);
  5058. for (k=0; k<loopcount; k++) {
  5059. if (starttest(k)) {
  5060. for(i=(rate)/cPoly; i; i--) {
  5061. glBegin(GL_QUADS);
  5062. switch (cPoly) {
  5063. case 5:
  5064. glTexCoord2fv(&t[0]); glVertex3fv(vtx+32);
  5065. glTexCoord2fv(&t[2]); glVertex3fv(vtx+36);
  5066. glTexCoord2fv(&t[4]); glVertex3fv(vtx+44);
  5067. glTexCoord2fv(&t[6]); glVertex3fv(vtx+40);
  5068. case 4:
  5069. glTexCoord2fv(&t[0]); glVertex3fv(vtx+24);
  5070. glTexCoord2fv(&t[2]); glVertex3fv(vtx+28);
  5071. glTexCoord2fv(&t[4]); glVertex3fv(vtx+36);
  5072. glTexCoord2fv(&t[6]); glVertex3fv(vtx+32);
  5073. case 3:
  5074. glTexCoord2fv(&t[0]); glVertex3fv(vtx+16);
  5075. glTexCoord2fv(&t[2]); glVertex3fv(vtx+20);
  5076. glTexCoord2fv(&t[4]); glVertex3fv(vtx+28);
  5077. glTexCoord2fv(&t[6]); glVertex3fv(vtx+24);
  5078. case 2:
  5079. glTexCoord2fv(&t[0]); glVertex3fv(vtx+8);
  5080. glTexCoord2fv(&t[2]); glVertex3fv(vtx+12);
  5081. glTexCoord2fv(&t[4]); glVertex3fv(vtx+20);
  5082. glTexCoord2fv(&t[6]); glVertex3fv(vtx+16);
  5083. case 1:
  5084. glTexCoord2fv(&t[0]); glVertex3fv(vtx+0);
  5085. glTexCoord2fv(&t[2]); glVertex3fv(vtx+4);
  5086. glTexCoord2fv(&t[4]); glVertex3fv(vtx+12);
  5087. glTexCoord2fv(&t[6]); glVertex3fv(vtx+8);
  5088. }
  5089. glEnd();
  5090. }
  5091. }
  5092. endtest(pbuf, rate, 0);
  5093. }
  5094. glPopMatrix();
  5095. }
  5096. printaverage();
  5097. }
  5098. } else {
  5099. /**** 2D POLYGONS ****/
  5100. if (mod_light && !mod_cmode) {
  5101. /*** POLYGONS (LIGHTED) *****/
  5102. glLoadIdentity();
  5103. glMatrixMode(GL_PROJECTION);
  5104. glLoadIdentity();
  5105. gluOrtho2D(-0.5*xsize, 0.5*xsize,-0.5*ysize, 0.5*ysize);
  5106. glMatrixMode(GL_MODELVIEW);
  5107. /* set lights */
  5108. setLightingParameters();
  5109. sum_secs = 0.0;
  5110. sum_n = 0;
  5111. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  5112. if (!mod_average)
  5113. sprintf(pbuf, "Angle %6.2f", angle);
  5114. glPushMatrix();
  5115. glRotatef(angle-90.0, 0, 0, 1);
  5116. /****** Calibration Loop ******/
  5117. secs = 0.0; rate = 125;
  5118. while (secs < (secspertest/4.0)) {
  5119. rate = rate*2;
  5120. if (mod_lmcolor) {
  5121. starttest(0);
  5122. for(i=(rate)/cPoly; i; i--) {
  5123. glBegin(GL_QUADS);
  5124. switch (cPoly) {
  5125. case 5:
  5126. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  5127. glTexCoord2fv(&t[0]); glVertex2fv(vtx+32);
  5128. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  5129. glTexCoord2fv(&t[2]); glVertex2fv(vtx+36);
  5130. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  5131. glTexCoord2fv(&t[4]); glVertex2fv(vtx+44);
  5132. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  5133. glTexCoord2fv(&t[6]); glVertex2fv(vtx+40);
  5134. case 4:
  5135. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  5136. glTexCoord2fv(&t[0]); glVertex2fv(vtx+24);
  5137. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  5138. glTexCoord2fv(&t[2]); glVertex2fv(vtx+28);
  5139. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  5140. glTexCoord2fv(&t[4]); glVertex2fv(vtx+36);
  5141. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  5142. glTexCoord2fv(&t[6]); glVertex2fv(vtx+32);
  5143. case 3:
  5144. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  5145. glTexCoord2fv(&t[0]); glVertex2fv(vtx+16);
  5146. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  5147. glTexCoord2fv(&t[2]); glVertex2fv(vtx+20);
  5148. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  5149. glTexCoord2fv(&t[4]); glVertex2fv(vtx+28);
  5150. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  5151. glTexCoord2fv(&t[6]); glVertex2fv(vtx+24);
  5152. case 2:
  5153. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  5154. glTexCoord2fv(&t[0]); glVertex2fv(vtx+8);
  5155. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  5156. glTexCoord2fv(&t[2]); glVertex2fv(vtx+12);
  5157. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  5158. glTexCoord2fv(&t[4]); glVertex2fv(vtx+20);
  5159. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  5160. glTexCoord2fv(&t[6]); glVertex2fv(vtx+16);
  5161. case 1:
  5162. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  5163. glTexCoord2fv(&t[0]); glVertex2fv(vtx);
  5164. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  5165. glTexCoord2fv(&t[2]); glVertex2fv(vtx+4);
  5166. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  5167. glTexCoord2fv(&t[4]); glVertex2fv(vtx+12);
  5168. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  5169. glTexCoord2fv(&t[6]); glVertex2fv(vtx+8);
  5170. }
  5171. glEnd();
  5172. }
  5173. secs = timer(1);
  5174. }
  5175. else {
  5176. starttest(0);
  5177. for(i=(rate)/cPoly; i; i--) {
  5178. glBegin(GL_QUADS);
  5179. switch (cPoly) {
  5180. case 5:
  5181. glTexCoord2fv(&t[0]);
  5182. glNormal3fv(&n[0]); glVertex2fv(vtx+32);
  5183. glTexCoord2fv(&t[2]);
  5184. glNormal3fv(&n[4]); glVertex2fv(vtx+36);
  5185. glTexCoord2fv(&t[4]);
  5186. glNormal3fv(&n[8]); glVertex2fv(vtx+44);
  5187. glTexCoord2fv(&t[6]);
  5188. glNormal3fv(&n[12]); glVertex2fv(vtx+40);
  5189. case 4:
  5190. glTexCoord2fv(&t[0]);
  5191. glNormal3fv(&n[0]); glVertex2fv(vtx+24);
  5192. glTexCoord2fv(&t[2]);
  5193. glNormal3fv(&n[4]); glVertex2fv(vtx+28);
  5194. glTexCoord2fv(&t[4]);
  5195. glNormal3fv(&n[8]); glVertex2fv(vtx+36);
  5196. glTexCoord2fv(&t[6]);
  5197. glNormal3fv(&n[12]); glVertex2fv(vtx+32);
  5198. case 3:
  5199. glTexCoord2fv(&t[0]);
  5200. glNormal3fv(&n[0]); glVertex2fv(vtx+16);
  5201. glTexCoord2fv(&t[2]);
  5202. glNormal3fv(&n[4]); glVertex2fv(vtx+20);
  5203. glTexCoord2fv(&t[4]);
  5204. glNormal3fv(&n[8]); glVertex2fv(vtx+28);
  5205. glTexCoord2fv(&t[6]);
  5206. glNormal3fv(&n[12]); glVertex2fv(vtx+24);
  5207. case 2:
  5208. glTexCoord2fv(&t[0]);
  5209. glNormal3fv(&n[0]); glVertex2fv(vtx+8);
  5210. glTexCoord2fv(&t[2]);
  5211. glNormal3fv(&n[4]); glVertex2fv(vtx+12);
  5212. glTexCoord2fv(&t[4]);
  5213. glNormal3fv(&n[8]); glVertex2fv(vtx+20);
  5214. glTexCoord2fv(&t[6]);
  5215. glNormal3fv(&n[12]); glVertex2fv(vtx+16);
  5216. case 1:
  5217. glTexCoord2fv(&t[0]);
  5218. glNormal3fv(&n[0]); glVertex2fv(vtx);
  5219. glTexCoord2fv(&t[2]);
  5220. glNormal3fv(&n[4]); glVertex2fv(vtx+4);
  5221. glTexCoord2fv(&t[4]);
  5222. glNormal3fv(&n[8]); glVertex2fv(vtx+12);
  5223. glTexCoord2fv(&t[6]);
  5224. glNormal3fv(&n[12]); glVertex2fv(vtx+8);
  5225. }
  5226. glEnd();
  5227. }
  5228. secs = timer(1);
  5229. }
  5230. }
  5231. rate = rate * (secspertest/secs);
  5232. rate = cPoly * (rate/cPoly);
  5233. for (k=0; k<loopcount; k++) {
  5234. if (mod_lmcolor) {
  5235. if (starttest(k)) {
  5236. for(i=(rate)/cPoly; i; i--) {
  5237. glBegin(GL_QUADS);
  5238. switch (cPoly) {
  5239. case 5:
  5240. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  5241. glTexCoord2fv(&t[0]); glVertex2fv(vtx+32);
  5242. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  5243. glTexCoord2fv(&t[2]); glVertex2fv(vtx+36);
  5244. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  5245. glTexCoord2fv(&t[4]); glVertex2fv(vtx+44);
  5246. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  5247. glTexCoord2fv(&t[6]); glVertex2fv(vtx+40);
  5248. case 4:
  5249. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  5250. glTexCoord2fv(&t[0]); glVertex2fv(vtx+24);
  5251. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  5252. glTexCoord2fv(&t[2]); glVertex2fv(vtx+28);
  5253. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  5254. glTexCoord2fv(&t[4]); glVertex2fv(vtx+36);
  5255. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  5256. glTexCoord2fv(&t[6]); glVertex2fv(vtx+32);
  5257. case 3:
  5258. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  5259. glTexCoord2fv(&t[0]); glVertex2fv(vtx+16);
  5260. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  5261. glTexCoord2fv(&t[2]); glVertex2fv(vtx+20);
  5262. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  5263. glTexCoord2fv(&t[4]); glVertex2fv(vtx+28);
  5264. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  5265. glTexCoord2fv(&t[6]); glVertex2fv(vtx+24);
  5266. case 2:
  5267. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  5268. glTexCoord2fv(&t[0]); glVertex2fv(vtx+8);
  5269. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  5270. glTexCoord2fv(&t[2]); glVertex2fv(vtx+12);
  5271. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  5272. glTexCoord2fv(&t[4]); glVertex2fv(vtx+20);
  5273. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  5274. glTexCoord2fv(&t[6]); glVertex2fv(vtx+16);
  5275. case 1:
  5276. glColor3fv(&c[4]); glNormal3fv(&n[0]);
  5277. glTexCoord2fv(&t[0]); glVertex2fv(vtx);
  5278. glColor3fv(&c[16]); glNormal3fv(&n[4]);
  5279. glTexCoord2fv(&t[2]); glVertex2fv(vtx+4);
  5280. glColor3fv(&c[8]); glNormal3fv(&n[8]);
  5281. glTexCoord2fv(&t[4]); glVertex2fv(vtx+12);
  5282. glColor3fv(&c[8]); glNormal3fv(&n[12]);
  5283. glTexCoord2fv(&t[6]); glVertex2fv(vtx+8);
  5284. }
  5285. glEnd();
  5286. }
  5287. }
  5288. endtest(pbuf, rate, 0);
  5289. }
  5290. else {
  5291. if (starttest(k)) {
  5292. for(i=(rate)/cPoly; i; i--) {
  5293. glBegin(GL_QUADS);
  5294. switch (cPoly) {
  5295. case 5:
  5296. glTexCoord2fv(&t[0]);
  5297. glNormal3fv(&n[0]); glVertex2fv(vtx+32);
  5298. glTexCoord2fv(&t[2]);
  5299. glNormal3fv(&n[4]); glVertex2fv(vtx+36);
  5300. glTexCoord2fv(&t[4]);
  5301. glNormal3fv(&n[8]); glVertex2fv(vtx+44);
  5302. glTexCoord2fv(&t[6]);
  5303. glNormal3fv(&n[12]); glVertex2fv(vtx+40);
  5304. case 4:
  5305. glTexCoord2fv(&t[0]);
  5306. glNormal3fv(&n[0]); glVertex2fv(vtx+24);
  5307. glTexCoord2fv(&t[2]);
  5308. glNormal3fv(&n[4]); glVertex2fv(vtx+28);
  5309. glTexCoord2fv(&t[4]);
  5310. glNormal3fv(&n[8]); glVertex2fv(vtx+36);
  5311. glTexCoord2fv(&t[6]);
  5312. glNormal3fv(&n[12]); glVertex2fv(vtx+32);
  5313. case 3:
  5314. glTexCoord2fv(&t[0]);
  5315. glNormal3fv(&n[0]); glVertex2fv(vtx+16);
  5316. glTexCoord2fv(&t[2]);
  5317. glNormal3fv(&n[4]); glVertex2fv(vtx+20);
  5318. glTexCoord2fv(&t[4]);
  5319. glNormal3fv(&n[8]); glVertex2fv(vtx+28);
  5320. glTexCoord2fv(&t[6]);
  5321. glNormal3fv(&n[12]); glVertex2fv(vtx+24);
  5322. case 2:
  5323. glTexCoord2fv(&t[0]);
  5324. glNormal3fv(&n[0]); glVertex2fv(vtx+8);
  5325. glTexCoord2fv(&t[2]);
  5326. glNormal3fv(&n[4]); glVertex2fv(vtx+12);
  5327. glTexCoord2fv(&t[4]);
  5328. glNormal3fv(&n[8]); glVertex2fv(vtx+20);
  5329. glTexCoord2fv(&t[6]);
  5330. glNormal3fv(&n[12]); glVertex2fv(vtx+16);
  5331. case 1:
  5332. glTexCoord2fv(&t[0]);
  5333. glNormal3fv(&n[0]); glVertex2fv(vtx);
  5334. glTexCoord2fv(&t[2]);
  5335. glNormal3fv(&n[4]); glVertex2fv(vtx+4);
  5336. glTexCoord2fv(&t[4]);
  5337. glNormal3fv(&n[8]); glVertex2fv(vtx+12);
  5338. glTexCoord2fv(&t[6]);
  5339. glNormal3fv(&n[12]); glVertex2fv(vtx+8);
  5340. }
  5341. glEnd();
  5342. }
  5343. }
  5344. endtest(pbuf, rate, 0);
  5345. }
  5346. }
  5347. glPopMatrix();
  5348. }
  5349. printaverage();
  5350. } else if (mod_shade && !mod_cmode) {
  5351. /*** POLYGONS (SHADED RGB) *****/
  5352. sum_secs = 0.0;
  5353. sum_n = 0;
  5354. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  5355. if (!mod_average)
  5356. sprintf(pbuf, "Angle %6.2f", angle);
  5357. glPushMatrix();
  5358. glRotatef(angle-90.0, 0, 0, 1);
  5359. /****** Calibration Loop ******/
  5360. secs = 0.0; rate = 125;
  5361. while (secs < (secspertest/4.0)) {
  5362. rate = rate*2;
  5363. starttest(0);
  5364. for(i=(rate)/cPoly; i; i--) {
  5365. glBegin(GL_QUADS);
  5366. switch (cPoly) {
  5367. case 5:
  5368. glTexCoord2fv(&t[0]);
  5369. glColor3fv(&c[4]); glVertex2fv(vtx+32);
  5370. glTexCoord2fv(&t[2]);
  5371. glColor3fv(&c[16]); glVertex2fv(vtx+36);
  5372. glTexCoord2fv(&t[4]);
  5373. glColor3fv(&c[8]); glVertex2fv(vtx+44);
  5374. glTexCoord2fv(&t[6]);
  5375. glColor3fv(&c[8]); glVertex2fv(vtx+40);
  5376. case 4:
  5377. glTexCoord2fv(&t[0]);
  5378. glColor3fv(&c[4]); glVertex2fv(vtx+24);
  5379. glTexCoord2fv(&t[2]);
  5380. glColor3fv(&c[16]); glVertex2fv(vtx+28);
  5381. glTexCoord2fv(&t[4]);
  5382. glColor3fv(&c[8]); glVertex2fv(vtx+36);
  5383. glTexCoord2fv(&t[6]);
  5384. glColor3fv(&c[8]); glVertex2fv(vtx+32);
  5385. case 3:
  5386. glTexCoord2fv(&t[0]);
  5387. glColor3fv(&c[4]); glVertex2fv(vtx+16);
  5388. glTexCoord2fv(&t[2]);
  5389. glColor3fv(&c[16]); glVertex2fv(vtx+20);
  5390. glTexCoord2fv(&t[4]);
  5391. glColor3fv(&c[8]); glVertex2fv(vtx+28);
  5392. glTexCoord2fv(&t[6]);
  5393. glColor3fv(&c[8]); glVertex2fv(vtx+24);
  5394. case 2:
  5395. glTexCoord2fv(&t[0]);
  5396. glColor3fv(&c[4]); glVertex2fv(vtx+8);
  5397. glTexCoord2fv(&t[2]);
  5398. glColor3fv(&c[16]); glVertex2fv(vtx+12);
  5399. glTexCoord2fv(&t[4]);
  5400. glColor3fv(&c[8]); glVertex2fv(vtx+20);
  5401. glTexCoord2fv(&t[6]);
  5402. glColor3fv(&c[8]); glVertex2fv(vtx+16);
  5403. case 1:
  5404. glTexCoord2fv(&t[0]);
  5405. glColor3fv(&c[4]); glVertex2fv(vtx);
  5406. glTexCoord2fv(&t[2]);
  5407. glColor3fv(&c[16]); glVertex2fv(vtx+4);
  5408. glTexCoord2fv(&t[4]);
  5409. glColor3fv(&c[8]); glVertex2fv(vtx+12);
  5410. glTexCoord2fv(&t[6]);
  5411. glColor3fv(&c[8]); glVertex2fv(vtx+8);
  5412. }
  5413. glEnd();
  5414. }
  5415. secs = timer(1);
  5416. }
  5417. rate = rate * (secspertest/secs);
  5418. rate = cPoly * (rate/cPoly);
  5419. for (k=0; k<loopcount; k++) {
  5420. if (starttest(k)) {
  5421. for(i=(rate)/cPoly; i; i--) {
  5422. glBegin(GL_QUADS);
  5423. switch (cPoly) {
  5424. case 5:
  5425. glTexCoord2fv(&t[0]);
  5426. glColor3fv(&c[4]); glVertex2fv(vtx+32);
  5427. glTexCoord2fv(&t[2]);
  5428. glColor3fv(&c[16]); glVertex2fv(vtx+36);
  5429. glTexCoord2fv(&t[4]);
  5430. glColor3fv(&c[8]); glVertex2fv(vtx+44);
  5431. glTexCoord2fv(&t[6]);
  5432. glColor3fv(&c[8]); glVertex2fv(vtx+40);
  5433. case 4:
  5434. glTexCoord2fv(&t[0]);
  5435. glColor3fv(&c[4]); glVertex2fv(vtx+24);
  5436. glTexCoord2fv(&t[2]);
  5437. glColor3fv(&c[16]); glVertex2fv(vtx+28);
  5438. glTexCoord2fv(&t[4]);
  5439. glColor3fv(&c[8]); glVertex2fv(vtx+36);
  5440. glTexCoord2fv(&t[6]);
  5441. glColor3fv(&c[8]); glVertex2fv(vtx+32);
  5442. case 3:
  5443. glTexCoord2fv(&t[0]);
  5444. glColor3fv(&c[4]); glVertex2fv(vtx+16);
  5445. glTexCoord2fv(&t[2]);
  5446. glColor3fv(&c[16]); glVertex2fv(vtx+20);
  5447. glTexCoord2fv(&t[4]);
  5448. glColor3fv(&c[8]); glVertex2fv(vtx+28);
  5449. glTexCoord2fv(&t[6]);
  5450. glColor3fv(&c[8]); glVertex2fv(vtx+24);
  5451. case 2:
  5452. glTexCoord2fv(&t[0]);
  5453. glColor3fv(&c[4]); glVertex2fv(vtx+8);
  5454. glTexCoord2fv(&t[2]);
  5455. glColor3fv(&c[16]); glVertex2fv(vtx+12);
  5456. glTexCoord2fv(&t[4]);
  5457. glColor3fv(&c[8]); glVertex2fv(vtx+20);
  5458. glTexCoord2fv(&t[6]);
  5459. glColor3fv(&c[8]); glVertex2fv(vtx+16);
  5460. case 1:
  5461. glTexCoord2fv(&t[0]);
  5462. glColor3fv(&c[4]); glVertex2fv(vtx);
  5463. glTexCoord2fv(&t[2]);
  5464. glColor3fv(&c[16]); glVertex2fv(vtx+4);
  5465. glTexCoord2fv(&t[4]);
  5466. glColor3fv(&c[8]); glVertex2fv(vtx+12);
  5467. glTexCoord2fv(&t[6]);
  5468. glColor3fv(&c[8]); glVertex2fv(vtx+8);
  5469. }
  5470. glEnd();
  5471. }
  5472. }
  5473. endtest(pbuf, rate, 0);
  5474. }
  5475. glPopMatrix();
  5476. }
  5477. printaverage();
  5478. } else if (mod_shade && mod_cmode) {
  5479. /*** POLYGONS (SHADED COLOR MAPPED) *****/
  5480. /* 255 = r, 240 = g, 255 = b */
  5481. makeramp(208, 255, 0, 0, 0, 0, 255, 16);
  5482. makeramp(224, 0, 0, 255, 255, 255, 0, 16);
  5483. makeramp(240, 255, 255, 0, 255, 0, 255, 16);
  5484. sum_secs = 0.0;
  5485. sum_n = 0;
  5486. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  5487. if (!mod_average)
  5488. sprintf(pbuf, "Angle %6.2f", angle);
  5489. glPushMatrix();
  5490. glRotatef(angle-90.0, 0, 0, 1);
  5491. /****** Calibration Loop ******/
  5492. secs = 0.0; rate = 125;
  5493. while (secs < (secspertest/4.0)) {
  5494. rate = rate*2;
  5495. starttest(0);
  5496. for(i=(rate)/cPoly; i; i--) {
  5497. glBegin(GL_QUADS);
  5498. switch (cPoly) {
  5499. case 5:
  5500. glTexCoord2fv(&t[0]);
  5501. glIndexi(255); glVertex2fv(vtx+32);
  5502. glTexCoord2fv(&t[2]);
  5503. glIndexi(240); glVertex2fv(vtx+36);
  5504. glTexCoord2fv(&t[4]);
  5505. glIndexi(223); glVertex2fv(vtx+44);
  5506. glTexCoord2fv(&t[6]);
  5507. glIndexi(208); glVertex2fv(vtx+40);
  5508. case 4:
  5509. glTexCoord2fv(&t[0]);
  5510. glIndexi(255); glVertex2fv(vtx+24);
  5511. glTexCoord2fv(&t[2]);
  5512. glIndexi(240); glVertex2fv(vtx+28);
  5513. glTexCoord2fv(&t[4]);
  5514. glIndexi(223); glVertex2fv(vtx+36);
  5515. glTexCoord2fv(&t[6]);
  5516. glIndexi(208); glVertex2fv(vtx+32);
  5517. case 3:
  5518. glTexCoord2fv(&t[0]);
  5519. glIndexi(255); glVertex2fv(vtx+16);
  5520. glTexCoord2fv(&t[2]);
  5521. glIndexi(240); glVertex2fv(vtx+20);
  5522. glTexCoord2fv(&t[4]);
  5523. glIndexi(223); glVertex2fv(vtx+28);
  5524. glTexCoord2fv(&t[6]);
  5525. glIndexi(208); glVertex2fv(vtx+24);
  5526. case 2:
  5527. glTexCoord2fv(&t[0]);
  5528. glIndexi(255); glVertex2fv(vtx+8);
  5529. glTexCoord2fv(&t[2]);
  5530. glIndexi(240); glVertex2fv(vtx+12);
  5531. glTexCoord2fv(&t[4]);
  5532. glIndexi(223); glVertex2fv(vtx+20);
  5533. glTexCoord2fv(&t[6]);
  5534. glIndexi(208); glVertex2fv(vtx+16);
  5535. case 1:
  5536. glTexCoord2fv(&t[0]);
  5537. glIndexi(255); glVertex2fv(vtx);
  5538. glTexCoord2fv(&t[2]);
  5539. glIndexi(240); glVertex2fv(vtx+4);
  5540. glTexCoord2fv(&t[4]);
  5541. glIndexi(223); glVertex2fv(vtx+12);
  5542. glTexCoord2fv(&t[6]);
  5543. glIndexi(208); glVertex2fv(vtx+8);
  5544. }
  5545. glEnd();
  5546. }
  5547. secs = timer(1);
  5548. }
  5549. rate = rate * (secspertest/secs);
  5550. rate = cPoly * (rate/cPoly);
  5551. for (k=0; k<loopcount; k++) {
  5552. if (starttest(k)) {
  5553. for(i=(rate)/cPoly; i; i--) {
  5554. glBegin(GL_QUADS);
  5555. switch (cPoly) {
  5556. case 5:
  5557. glTexCoord2fv(&t[0]);
  5558. glIndexi(255); glVertex2fv(vtx+32);
  5559. glTexCoord2fv(&t[2]);
  5560. glIndexi(240); glVertex2fv(vtx+36);
  5561. glTexCoord2fv(&t[4]);
  5562. glIndexi(223); glVertex2fv(vtx+44);
  5563. glTexCoord2fv(&t[6]);
  5564. glIndexi(208); glVertex2fv(vtx+40);
  5565. case 4:
  5566. glTexCoord2fv(&t[0]);
  5567. glIndexi(255); glVertex2fv(vtx+24);
  5568. glTexCoord2fv(&t[2]);
  5569. glIndexi(240); glVertex2fv(vtx+28);
  5570. glTexCoord2fv(&t[4]);
  5571. glIndexi(223); glVertex2fv(vtx+36);
  5572. glTexCoord2fv(&t[6]);
  5573. glIndexi(208); glVertex2fv(vtx+32);
  5574. case 3:
  5575. glTexCoord2fv(&t[0]);
  5576. glIndexi(255); glVertex2fv(vtx+16);
  5577. glTexCoord2fv(&t[2]);
  5578. glIndexi(240); glVertex2fv(vtx+20);
  5579. glTexCoord2fv(&t[4]);
  5580. glIndexi(223); glVertex2fv(vtx+28);
  5581. glTexCoord2fv(&t[6]);
  5582. glIndexi(208); glVertex2fv(vtx+24);
  5583. case 2:
  5584. glTexCoord2fv(&t[0]);
  5585. glIndexi(255); glVertex2fv(vtx+8);
  5586. glTexCoord2fv(&t[2]);
  5587. glIndexi(240); glVertex2fv(vtx+12);
  5588. glTexCoord2fv(&t[4]);
  5589. glIndexi(223); glVertex2fv(vtx+20);
  5590. glTexCoord2fv(&t[6]);
  5591. glIndexi(208); glVertex2fv(vtx+16);
  5592. case 1:
  5593. glTexCoord2fv(&t[0]);
  5594. glIndexi(255); glVertex2fv(vtx);
  5595. glTexCoord2fv(&t[2]);
  5596. glIndexi(240); glVertex2fv(vtx+4);
  5597. glTexCoord2fv(&t[4]);
  5598. glIndexi(223); glVertex2fv(vtx+12);
  5599. glTexCoord2fv(&t[6]);
  5600. glIndexi(208); glVertex2fv(vtx+8);
  5601. }
  5602. glEnd();
  5603. }
  5604. }
  5605. endtest(pbuf, rate, 0);
  5606. }
  5607. glPopMatrix();
  5608. }
  5609. printaverage();
  5610. } else if (!mod_light && !mod_shade) {
  5611. /*** POLYGONS (FLAT SHADED) *****/
  5612. sum_secs = 0.0;
  5613. sum_n = 0;
  5614. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  5615. if (!mod_average)
  5616. sprintf(pbuf, "Angle %6.2f", angle);
  5617. glPushMatrix();
  5618. glRotatef(angle-90.0, 0, 0, 1);
  5619. /****** Calibration Loop ******/
  5620. secs = 0.0; rate = 125;
  5621. while (secs < (secspertest/4.0)) {
  5622. rate = rate*2;
  5623. starttest(0);
  5624. for(i=(rate)/cPoly; i; i--) {
  5625. glBegin(GL_QUADS);
  5626. switch (cPoly) {
  5627. case 5:
  5628. glTexCoord2fv(&t[0]); glVertex2fv(vtx+32);
  5629. glTexCoord2fv(&t[2]); glVertex2fv(vtx+36);
  5630. glTexCoord2fv(&t[4]); glVertex2fv(vtx+44);
  5631. glTexCoord2fv(&t[6]); glVertex2fv(vtx+40);
  5632. case 4:
  5633. glTexCoord2fv(&t[0]); glVertex2fv(vtx+24);
  5634. glTexCoord2fv(&t[2]); glVertex2fv(vtx+28);
  5635. glTexCoord2fv(&t[4]); glVertex2fv(vtx+36);
  5636. glTexCoord2fv(&t[6]); glVertex2fv(vtx+32);
  5637. case 3:
  5638. glTexCoord2fv(&t[0]); glVertex2fv(vtx+16);
  5639. glTexCoord2fv(&t[2]); glVertex2fv(vtx+20);
  5640. glTexCoord2fv(&t[4]); glVertex2fv(vtx+28);
  5641. glTexCoord2fv(&t[6]); glVertex2fv(vtx+24);
  5642. case 2:
  5643. glTexCoord2fv(&t[0]); glVertex2fv(vtx+8);
  5644. glTexCoord2fv(&t[2]); glVertex2fv(vtx+12);
  5645. glTexCoord2fv(&t[4]); glVertex2fv(vtx+20);
  5646. glTexCoord2fv(&t[6]); glVertex2fv(vtx+16);
  5647. case 1:
  5648. glTexCoord2fv(&t[0]); glVertex2fv(vtx);
  5649. glTexCoord2fv(&t[2]); glVertex2fv(vtx+4);
  5650. glTexCoord2fv(&t[4]); glVertex2fv(vtx+12);
  5651. glTexCoord2fv(&t[6]); glVertex2fv(vtx+8);
  5652. }
  5653. glEnd();
  5654. }
  5655. secs = timer(1);
  5656. }
  5657. rate = rate * (secspertest/secs);
  5658. rate = cPoly * (rate/cPoly);
  5659. for (k=0; k<loopcount; k++) {
  5660. if (starttest(k)) {
  5661. for(i=(rate)/cPoly; i; i--) {
  5662. glBegin(GL_QUADS);
  5663. switch (cPoly) {
  5664. case 5:
  5665. glTexCoord2fv(&t[0]); glVertex2fv(vtx+32);
  5666. glTexCoord2fv(&t[2]); glVertex2fv(vtx+36);
  5667. glTexCoord2fv(&t[4]); glVertex2fv(vtx+44);
  5668. glTexCoord2fv(&t[6]); glVertex2fv(vtx+40);
  5669. case 4:
  5670. glTexCoord2fv(&t[0]); glVertex2fv(vtx+24);
  5671. glTexCoord2fv(&t[2]); glVertex2fv(vtx+28);
  5672. glTexCoord2fv(&t[4]); glVertex2fv(vtx+36);
  5673. glTexCoord2fv(&t[6]); glVertex2fv(vtx+32);
  5674. case 3:
  5675. glTexCoord2fv(&t[0]); glVertex2fv(vtx+16);
  5676. glTexCoord2fv(&t[2]); glVertex2fv(vtx+20);
  5677. glTexCoord2fv(&t[4]); glVertex2fv(vtx+28);
  5678. glTexCoord2fv(&t[6]); glVertex2fv(vtx+24);
  5679. case 2:
  5680. glTexCoord2fv(&t[0]); glVertex2fv(vtx+8);
  5681. glTexCoord2fv(&t[2]); glVertex2fv(vtx+12);
  5682. glTexCoord2fv(&t[4]); glVertex2fv(vtx+20);
  5683. glTexCoord2fv(&t[6]); glVertex2fv(vtx+16);
  5684. case 1:
  5685. glTexCoord2fv(&t[0]); glVertex2fv(vtx);
  5686. glTexCoord2fv(&t[2]); glVertex2fv(vtx+4);
  5687. glTexCoord2fv(&t[4]); glVertex2fv(vtx+12);
  5688. glTexCoord2fv(&t[6]); glVertex2fv(vtx+8);
  5689. }
  5690. glEnd();
  5691. }
  5692. }
  5693. endtest(pbuf, rate, 0);
  5694. }
  5695. glPopMatrix();
  5696. }
  5697. printaverage();
  5698. }
  5699. }
  5700. if (mod_doublebuffer) {
  5701. auxSwapBuffers();
  5702. Sleep(2000); /* for visual feedback */
  5703. }
  5704. exit(0);
  5705. }
  5706. static void perftmeshtex(void)
  5707. {
  5708. int i,j,k, tin;
  5709. float *vtx = &v[0];
  5710. char pbuf[256];
  5711. int cVert = 60;
  5712. if (mod_texfile) MyLoadImage();
  5713. else CreateImage();
  5714. InitTexParams();
  5715. /* Triangle mesh tests: Each tmesh contains 62 vertices, or */
  5716. /* 60 triangles. To make the calculation exact, the rate */
  5717. /* must be a multiple of 60. */
  5718. if (mod_backface){
  5719. glEnable(GL_CULL_FACE);
  5720. glCullFace(GL_FRONT);
  5721. }
  5722. if (mod_bigger) {
  5723. vtx = &mv[0];
  5724. printf("bigger in tmesh\n");
  5725. }
  5726. /* If the triangle size is specified, set the size of the triangle mesh to
  5727. ** fit the window. The number of vertices must be a multiple of four (due
  5728. ** to code below), and it must not exceed 60.
  5729. */
  5730. if (mod_size) {
  5731. cVert = (int) (MINDIMENSION*2 / prim_size) - 2;
  5732. if (cVert & 1) cVert++;
  5733. cVert &= ~3;
  5734. if (cVert < 4) cVert = 4;
  5735. if (cVert > 60) cVert = 60;
  5736. }
  5737. for(i=0; i<NVERT; i++) {
  5738. vtx[i*4+1] -= ((cVert+2)/4.0 * prim_size);
  5739. }
  5740. if (!mod_2d) {
  5741. if (mod_cmode && mod_shade) {
  5742. /*** GOURAUD SHADED CMODE TMESH ***/
  5743. /* 255 = r, 240 = g, 255 = b */
  5744. makeramp(208,255,0,0,0,0,255,16);
  5745. makeramp(224,0,0,255,255,255,0,16);
  5746. makeramp(240,255,255,0,255,0,255,16);
  5747. sum_secs = 0.0;
  5748. sum_n = 0;
  5749. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  5750. if (!mod_average)
  5751. sprintf(pbuf, "Angle %6.2f", angle);
  5752. glPushMatrix();
  5753. glRotatef(angle-90.0, 0, 0, 1);
  5754. /****** Calibration Loop ******/
  5755. secs = 0.0; rate = 125;
  5756. while (secs < (secspertest/4.0)) {
  5757. rate = rate*2;
  5758. starttest(0);
  5759. for(i=(rate)/cVert; i; i--) {
  5760. glBegin(GL_TRIANGLE_STRIP);
  5761. for (j=0, tin=-2; j<cVert; j+=4, tin=-2) {
  5762. glIndexi(255); glTexCoord2fv (&t[tin+=2]);
  5763. glVertex3fv(&vtx[j*4]);
  5764. glIndexi(240); glTexCoord2fv (&t[tin+=2]);
  5765. glVertex3fv(&vtx[(j+1)*4]);
  5766. glIndexi(223); glTexCoord2fv (&t[tin+=2]);
  5767. glVertex3fv(&vtx[(j+2)*4]);
  5768. glIndexi(208); glTexCoord2fv (&t[tin+=2]);
  5769. glVertex3fv(&vtx[(j+3)*4]);
  5770. }
  5771. glIndexi(255); glTexCoord2fv (&t[tin+=2]);
  5772. glVertex3fv(&vtx[j*4]);
  5773. glIndexi(240); glTexCoord2fv (&t[tin+=2]);
  5774. glVertex3fv(&vtx[(j+1)*4]);
  5775. glEnd();
  5776. }
  5777. secs = timer(1);
  5778. }
  5779. rate = rate * (secspertest/secs);
  5780. rate = cVert * (rate/cVert);
  5781. /* Do the real thing GOURAUD shaded Cmode tmesh */
  5782. for (k=0; k<loopcount; k++) {
  5783. if (starttest(k)) {
  5784. for(i=(rate)/cVert; i; i--) {
  5785. glBegin(GL_TRIANGLE_STRIP);
  5786. for (j=0, tin=-2; j<cVert; j+=4, tin=-2) {
  5787. glIndexi(255); glTexCoord2fv (&t[tin+=2]);
  5788. glVertex3fv(&vtx[j*4]);
  5789. glIndexi(240); glTexCoord2fv (&t[tin+=2]);
  5790. glVertex3fv(&vtx[(j+1)*4]);
  5791. glIndexi(223); glTexCoord2fv (&t[tin+=2]);
  5792. glVertex3fv(&vtx[(j+2)*4]);
  5793. glIndexi(208); glTexCoord2fv (&t[tin+=2]);
  5794. glVertex3fv(&vtx[(j+3)*4]);
  5795. }
  5796. glIndexi(255); glTexCoord2fv (&t[tin+=2]);
  5797. glVertex3fv(&vtx[j*4]);
  5798. glIndexi(240); glTexCoord2fv (&t[tin+=2]);
  5799. glVertex3fv(&vtx[(j+1)*4]);
  5800. glEnd();
  5801. }
  5802. }
  5803. endtest(pbuf, rate, 0);
  5804. }
  5805. glPopMatrix();
  5806. }
  5807. printaverage();
  5808. } else if (!mod_light && !mod_shade) {
  5809. /*** FLAT SHADED TMESH ***/
  5810. sum_secs = 0.0;
  5811. sum_n = 0;
  5812. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  5813. if (!mod_average)
  5814. sprintf(pbuf, "Angle %6.2f", angle);
  5815. glPushMatrix();
  5816. glRotatef(angle-90.0, 0, 0, 1);
  5817. /****** Calibration Loop ******/
  5818. secs = 0.0; rate = 125;
  5819. while (secs < (secspertest/4.0)) {
  5820. rate = rate*2;
  5821. starttest(0);
  5822. for(i=(rate)/cVert; i; i--) {
  5823. glBegin(GL_TRIANGLE_STRIP);
  5824. for (j=0, tin=0; j<cVert+2; j++, tin= (tin+2)%8) {
  5825. glTexCoord2fv(&t[tin]);
  5826. glVertex3fv(&vtx[j*4]);
  5827. }
  5828. glEnd();
  5829. }
  5830. secs = timer(1);
  5831. }
  5832. rate = rate * (secspertest/secs);
  5833. rate = cVert * (rate/cVert);
  5834. /* Do the real thing - FLAT shaded tmesh */
  5835. for (k=0; k<loopcount; k++) {
  5836. if (starttest(k)) {
  5837. for(i=(rate)/cVert; i; i--) {
  5838. glBegin(GL_TRIANGLE_STRIP);
  5839. for (j=0, tin=0; j<cVert+2; j++, tin=(tin+2)%8) {
  5840. glTexCoord2fv(&t[tin]);
  5841. glVertex3fv(&vtx[j*4]);
  5842. }
  5843. glEnd();
  5844. }
  5845. }
  5846. endtest(pbuf, rate, 0);
  5847. }
  5848. glPopMatrix();
  5849. }
  5850. printaverage();
  5851. } else if (!mod_cmode && mod_light) {
  5852. /*** LIGHTED RGB MESH ***/
  5853. glLoadIdentity();
  5854. glMatrixMode(GL_PROJECTION);
  5855. glLoadIdentity();
  5856. glOrtho(-0.5*xsize,0.5*xsize,-0.5*ysize,0.5*ysize,1.0,-1.0);
  5857. glMatrixMode(GL_MODELVIEW);
  5858. /* set lights */
  5859. setLightingParameters();
  5860. sum_secs = 0.0;
  5861. sum_n = 0;
  5862. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  5863. if (!mod_average)
  5864. sprintf (pbuf, "Angle %6.2f", angle);
  5865. glPushMatrix();
  5866. glRotatef(angle-90.0, 0, 0, 1);
  5867. /****** Calibration Loop ******/
  5868. secs = 0.0; rate = 125;
  5869. while (secs < (secspertest/4.0)) {
  5870. rate = rate*2;
  5871. if (mod_lmcolor) {
  5872. starttest(0);
  5873. for(i=(rate)/cVert; i; i--) {
  5874. glBegin(GL_TRIANGLE_STRIP);
  5875. for (j=0, tin=-2; j<cVert; j+=4, tin=-2) {
  5876. glColor3fv(&c[16]);
  5877. glTexCoord2fv(&t[tin+=2]);
  5878. glNormal3fv(&n[0]);
  5879. glVertex3fv(&vtx[j*4]);
  5880. glColor3fv(&c[20]);
  5881. glTexCoord2fv(&t[tin+=2]);
  5882. glNormal3fv(&n[4]);
  5883. glVertex3fv(&vtx[(j+1)*4]);
  5884. glColor3fv(&c[4]);
  5885. glTexCoord2fv(&t[tin+=2]);
  5886. glNormal3fv(&n[8]);
  5887. glVertex3fv(&vtx[(j+2)*4]);
  5888. glColor3fv(&c[8]);
  5889. glTexCoord2fv(&t[tin+=2]);
  5890. glNormal3fv(&n[12]);
  5891. glVertex3fv(&vtx[(j+3)*4]);
  5892. }
  5893. glColor3fv(&c[16]);
  5894. glTexCoord2fv(&t[tin+=2]);
  5895. glNormal3fv(&n[0]);
  5896. glVertex3fv(&vtx[j*4]);
  5897. glColor3fv(&c[20]);
  5898. glTexCoord2fv(&t[tin+=2]);
  5899. glNormal3fv(&n[4]);
  5900. glVertex3fv(&vtx[(j+1)*4]);
  5901. glEnd();
  5902. }
  5903. secs = timer(1);
  5904. }
  5905. else {
  5906. starttest(0);
  5907. for(i=(rate)/cVert; i; i--) {
  5908. glBegin(GL_TRIANGLE_STRIP);
  5909. for (j=0, tin=-2; j<cVert; j+=4, tin=-2) {
  5910. glNormal3fv(&n[0]);
  5911. glTexCoord2fv(&t[tin+=2]);
  5912. glVertex3fv(&vtx[j*4]);
  5913. glNormal3fv(&n[4]);
  5914. glTexCoord2fv(&t[tin+=2]);
  5915. glVertex3fv(&vtx[(j+1)*4]);
  5916. glNormal3fv(&n[8]);
  5917. glTexCoord2fv(&t[tin+=2]);
  5918. glVertex3fv(&vtx[(j+2)*4]);
  5919. glNormal3fv(&n[12]);
  5920. glTexCoord2fv(&t[tin+=2]);
  5921. glVertex3fv(&vtx[(j+3)*4]);
  5922. }
  5923. glNormal3fv(&n[0]);
  5924. glTexCoord2fv(&t[tin+=2]);
  5925. glVertex3fv(&vtx[j*4]);
  5926. glNormal3fv(&n[4]);
  5927. glTexCoord2fv(&t[tin+=2]);
  5928. glVertex3fv(&vtx[(j+1)*4]);
  5929. glEnd();
  5930. }
  5931. secs = timer(1);
  5932. }
  5933. }
  5934. rate = rate * (secspertest/secs);
  5935. rate = cVert * (rate/cVert);
  5936. for (k=0; k<loopcount; k++) {
  5937. if (mod_lmcolor) {
  5938. if (starttest(k)) {
  5939. for(i=(rate)/cVert; i; i--) {
  5940. glBegin(GL_TRIANGLE_STRIP);
  5941. for (j=0, tin=-2; j<cVert; j+=4, tin=-2) {
  5942. glColor3fv(&c[16]);
  5943. glTexCoord2fv(&t[tin+=2]);
  5944. glNormal3fv(&n[0]);
  5945. glVertex3fv(&vtx[j*4]);
  5946. glColor3fv(&c[20]);
  5947. glTexCoord2fv(&t[tin+=2]);
  5948. glNormal3fv(&n[4]);
  5949. glVertex3fv(&vtx[(j+1)*4]);
  5950. glColor3fv(&c[4]);
  5951. glTexCoord2fv(&t[tin+=2]);
  5952. glNormal3fv(&n[8]);
  5953. glVertex3fv(&vtx[(j+2)*4]);
  5954. glColor3fv(&c[8]);
  5955. glTexCoord2fv(&t[tin+=2]);
  5956. glNormal3fv(&n[12]);
  5957. glVertex3fv(&vtx[(j+3)*4]);
  5958. }
  5959. glColor3fv(&c[16]);
  5960. glTexCoord2fv(&t[tin+=2]);
  5961. glNormal3fv(&n[0]);
  5962. glVertex3fv(&vtx[j*4]);
  5963. glColor3fv(&c[20]);
  5964. glTexCoord2fv(&t[tin+=2]);
  5965. glNormal3fv(&n[4]);
  5966. glVertex3fv(&vtx[(j+1)*4]);
  5967. glEnd();
  5968. }
  5969. }
  5970. endtest(pbuf, rate, 0);
  5971. }
  5972. else {
  5973. if (starttest(k)) {
  5974. for(i=(rate)/cVert; i; i--) {
  5975. glBegin(GL_TRIANGLE_STRIP);
  5976. for (j=0, tin=-2; j<cVert; j+=4, tin=-2) {
  5977. glTexCoord2fv(&t[tin+=2]);
  5978. glNormal3fv(&n[0]);
  5979. glVertex3fv(&vtx[j*4]);
  5980. glTexCoord2fv(&t[tin+=2]);
  5981. glNormal3fv(&n[4]);
  5982. glVertex3fv(&vtx[(j+1)*4]);
  5983. glTexCoord2fv(&t[tin+=2]);
  5984. glNormal3fv(&n[8]);
  5985. glVertex3fv(&vtx[(j+2)*4]);
  5986. glTexCoord2fv(&t[tin+=2]);
  5987. glNormal3fv(&n[12]);
  5988. glVertex3fv(&vtx[(j+3)*4]);
  5989. }
  5990. glTexCoord2fv(&t[tin+=2]);
  5991. glNormal3fv(&n[0]);
  5992. glVertex3fv(&vtx[j*4]);
  5993. glTexCoord2fv(&t[tin+=2]);
  5994. glNormal3fv(&n[4]);
  5995. glVertex3fv(&vtx[(j+1)*4]);
  5996. glEnd();
  5997. }
  5998. }
  5999. endtest(pbuf, rate, 0);
  6000. }
  6001. }
  6002. glPopMatrix();
  6003. }
  6004. printaverage();
  6005. } else if (!mod_cmode && mod_shade) {
  6006. /*** GOURAUD SHADED RGB TMESH ***/
  6007. sum_secs = 0.0;
  6008. sum_n = 0;
  6009. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  6010. if (!mod_average)
  6011. sprintf(pbuf, "Angle %6.2f", angle);
  6012. glPushMatrix();
  6013. glRotatef(angle-90.0, 0, 0, 1);
  6014. /****** Calibration Loop ******/
  6015. secs = 0.0; rate = 125;
  6016. while (secs < (secspertest/4.0)) {
  6017. rate = rate*2;
  6018. starttest(0);
  6019. for(i=(rate)/cVert; i; i--) {
  6020. glBegin(GL_TRIANGLE_STRIP);
  6021. for (j=0, tin=-2; j<cVert; j+=4, tin=-2) {
  6022. glColor3fv(&c[4]);
  6023. glTexCoord2fv(&t[tin+=2]);
  6024. glVertex3fv(&vtx[j*4]);
  6025. glColor3fv(&c[8]);
  6026. glTexCoord2fv(&t[tin+=2]);
  6027. glVertex3fv(&vtx[(j+1)*4]);
  6028. glColor3fv(&c[12]);
  6029. glTexCoord2fv(&t[tin+=2]);
  6030. glVertex3fv(&vtx[(j+2)*4]);
  6031. glColor3fv(&c[16]);
  6032. glTexCoord2fv(&t[tin+=2]);
  6033. glVertex3fv(&vtx[(j+3)*4]);
  6034. }
  6035. glColor3fv(&c[4]);
  6036. glTexCoord2fv(&t[tin+=2]);
  6037. glVertex3fv(&vtx[j*4]);
  6038. glColor3fv(&c[8]);
  6039. glTexCoord2fv(&t[tin+=2]);
  6040. glVertex3fv(&vtx[(j+1)*4]);
  6041. glEnd();
  6042. }
  6043. secs = timer(1);
  6044. }
  6045. rate = rate * (secspertest/secs);
  6046. rate = cVert * (rate/cVert);
  6047. /* Do the real thing GOURAUD shaded tmesh */
  6048. for (k=0; k<loopcount; k++) {
  6049. if (starttest(k)) {
  6050. for(i=(rate)/cVert; i; i--) {
  6051. glBegin(GL_TRIANGLE_STRIP);
  6052. for (j=0, tin=-2; j<cVert; j+=4, tin=-2) {
  6053. glColor3fv(&c[4]);
  6054. glTexCoord2fv(&t[tin+=2]);
  6055. glVertex3fv(&vtx[j*4]);
  6056. glColor3fv(&c[8]);
  6057. glTexCoord2fv(&t[tin+=2]);
  6058. glVertex3fv(&vtx[(j+1)*4]);
  6059. glColor3fv(&c[12]);
  6060. glTexCoord2fv(&t[tin+=2]);
  6061. glVertex3fv(&vtx[(j+2)*4]);
  6062. glColor3fv(&c[16]);
  6063. glTexCoord2fv(&t[tin+=2]);
  6064. glVertex3fv(&vtx[(j+3)*4]);
  6065. }
  6066. glColor3fv(&c[4]);
  6067. glTexCoord2fv(&t[tin+=2]);
  6068. glVertex3fv(&vtx[j*4]);
  6069. glColor3fv(&c[8]);
  6070. glTexCoord2fv(&t[tin+=2]);
  6071. glVertex3fv(&vtx[(j+1)*4]);
  6072. glEnd();
  6073. }
  6074. }
  6075. endtest(pbuf, rate, 0);
  6076. }
  6077. glPopMatrix();
  6078. }
  6079. printaverage();
  6080. }
  6081. } else { /* must be 2d */
  6082. if (mod_cmode && mod_shade) {
  6083. /*** GOURAUD SHADED CMODE TMESH ***/
  6084. /* 255 = r, 240 = g, 255 = b */
  6085. makeramp(208,255,0,0,0,0,255,16);
  6086. makeramp(224,0,0,255,255,255,0,16);
  6087. makeramp(240,255,255,0,255,0,255,16);
  6088. sum_secs = 0.0;
  6089. sum_n = 0;
  6090. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  6091. if (!mod_average)
  6092. sprintf(pbuf, "Angle %6.2f", angle);
  6093. glPushMatrix();
  6094. glRotatef(angle-90.0, 0, 0, 1);
  6095. /****** Calibration Loop ******/
  6096. secs = 0.0; rate = 125;
  6097. while (secs < (secspertest/4.0)) {
  6098. rate = rate*2;
  6099. starttest(0);
  6100. for(i=(rate)/cVert; i; i--) {
  6101. glBegin(GL_TRIANGLE_STRIP);
  6102. for (j=0, tin=-2; j<cVert; j+=4, tin=-2) {
  6103. glIndexi(255); glTexCoord2fv (&t[tin+=2]);
  6104. glVertex2fv(&vtx[j*4]);
  6105. glIndexi(240); glTexCoord2fv (&t[tin+=2]);
  6106. glVertex2fv(&vtx[(j+1)*4]);
  6107. glIndexi(223); glTexCoord2fv (&t[tin+=2]);
  6108. glVertex2fv(&vtx[(j+2)*4]);
  6109. glIndexi(208); glTexCoord2fv (&t[tin+=2]);
  6110. glVertex2fv(&vtx[(j+3)*4]);
  6111. }
  6112. glIndexi(255); glTexCoord2fv (&t[tin+=2]);
  6113. glVertex2fv(&vtx[j*4]);
  6114. glIndexi(240); glTexCoord2fv (&t[tin+=2]);
  6115. glVertex2fv(&vtx[(j+1)*4]);
  6116. glEnd();
  6117. }
  6118. secs = timer(1);
  6119. }
  6120. rate = rate * (secspertest/secs);
  6121. rate = cVert * (rate/cVert);
  6122. /* Do the real thing GOURAUD shaded Cmode tmesh */
  6123. for (k=0; k<loopcount; k++) {
  6124. if (starttest(k)) {
  6125. for(i=(rate)/cVert; i; i--) {
  6126. glBegin(GL_TRIANGLE_STRIP);
  6127. for (j=0, tin=-2; j<cVert; j+=4, tin=-2) {
  6128. glIndexi(255); glTexCoord2fv (&t[tin+=2]);
  6129. glVertex2fv(&vtx[j*4]);
  6130. glIndexi(240); glTexCoord2fv (&t[tin+=2]);
  6131. glVertex2fv(&vtx[(j+1)*4]);
  6132. glIndexi(223); glTexCoord2fv (&t[tin+=2]);
  6133. glVertex2fv(&vtx[(j+2)*4]);
  6134. glIndexi(208); glTexCoord2fv (&t[tin+=2]);
  6135. glVertex2fv(&vtx[(j+3)*4]);
  6136. }
  6137. glIndexi(255); glTexCoord2fv (&t[tin+=2]);
  6138. glVertex2fv(&vtx[j*4]);
  6139. glIndexi(240); glTexCoord2fv (&t[tin+=2]);
  6140. glVertex2fv(&vtx[(j+1)*4]);
  6141. glEnd();
  6142. }
  6143. }
  6144. endtest(pbuf, rate, 0);
  6145. }
  6146. glPopMatrix();
  6147. }
  6148. printaverage();
  6149. } else if (!mod_light && !mod_shade) {
  6150. /*** FLAT SHADED TMESH ***/
  6151. sum_secs = 0.0;
  6152. sum_n = 0;
  6153. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  6154. if (!mod_average)
  6155. sprintf(pbuf, "Angle %6.2f", angle);
  6156. glPushMatrix();
  6157. glRotatef(angle-90.0, 0, 0, 1);
  6158. /****** Calibration Loop ******/
  6159. secs = 0.0; rate = 125;
  6160. while (secs < (secspertest/4.0)) {
  6161. rate = rate*2;
  6162. starttest(0);
  6163. for(i=(rate)/cVert; i; i--) {
  6164. glBegin(GL_TRIANGLE_STRIP);
  6165. for (j=0, tin=0; j<cVert+2; j++, tin= (tin+2)%8) {
  6166. glTexCoord2fv(&t[tin]);
  6167. glVertex2fv(&vtx[j*4]);
  6168. }
  6169. glEnd();
  6170. }
  6171. secs = timer(1);
  6172. }
  6173. rate = rate * (secspertest/secs);
  6174. rate = cVert * (rate/cVert);
  6175. /* Do the real thing - FLAT shaded tmesh */
  6176. for (k=0; k<loopcount; k++) {
  6177. if (starttest(k)) {
  6178. for(i=(rate)/cVert; i; i--) {
  6179. glBegin(GL_TRIANGLE_STRIP);
  6180. for (j=0, tin=0; j<cVert+2; j++, tin=(tin+2)%8) {
  6181. glTexCoord2fv(&t[tin]);
  6182. glVertex2fv(&vtx[j*4]);
  6183. }
  6184. glEnd();
  6185. }
  6186. }
  6187. endtest(pbuf, rate, 0);
  6188. }
  6189. glPopMatrix();
  6190. }
  6191. printaverage();
  6192. } else if (!mod_cmode && mod_light) {
  6193. /*** LIGHTED RGB MESH ***/
  6194. glLoadIdentity();
  6195. glMatrixMode(GL_PROJECTION);
  6196. glLoadIdentity();
  6197. glOrtho(-0.5*xsize,0.5*xsize,-0.5*ysize,0.5*ysize,1.0,-1.0);
  6198. glMatrixMode(GL_MODELVIEW);
  6199. /* set lights */
  6200. setLightingParameters();
  6201. sum_secs = 0.0;
  6202. sum_n = 0;
  6203. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  6204. if (!mod_average)
  6205. sprintf (pbuf, "Angle %6.2f", angle);
  6206. glPushMatrix();
  6207. glRotatef(angle-90.0, 0, 0, 1);
  6208. /****** Calibration Loop ******/
  6209. secs = 0.0; rate = 125;
  6210. while (secs < (secspertest/4.0)) {
  6211. rate = rate*2;
  6212. if (mod_lmcolor) {
  6213. starttest(0);
  6214. for(i=(rate)/cVert; i; i--) {
  6215. glBegin(GL_TRIANGLE_STRIP);
  6216. for (j=0, tin=-2; j<cVert; j+=4, tin=-2) {
  6217. glColor3fv(&c[16]);
  6218. glTexCoord2fv(&t[tin+=2]);
  6219. glNormal3fv(&n[0]);
  6220. glVertex2fv(&vtx[j*4]);
  6221. glColor3fv(&c[20]);
  6222. glTexCoord2fv(&t[tin+=2]);
  6223. glNormal3fv(&n[4]);
  6224. glVertex2fv(&vtx[(j+1)*4]);
  6225. glColor3fv(&c[4]);
  6226. glTexCoord2fv(&t[tin+=2]);
  6227. glNormal3fv(&n[8]);
  6228. glVertex2fv(&vtx[(j+2)*4]);
  6229. glColor3fv(&c[8]);
  6230. glTexCoord2fv(&t[tin+=2]);
  6231. glNormal3fv(&n[12]);
  6232. glVertex2fv(&vtx[(j+3)*4]);
  6233. }
  6234. glColor3fv(&c[16]);
  6235. glTexCoord2fv(&t[tin+=2]);
  6236. glNormal3fv(&n[0]);
  6237. glVertex2fv(&vtx[j*4]);
  6238. glColor3fv(&c[20]);
  6239. glTexCoord2fv(&t[tin+=2]);
  6240. glNormal3fv(&n[4]);
  6241. glVertex2fv(&vtx[(j+1)*4]);
  6242. glEnd();
  6243. }
  6244. secs = timer(1);
  6245. }
  6246. else {
  6247. starttest(0);
  6248. for(i=(rate)/cVert; i; i--) {
  6249. glBegin(GL_TRIANGLE_STRIP);
  6250. for (j=0, tin=-2; j<cVert; j+=4, tin=-2) {
  6251. glNormal3fv(&n[0]);
  6252. glTexCoord2fv(&t[tin+=2]);
  6253. glVertex2fv(&vtx[j*4]);
  6254. glNormal3fv(&n[4]);
  6255. glTexCoord2fv(&t[tin+=2]);
  6256. glVertex2fv(&vtx[(j+1)*4]);
  6257. glNormal3fv(&n[8]);
  6258. glTexCoord2fv(&t[tin+=2]);
  6259. glVertex2fv(&vtx[(j+2)*4]);
  6260. glNormal3fv(&n[12]);
  6261. glTexCoord2fv(&t[tin+=2]);
  6262. glVertex2fv(&vtx[(j+3)*4]);
  6263. }
  6264. glNormal3fv(&n[0]);
  6265. glTexCoord2fv(&t[tin+=2]);
  6266. glVertex2fv(&vtx[j*4]);
  6267. glNormal3fv(&n[4]);
  6268. glTexCoord2fv(&t[tin+=2]);
  6269. glVertex2fv(&vtx[(j+1)*4]);
  6270. glEnd();
  6271. }
  6272. secs = timer(1);
  6273. }
  6274. }
  6275. rate = rate * (secspertest/secs);
  6276. rate = cVert * (rate/cVert);
  6277. for (k=0; k<loopcount; k++) {
  6278. if (mod_lmcolor) {
  6279. if (starttest(k)) {
  6280. for(i=(rate)/cVert; i; i--) {
  6281. glBegin(GL_TRIANGLE_STRIP);
  6282. for (j=0, tin=-2; j<cVert; j+=4, tin=-2) {
  6283. glColor3fv(&c[16]);
  6284. glTexCoord2fv(&t[tin+=2]);
  6285. glNormal3fv(&n[0]);
  6286. glVertex2fv(&vtx[j*4]);
  6287. glColor3fv(&c[20]);
  6288. glTexCoord2fv(&t[tin+=2]);
  6289. glNormal3fv(&n[4]);
  6290. glVertex2fv(&vtx[(j+1)*4]);
  6291. glColor3fv(&c[4]);
  6292. glTexCoord2fv(&t[tin+=2]);
  6293. glNormal3fv(&n[8]);
  6294. glVertex2fv(&vtx[(j+2)*4]);
  6295. glColor3fv(&c[8]);
  6296. glTexCoord2fv(&t[tin+=2]);
  6297. glNormal3fv(&n[12]);
  6298. glVertex2fv(&vtx[(j+3)*4]);
  6299. }
  6300. glColor3fv(&c[16]);
  6301. glTexCoord2fv(&t[tin+=2]);
  6302. glNormal3fv(&n[0]);
  6303. glVertex2fv(&vtx[j*4]);
  6304. glColor3fv(&c[20]);
  6305. glTexCoord2fv(&t[tin+=2]);
  6306. glNormal3fv(&n[4]);
  6307. glVertex2fv(&vtx[(j+1)*4]);
  6308. glEnd();
  6309. }
  6310. }
  6311. endtest(pbuf, rate, 0);
  6312. }
  6313. else {
  6314. if (starttest(k)) {
  6315. for(i=(rate)/cVert; i; i--) {
  6316. glBegin(GL_TRIANGLE_STRIP);
  6317. for (j=0, tin=-2; j<cVert; j+=4, tin=-2) {
  6318. glTexCoord2fv(&t[tin+=2]);
  6319. glNormal3fv(&n[0]);
  6320. glVertex2fv(&vtx[j*4]);
  6321. glTexCoord2fv(&t[tin+=2]);
  6322. glNormal3fv(&n[4]);
  6323. glVertex2fv(&vtx[(j+1)*4]);
  6324. glTexCoord2fv(&t[tin+=2]);
  6325. glNormal3fv(&n[8]);
  6326. glVertex2fv(&vtx[(j+2)*4]);
  6327. glTexCoord2fv(&t[tin+=2]);
  6328. glNormal3fv(&n[12]);
  6329. glVertex2fv(&vtx[(j+3)*4]);
  6330. }
  6331. glTexCoord2fv(&t[tin+=2]);
  6332. glNormal3fv(&n[0]);
  6333. glVertex2fv(&vtx[j*4]);
  6334. glTexCoord2fv(&t[tin+=2]);
  6335. glNormal3fv(&n[4]);
  6336. glVertex2fv(&vtx[(j+1)*4]);
  6337. glEnd();
  6338. }
  6339. }
  6340. endtest(pbuf, rate, 0);
  6341. }
  6342. }
  6343. glPopMatrix();
  6344. }
  6345. printaverage();
  6346. } else if (!mod_cmode && mod_shade) {
  6347. /*** GOURAUD SHADED RGB TMESH ***/
  6348. sum_secs = 0.0;
  6349. sum_n = 0;
  6350. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  6351. if (!mod_average)
  6352. sprintf(pbuf, "Angle %6.2f", angle);
  6353. glPushMatrix();
  6354. glRotatef(angle-90.0, 0, 0, 1);
  6355. /****** Calibration Loop ******/
  6356. secs = 0.0; rate = 125;
  6357. while (secs < (secspertest/4.0)) {
  6358. rate = rate*2;
  6359. starttest(0);
  6360. for(i=(rate)/cVert; i; i--) {
  6361. glBegin(GL_TRIANGLE_STRIP);
  6362. for (j=0, tin=-2; j<cVert; j+=4, tin=-2) {
  6363. glColor3fv(&c[4]);
  6364. glTexCoord2fv(&t[tin+=2]);
  6365. glVertex2fv(&vtx[j*4]);
  6366. glColor3fv(&c[8]);
  6367. glTexCoord2fv(&t[tin+=2]);
  6368. glVertex2fv(&vtx[(j+1)*4]);
  6369. glColor3fv(&c[12]);
  6370. glTexCoord2fv(&t[tin+=2]);
  6371. glVertex2fv(&vtx[(j+2)*4]);
  6372. glColor3fv(&c[16]);
  6373. glTexCoord2fv(&t[tin+=2]);
  6374. glVertex2fv(&vtx[(j+3)*4]);
  6375. }
  6376. glColor3fv(&c[4]);
  6377. glTexCoord2fv(&t[tin+=2]);
  6378. glVertex2fv(&vtx[j*4]);
  6379. glColor3fv(&c[8]);
  6380. glTexCoord2fv(&t[tin+=2]);
  6381. glVertex2fv(&vtx[(j+1)*4]);
  6382. glEnd();
  6383. }
  6384. secs = timer(1);
  6385. }
  6386. rate = rate * (secspertest/secs);
  6387. rate = cVert * (rate/cVert);
  6388. /* Do the real thing GOURAUD shaded tmesh */
  6389. for (k=0; k<loopcount; k++) {
  6390. if (starttest(k)) {
  6391. for(i=(rate)/cVert; i; i--) {
  6392. glBegin(GL_TRIANGLE_STRIP);
  6393. for (j=0, tin=-2; j<cVert; j+=4, tin=-2) {
  6394. glColor3fv(&c[4]);
  6395. glTexCoord2fv(&t[tin+=2]);
  6396. glVertex2fv(&vtx[j*4]);
  6397. glColor3fv(&c[8]);
  6398. glTexCoord2fv(&t[tin+=2]);
  6399. glVertex2fv(&vtx[(j+1)*4]);
  6400. glColor3fv(&c[12]);
  6401. glTexCoord2fv(&t[tin+=2]);
  6402. glVertex2fv(&vtx[(j+2)*4]);
  6403. glColor3fv(&c[16]);
  6404. glTexCoord2fv(&t[tin+=2]);
  6405. glVertex2fv(&vtx[(j+3)*4]);
  6406. }
  6407. glColor3fv(&c[4]);
  6408. glTexCoord2fv(&t[tin+=2]);
  6409. glVertex2fv(&vtx[j*4]);
  6410. glColor3fv(&c[8]);
  6411. glTexCoord2fv(&t[tin+=2]);
  6412. glVertex2fv(&vtx[(j+1)*4]);
  6413. glEnd();
  6414. }
  6415. }
  6416. endtest(pbuf, rate, 0);
  6417. }
  6418. glPopMatrix();
  6419. }
  6420. printaverage();
  6421. }
  6422. }
  6423. if (mod_doublebuffer) {
  6424. auxSwapBuffers();
  6425. Sleep(2000); /* for visual feedback */
  6426. }
  6427. exit(0);
  6428. }
  6429. static void perfvarray(void)
  6430. {
  6431. int i,j,k, tin;
  6432. float len;
  6433. char pbuf[256];
  6434. int cVert = 20;
  6435. int num_eles, num_tris;
  6436. if (mod_texture) {
  6437. if (mod_texfile) MyLoadImage();
  6438. else CreateImage();
  6439. InitTexParams();
  6440. }
  6441. /* Triangle mesh tests: Each tmesh contains 62 vertices, or */
  6442. /* 60 triangles. To make the calculation exact, the rate */
  6443. /* must be a multiple of 60. */
  6444. if (mod_backface){
  6445. glEnable(GL_CULL_FACE);
  6446. glCullFace(GL_FRONT);
  6447. }
  6448. if (mod_bigger) {
  6449. printf("bigger in tmesh\n");
  6450. }
  6451. /* If the triangle size is specified, set the size of the triangle mesh to
  6452. ** fit the window. The number of vertices must be a multiple of four (due
  6453. ** to code below), and it must not exceed 60.
  6454. */
  6455. if (mod_size) {
  6456. cVert = (int) (MINDIMENSION / prim_size / (float)M_SQRT2) - 2;
  6457. if (cVert & 1) cVert++;
  6458. cVert &= ~3;
  6459. if (cVert < 4) cVert = 4;
  6460. if (cVert > 60) cVert = 60;
  6461. }
  6462. num_eles = GenVertData (cVert, cVert, stride);
  6463. num_tris = num_eles/3;
  6464. if (!mod_2d)
  6465. glVertexPointer (3, GL_FLOAT, stride, &(va[0].vertex.x));
  6466. else
  6467. glVertexPointer (2, GL_FLOAT, stride, &(va[0].vertex.x));
  6468. if (mod_cmode && mod_shade) {
  6469. /*** GOURAUD SHADED CMODE TMESH ***/
  6470. glDisableClientState (GL_COLOR_ARRAY);
  6471. glDisableClientState (GL_NORMAL_ARRAY);
  6472. glEnableClientState (GL_INDEX_ARRAY);
  6473. } else if (!mod_light && !mod_shade) {
  6474. /*** FLAT SHADED TMESH ***/
  6475. glDisableClientState (GL_COLOR_ARRAY);
  6476. glDisableClientState (GL_NORMAL_ARRAY);
  6477. glDisableClientState (GL_INDEX_ARRAY);
  6478. } else if (!mod_cmode && mod_light) {
  6479. /*** LIGHTED RGB MESH ***/
  6480. glDisableClientState (GL_INDEX_ARRAY);
  6481. glEnableClientState (GL_NORMAL_ARRAY);
  6482. if (mod_lmcolor)
  6483. glEnableClientState (GL_COLOR_ARRAY);
  6484. else
  6485. glDisableClientState (GL_COLOR_ARRAY);
  6486. // glMatrixMode(GL_PROJECTION);
  6487. // glLoadIdentity();
  6488. // glOrtho(-0.5*xsize,0.5*xsize,-0.5*ysize,0.5*ysize,1.0,-1.0);
  6489. // glMatrixMode(GL_MODELVIEW);
  6490. /* set lights */
  6491. setLightingParameters();
  6492. } else if (!mod_cmode && mod_shade) {
  6493. /*** GOURAUD SHADED RGB TMESH ***/
  6494. glDisableClientState (GL_INDEX_ARRAY);
  6495. glDisableClientState (GL_NORMAL_ARRAY);
  6496. glEnableClientState (GL_COLOR_ARRAY);
  6497. }
  6498. sum_secs = 0.0;
  6499. sum_n = 0;
  6500. for (angle = 2.0; angle < 360.0; angle += 22.5) {
  6501. if (!mod_average)
  6502. sprintf (pbuf, "Angle %6.2f", angle);
  6503. glPushMatrix ();
  6504. glRotatef (angle-90.0, 0, 0, 1.0);
  6505. /****** Calibration Loop ******/
  6506. secs = 0.0; rate = 125;
  6507. while (secs < (secspertest/4.0)) {
  6508. rate = rate*2;
  6509. starttest(0);
  6510. for(i=(rate)/num_tris; i; i--)
  6511. glDrawElements (GL_TRIANGLES, num_eles, GL_UNSIGNED_INT, ve);
  6512. secs = timer(1);
  6513. }
  6514. /****** Real thing *******/
  6515. rate = rate * (secspertest/secs);
  6516. rate = cVert * (rate/cVert);
  6517. for (k=0; k<loopcount; k++) {
  6518. if (starttest(k))
  6519. for(i=(rate)/num_tris; i; i--)
  6520. glDrawElements (GL_TRIANGLES, num_eles, GL_UNSIGNED_INT,
  6521. ve);
  6522. endtest(pbuf, rate, 0);
  6523. }
  6524. glPopMatrix ();
  6525. }
  6526. printaverage();
  6527. if (mod_doublebuffer) {
  6528. auxSwapBuffers();
  6529. Sleep(2000); /* for visual feedback */
  6530. }
  6531. exit(0);
  6532. }
  6533. #ifdef Portme
  6534. Static Void Buildattributelist(Int *List, Int Mod_Cmode, Int Mod_Z)
  6535. {
  6536. If (!Mod_Cmode) {
  6537. *List++ = Glx_Rgba;
  6538. *List++ = Glx_Red_Size; *List++ = 1;
  6539. *List++ = Glx_GREEN_SIZE; *list++ = 1;
  6540. *list++ = GLX_BLUE_SIZE; *list++ = 1;
  6541. }
  6542. if (mod_z) {
  6543. *list++ = GLX_DEPTH_SIZE;
  6544. *list++ = 1;
  6545. }
  6546. *list = None;
  6547. }
  6548. static Colormap buildColormap(XVisualInfo *vis, int mod_cmode)
  6549. {
  6550. Colormap cmap;
  6551. XColor col;
  6552. int i;
  6553. if (mod_cmode) {
  6554. XColor col;
  6555. cmap = XCreateColormap(theDisplay,
  6556. RootWindow(theDisplay, vis->screen),
  6557. vis->visual, AllocAll);
  6558. /* create default entries */
  6559. col.flags = DoRed | DoGreen | DoBlue;
  6560. for (i = BLACK; i <= WHITE; i++) {
  6561. col.pixel = i;
  6562. col.red = (i % 2 == 1) ? 0xffff : 0;
  6563. col.green = ((i >> 1) % 2 == 1) ? 0xffff : 0;
  6564. col.blue = ((i >> 2) % 2 == 1) ? 0xffff : 0;
  6565. XStoreColor(theDisplay, cmap, &col);
  6566. }
  6567. }
  6568. else
  6569. cmap= XCreateColormap(theDisplay,
  6570. RootWindow(theDisplay, vis->screen),
  6571. vis->visual, AllocNone);
  6572. return cmap;
  6573. }
  6574. static Bool WaitForNotify(Display *d, XEvent *e, char *arg) {
  6575. return (e->type == MapNotify) && (e->xmap.window == (Window)arg);
  6576. }
  6577. #endif
  6578. static void print_usage (char *str)
  6579. {
  6580. printf ("%s - Usage:\n", str);
  6581. printf ("gpt <test> [<modifiers>] [loop count] [duration]\n");
  6582. printf ("\nValid tests:\n");
  6583. printf (" xform Test transform rate\n");
  6584. printf (" fill Test fill rate\n");
  6585. printf (" dma Test DMA rate\n");
  6586. printf (" char Test character drawing rate\n");
  6587. printf (" line Test line drawing rate\n");
  6588. printf (" poly Test polygon drawing rate\n");
  6589. printf (" tmesh Test Triangle mesh drawing rate\n");
  6590. printf (" qstrip Test Quad strip rate\n");
  6591. printf (" clear Test screen clear rate\n");
  6592. printf (" varray Test vertex array drawing rate\n");
  6593. printf ("\nValid modifiers:\n");
  6594. printf (" +2d Restrict transform to 2D, use glVertex2fv\n");
  6595. printf (" +z Enable Z buffering\n");
  6596. printf (" +shade Enable Gouraud shading\n");
  6597. printf (" +cmode Use color index mode (Limited support)\n");
  6598. printf (" +1ilight Enable 1 infinite light\n");
  6599. printf (" +2ilight Enable 2 infinite lights\n");
  6600. printf (" +4ilight Enable 4 infinite lights\n");
  6601. printf (" +1llight Enable 1 local light\n");
  6602. printf (" +2llight Enable 2 local lights\n");
  6603. printf (" +4llight Enable 4 local lights\n");
  6604. printf (" +lmcolor Enable colored lighted vertices\n");
  6605. printf (" +depth Enable depth cueing (Lines only) \n");
  6606. printf (" +aa Enable anti-aliasing (Points and lines only)\n");
  6607. printf (" +snap Set subpixel FALSE (Fast path for PI).\n");
  6608. printf (" +dashed Enable dashed lines.\n");
  6609. printf (" +width Set line width, +width n (n = 0-9 pixels)\n");
  6610. printf (" +pattern Enable pattern filling.\n");
  6611. printf (" +oldwindow Open window at (100,900)-(100,650)\n");
  6612. printf (" +brief Brief text output\n");
  6613. printf (" +backface Sets frontface or backface to cull primitives\n");
  6614. printf (" +dlist Use display lists (not implemented)\n");
  6615. printf (" +texture Use Texture mapping\n");
  6616. printf (" +blend Use texture blend mode instead of decal\n");
  6617. printf (" +modulate Use texure modulate function instead of decal\n");
  6618. printf (" +db Use double-buffered pixel format\n");
  6619. printf (" +avg Print averages only\n");
  6620. printf (" +size <size> Sets size of line or side of triangle\n");
  6621. printf (" +texfile <filename> Texture file\n");
  6622. }
  6623. static void badparam(int param, char *paramstr)
  6624. {
  6625. if (param) printf ("%s ",paramstr);
  6626. }
  6627. void reshape(GLsizei w, GLsizei h)
  6628. {
  6629. glViewport(0, 0, w, h);
  6630. if (mod_2d)
  6631. gluOrtho2D(-0.5*xsize, 0.5*xsize,-0.5*ysize, 0.5*ysize);
  6632. else
  6633. glOrtho(-0.5*xsize, 0.5*xsize,-0.5*ysize, 0.5*ysize,1.0, -1.0);
  6634. }
  6635. main(int argc, char *argv[])
  6636. {
  6637. int test_xform = 0;
  6638. int test_fill = 0;
  6639. int test_dma = 0;
  6640. int test_char = 0;
  6641. int test_line = 0;
  6642. int test_poly = 0;
  6643. int test_tmesh = 0;
  6644. int test_clear = 0;
  6645. int test_varray = 0;
  6646. int test_qstrip = 0;
  6647. int i;
  6648. char pbuf[256];
  6649. char pbuf2[256];
  6650. char pbuf3[256];
  6651. extern void bzero(void *, int);
  6652. /* Data initialization. */
  6653. /* These are malloced and assigned so we get quad alignment */
  6654. v = (float *)malloc ((NVERT+1)*4*sizeof(float));
  6655. v = (float *)QUAD_ROUND((int)v);
  6656. mv = (float *)malloc ((NVERT+1)*4*sizeof(float));
  6657. mv = (float *)QUAD_ROUND((int)mv);
  6658. n = (float *)malloc ((NNORM+1)*4*sizeof(float));
  6659. n = (float *)QUAD_ROUND((int)n);
  6660. c = (float *)malloc ((NCOLR+1)*4*sizeof(float));
  6661. c = (float *)QUAD_ROUND((int)c);
  6662. t = (float *)malloc ((NTEXTR)*2*sizeof(float));
  6663. n[0]=1.0; n[1]=0.0; n[2]=0.0; n[3]=0.0;
  6664. n[4]=0.0; n[5]=1.0; n[6]=0.0; n[7]=0.0;
  6665. n[8]=0.0; n[9]=0.0; n[10]=1.0; n[11]=0.0;
  6666. n[12]=0.0; n[13]=M_SQRT1_2; n[14]=M_SQRT1_2; n[15]=0.0;
  6667. c[0]=0.0; c[1]=0.0; c[2]=0.0; c[3]=0.0;
  6668. c[4]=1.0; c[5]=0.0; c[6]=0.0; c[7]=0.0;
  6669. c[8]=0.0; c[9]=1.0; c[10]=0.0; c[11]=0.0;
  6670. c[12]=0.0; c[13]=0.0; c[14]=1.0; c[15]=0.0;
  6671. c[16]=1.0; c[17]=1.0; c[18]=0.0; c[19]=0.0;
  6672. c[20]=1.0; c[21]=0.0; c[22]=1.0; c[23]=0.0;
  6673. c[24]=0.0; c[25]=1.0; c[26]=1.0; c[27]=0.0;
  6674. c[28]=1.0; c[29]=1.0; c[30]=1.0; c[31]=0.0;
  6675. t[0]=0.0; t[1]=0.0;
  6676. t[2]=1.0; t[3]=0.0;
  6677. t[6]=1.0; t[7]=1.0;
  6678. t[4]=0.0; t[5]=1.0;
  6679. /* Process command line arguments */
  6680. /* First, check for which test is specified */
  6681. if (argc <= 1) {
  6682. print_usage ("");
  6683. exit (1);
  6684. }
  6685. if (strcmp (argv[1], "xform") == 0)
  6686. test_xform = 1;
  6687. else if (strcmp (argv[1], "fill") == 0)
  6688. test_fill = 1;
  6689. else if (strcmp (argv[1], "dma") == 0)
  6690. test_dma = 1;
  6691. else if (strcmp (argv[1], "char") == 0)
  6692. test_char = 1;
  6693. else if (strcmp (argv[1], "line") == 0)
  6694. test_line = 1;
  6695. else if (strcmp (argv[1], "poly") == 0)
  6696. test_poly = 1;
  6697. else if (strcmp (argv[1], "tmesh") == 0)
  6698. test_tmesh = 1;
  6699. else if (strcmp (argv[1], "clear") == 0)
  6700. test_clear = 1;
  6701. else if (strcmp (argv[1], "qstrip") == 0)
  6702. test_qstrip = 1;
  6703. else if (strcmp (argv[1], "varray") == 0)
  6704. test_varray = 1;
  6705. else {
  6706. print_usage ("Invalid test");
  6707. exit (1);
  6708. }
  6709. /* Next, check for modifiers */
  6710. for (i=2; i<argc; i++) {
  6711. if (*(argv[i]) != '+') break;
  6712. if (strcmp (argv[i], "+2d") == 0)
  6713. mod_2d = 1;
  6714. else if (strcmp (argv[i], "+z") == 0)
  6715. mod_z = 1;
  6716. else if (strcmp (argv[i], "+texture") == 0)
  6717. mod_texture = 1;
  6718. else if (strcmp (argv[i], "+blend") == 0)
  6719. mod_blend = 1;
  6720. else if (strcmp (argv[i], "+modulate") == 0)
  6721. mod_modulate = 1;
  6722. else if (strcmp (argv[i], "+shade") == 0)
  6723. mod_shade = 1;
  6724. else if (strcmp (argv[i], "+cmode") == 0)
  6725. mod_cmode = 1;
  6726. else if (strcmp (argv[i], "+1ilight") == 0)
  6727. mod_1ilight = 1;
  6728. else if (strcmp (argv[i], "+2ilight") == 0)
  6729. mod_2ilight = 1;
  6730. else if (strcmp (argv[i], "+4ilight") == 0)
  6731. mod_4ilight = 1;
  6732. else if (strcmp (argv[i], "+1llight") == 0)
  6733. mod_1llight = 1;
  6734. else if (strcmp (argv[i], "+2llight") == 0)
  6735. mod_2llight = 1;
  6736. else if (strcmp (argv[i], "+4llight") == 0)
  6737. mod_4llight = 1;
  6738. else if (strcmp (argv[i], "+lmcolor") == 0)
  6739. mod_lmcolor = 1;
  6740. else if (strcmp (argv[i], "+depth") == 0)
  6741. mod_depth = 1;
  6742. else if (strcmp (argv[i], "+aa") == 0)
  6743. mod_aa = 1;
  6744. else if (strcmp (argv[i], "+snap") == 0)
  6745. mod_snap = 1;
  6746. else if (strcmp (argv[i], "+dashed") == 0)
  6747. mod_dashed = 1;
  6748. else if (strcmp (argv[i], "+oldwindow") == 0)
  6749. mod_oldwindow = 1;
  6750. else if (strcmp (argv[i], "+brief") == 0)
  6751. mod_brief = 1;
  6752. else if (strcmp (argv[i], "+backface") == 0)
  6753. mod_backface = 1;
  6754. else if (strcmp (argv[i], "+bigger") == 0)
  6755. { mod_bigger = 1; printf("bigger\n"); }
  6756. else if (strcmp (argv[i], "+width") == 0) {
  6757. if ((i+1 < argc) && ((*(argv[i+1]) >= '0') || (*(argv[i+1]) <= '9'))) {
  6758. mod_width = 1;
  6759. line_width = atoi(argv[i+1]);
  6760. i++;
  6761. }
  6762. }
  6763. else if (strcmp (argv[i], "+pattern") == 0)
  6764. mod_pattern = 1;
  6765. else if (strcmp (argv[i], "+dlist") == 0)
  6766. useList = GL_TRUE;
  6767. else if (strcmp (argv[i], "+db") == 0)
  6768. mod_doublebuffer = 1;
  6769. else if (strcmp (argv[i], "+avg") == 0)
  6770. mod_average = 1;
  6771. else if (strcmp (argv[i], "+size") == 0) {
  6772. if (i+1 < argc) {
  6773. mod_size = 1;
  6774. prim_size = (float) atoi(argv[i+1]);
  6775. i++;
  6776. }
  6777. }
  6778. else if (strcmp (argv[i], "+texfile") == 0) {
  6779. if (i+1 < argc) {
  6780. mod_texfile = 1;
  6781. strcpy(tex_fname, argv[i+1]);
  6782. i++;
  6783. }
  6784. }
  6785. else {
  6786. sprintf(pbuf,"%s: Invalid modifier\n",argv[i]);
  6787. print_usage (pbuf);
  6788. exit (1);
  6789. }
  6790. }
  6791. /* Finally, check if count and duration were specified */
  6792. /* make sure we have a digit here */
  6793. if ((i < argc) && ((*(argv[i]) < '0') || (*(argv[i]) > '9'))) {
  6794. print_usage ("Invalid argument");
  6795. exit (1);
  6796. }
  6797. secspertest = 1.0;
  6798. loopcount = 1;
  6799. if (i < argc) {
  6800. loopcount = atoi(argv[i]);
  6801. if (loopcount <= 0) loopcount = 1;
  6802. }
  6803. i++;
  6804. if (i < argc) {
  6805. secspertest = atof(argv[i]);
  6806. if (secspertest < 0.1) secspertest = 1.0;
  6807. }
  6808. /* vertex initialization was moved to here due to the +size modifier */
  6809. for (i=0; i<NVERT; i++) {
  6810. v[4*i] = ((i&0x01) ? prim_size + 10 : 10.0);
  6811. v[(4*i)+1] = prim_size*(i>>1) + 10.0;
  6812. v[(4*i)+2] = 0.0;
  6813. v[(4*i)+3] = 1.0;
  6814. mv[4*i] = ((i&0x01) ? 30.0 : 10.0);
  6815. mv[(4*i)+1] = 20.0 *((i>>1)+1);
  6816. mv[(4*i)+2] = 0.0;
  6817. mv[(4*i)+3] = 1.0;
  6818. }
  6819. /*--------------------------------------------------------*/
  6820. /* check for unsupported or unimplemented combinations */
  6821. /*--------------------------------------------------------*/
  6822. if (mod_bigger && (!test_tmesh)) {
  6823. printf("+bigger only works on tmesh\n");
  6824. exit (1);
  6825. }
  6826. if (mod_size && (!(test_tmesh || test_line || test_poly || test_qstrip
  6827. || test_varray))) {
  6828. printf("+size only works with line, tmesh, varray, poly and qstrip\n");
  6829. exit (1);
  6830. }
  6831. if (mod_backface && !(test_tmesh || test_poly || test_qstrip )) {
  6832. printf("+backface only works on tmesh, poly, varray or qstrip\n");
  6833. exit(1);
  6834. }
  6835. if (mod_1ilight || mod_2ilight || mod_4ilight || mod_lmcolor ||
  6836. mod_1llight || mod_2llight || mod_4llight)
  6837. mod_light = 1;
  6838. if (mod_lmcolor && !(mod_1ilight || mod_2ilight || mod_4ilight ||
  6839. mod_1llight || mod_2llight || mod_4llight)) {
  6840. printf("Can't have +lmcolor without lighting enabled\n");
  6841. exit(1);
  6842. }
  6843. if (mod_blend && !mod_texture) {
  6844. printf("+blend works only with texture\n");
  6845. exit (1);
  6846. }
  6847. if (mod_modulate && !mod_texture) {
  6848. printf("+modulate works only with texture\n");
  6849. exit (1);
  6850. }
  6851. if (mod_blend && mod_modulate) {
  6852. printf("Use either +blend or +modulate, not both\n");
  6853. exit (1);
  6854. }
  6855. if (mod_texfile && !mod_texture) {
  6856. printf("+texfile works only with texture\n");
  6857. exit (1);
  6858. }
  6859. if (mod_width && !(test_line || test_xform)) {
  6860. printf("Width only available with lines and points\n");
  6861. exit(1);
  6862. }
  6863. if (mod_snap)
  6864. printf("+snap has no effect in OpenGL, disregarding\n");
  6865. if (test_xform) {
  6866. if (mod_light || mod_depth || mod_pattern || mod_dashed) {
  6867. printf("%s: invalid parameter:\n",argv[1]);
  6868. badparam(mod_light,"+light");
  6869. badparam(mod_depth,"+depth");
  6870. badparam(mod_pattern,"+pattern");
  6871. badparam(mod_dashed,"+dashed");
  6872. printf("\n");
  6873. exit(1);
  6874. }
  6875. }
  6876. if (test_line) {
  6877. if (mod_pattern || mod_light) {
  6878. printf("%s: invalid parameter:\n",argv[1]);
  6879. badparam(mod_pattern,"+pattern");
  6880. badparam(mod_light,"+light");
  6881. printf("\n");
  6882. exit(1);
  6883. }
  6884. if ((mod_light && mod_cmode) || (mod_aa&&mod_depth) ||
  6885. (mod_depth&&mod_2d)){
  6886. printf("%s: invalid parameter combination:\n",argv[1]);
  6887. badparam(mod_light&&mod_cmode," +light && +cmode");
  6888. badparam(mod_aa&&mod_depth," +aa && +depth");
  6889. badparam(mod_depth&&mod_2d," +depth && +2d");
  6890. printf("\n");
  6891. exit(1);
  6892. }
  6893. }
  6894. if (test_char) {
  6895. if (mod_pattern || mod_width || mod_dashed || mod_aa ||
  6896. mod_depth || mod_light || mod_texture) {
  6897. printf("%s: invalid parameter:\n",argv[1]);
  6898. badparam(mod_pattern,"+pattern");
  6899. badparam(mod_dashed,"+dashed");
  6900. badparam(mod_width,"+width");
  6901. badparam(mod_depth,"+depth");
  6902. badparam(mod_texture,"+texture");
  6903. badparam(mod_aa,"+aa");
  6904. badparam(mod_light,"+light");
  6905. printf("\n");
  6906. exit(1);
  6907. }
  6908. }
  6909. if (test_tmesh || test_qstrip || test_varray) {
  6910. if (mod_pattern || mod_dashed || mod_width || mod_depth || mod_aa ) {
  6911. printf("%s: invalid parameter:\n",argv[1]);
  6912. badparam(mod_pattern,"+pattern");
  6913. badparam(mod_dashed,"+dashed");
  6914. badparam(mod_width,"+width");
  6915. badparam(mod_depth,"+depth");
  6916. badparam(mod_aa,"+aa");
  6917. printf("\n");
  6918. exit(1);
  6919. }
  6920. }
  6921. if (test_poly) {
  6922. if (mod_aa || mod_width || mod_depth) {
  6923. printf("%s: invalid parameter:\n",argv[1]);
  6924. badparam(mod_dashed,"+dashed");
  6925. badparam(mod_width,"+width");
  6926. badparam(mod_depth,"+depth");
  6927. badparam(mod_aa,"+aa");
  6928. printf("\n");
  6929. exit(1);
  6930. }
  6931. }
  6932. if (test_dma) {
  6933. if (mod_2d || mod_z || mod_shade || mod_cmode || mod_light ||
  6934. mod_depth || mod_aa || mod_snap || mod_dashed || mod_width ||
  6935. mod_pattern || mod_oldwindow || mod_texture) {
  6936. printf("DMA test. No modifiers have any effect\n");
  6937. printf("\n");
  6938. exit(1);
  6939. }
  6940. mod_2d = 1;
  6941. mod_shade = 1;
  6942. mod_oldwindow = 0;
  6943. }
  6944. if(test_clear) {
  6945. if(mod_2d || mod_shade || mod_light || mod_depth || mod_aa ||
  6946. mod_texture ||
  6947. mod_dashed || mod_width || mod_oldwindow || mod_pattern) {
  6948. printf("%s: invalid parameter:\n",argv[1]);
  6949. badparam(mod_2d,"+2d");
  6950. badparam(mod_shade,"+shade");
  6951. badparam(mod_dashed,"+dashed");
  6952. badparam(mod_width,"+width");
  6953. badparam(mod_depth,"+depth");
  6954. badparam(mod_aa,"+aa");
  6955. badparam(mod_oldwindow,"+oldwindow");
  6956. badparam(mod_pattern,"+pattern");
  6957. printf("\n");
  6958. exit(1);
  6959. }
  6960. }
  6961. if(test_fill) {
  6962. if(mod_depth || mod_aa || mod_dashed || mod_width ||
  6963. mod_texture || mod_oldwindow) {
  6964. printf("%s: invalid parameter:\n",argv[1]);
  6965. badparam(mod_dashed,"+dashed");
  6966. badparam(mod_width,"+width");
  6967. badparam(mod_depth,"+depth");
  6968. badparam(mod_oldwindow,"+oldwindow");
  6969. printf("\n");
  6970. exit(1);
  6971. }
  6972. }
  6973. /* Arguments all OK, put up a window, and an informative banner */
  6974. xsize = WINWIDTH;
  6975. ysize = WINHEIGHT;
  6976. if (mod_doublebuffer)
  6977. auxInitDisplayMode(AUX_DOUBLE | AUX_RGB | AUX_DEPTH);
  6978. else
  6979. auxInitDisplayMode(AUX_SINGLE | AUX_RGB | AUX_DEPTH);
  6980. auxInitPosition(0, 0, 0 + xsize, 0 + ysize);
  6981. auxInitWindow("ogpt");
  6982. auxReshapeFunc(reshape);
  6983. #ifdef FONTS_NEEDED
  6984. /* get the font if required */
  6985. if (test_char) {
  6986. XFontStruct *fontInfo = NULL;
  6987. fontInfo = XLoadQueryFont(theDisplay, IRISFONT);
  6988. if (fontInfo == NULL) {
  6989. printf("Could not load font '%s'\n", IRISFONT);
  6990. exit(1);
  6991. }
  6992. theFont = fontInfo->fid;
  6993. }
  6994. #endif
  6995. if (!mod_brief) {
  6996. printf ("\nOpenGL Graphics Performance Tester - version 1.0\n");
  6997. printf ("------------------------------------------------\n\n");
  6998. printf ("window size = %ld %ld\n", xsize,ysize);
  6999. printf ("%6s: ", argv[1]);
  7000. printf ("%s, %s, %s, %s\n",
  7001. (mod_2d ? "2D" : "3D"),
  7002. (mod_z ? "Z buffered" : "not Z buffered"),
  7003. (mod_shade ? "Gouraud shaded" : "flat shaded"),
  7004. (mod_pattern ? "patterned" : "not patterned") );
  7005. printf (" %s, %s, %s, width = %d, %s,\n",
  7006. (mod_light ? "lighted" : "not lighted"),
  7007. (mod_depth ? "depth cued" : "not depth cued"),
  7008. (mod_dashed ? "dashed" : "not dashed"),
  7009. line_width,
  7010. (mod_aa ? "anti-aliased" : "not anti-aliased") );
  7011. printf (" %s, %s\n",
  7012. (mod_cmode ? "CImode" : "RGBmode"),
  7013. (mod_backface ? "backface(TRUE)" : "backface(FALSE)"));
  7014. printf (" %s\n",
  7015. (mod_texture ? "Texturing on" : "Texturing off"));
  7016. printf (" %s\n",
  7017. (mod_blend ? "Blending on" : (mod_modulate ? "Modulation on" :
  7018. "Decal on")));
  7019. }
  7020. else {
  7021. sprintf(pbuf,"width=%d ",line_width);
  7022. sprintf(pbuf2,"lighted ( %s%s%s%s%s%s) ",
  7023. (mod_1ilight ? "1inf " : ""),
  7024. (mod_2ilight ? "2inf " : ""),
  7025. (mod_4ilight ? "4inf " : ""),
  7026. (mod_1llight ? "1lcl " : ""),
  7027. (mod_2llight ? "2lcl " : ""),
  7028. (mod_4llight ? "4lcl " : ""));
  7029. printf("%6s: ", argv[1]);
  7030. printf("%s", (mod_2d ? "2D " : ""));
  7031. printf("%s", (mod_z ? "Zbuf " : ""));
  7032. printf("%s", (mod_shade ? "Gouraud " : ""));
  7033. printf("%s", (mod_pattern ? "patterned " : ""));
  7034. printf("%s", (mod_depth ? "depth cued " : ""));
  7035. printf("%s", (mod_dashed ? "dashed " : ""));
  7036. printf("%s", (line_width!=1 ? pbuf : ""));
  7037. printf("%s", (mod_aa ? "anti-aliased " : ""));
  7038. printf("%s", (mod_cmode ? "cmode " : ""));
  7039. printf("%s", (mod_light ? pbuf2 : ""));
  7040. printf("%s", (mod_lmcolor ? "lmcolor " : ""));
  7041. printf("%s", (mod_oldwindow ? "oldwindow " : ""));
  7042. printf("%s", (mod_backface ? "backfaced " : ""));
  7043. printf("%s", (mod_texture ? "textured " : ""));
  7044. printf("%s", (mod_blend && mod_texture ? "blend " : ""));
  7045. printf("%s", (mod_modulate && mod_texture ? "modulate " : ""));
  7046. printf("%s", (!mod_modulate && !mod_blend && mod_texture ?
  7047. "decal " : ""));
  7048. printf("\n");
  7049. }
  7050. /* Then run the requested test */
  7051. if (useList)
  7052. initListMode();
  7053. glShadeModel(mod_shade ? GL_SMOOTH : GL_FLAT);
  7054. if (mod_z) {
  7055. glEnable(GL_DEPTH_TEST);
  7056. /* make z function the same as IrisGL's default */
  7057. glDepthFunc(GL_LEQUAL);
  7058. }
  7059. else
  7060. glDisable(GL_DEPTH_TEST);
  7061. Sleep(1000); /* wait for window system to quiet down */
  7062. if (mod_cmode) {
  7063. glClearIndex(BLACK);
  7064. glIndexi(WHITE);
  7065. } else {
  7066. glClearColor(c[0], c[1], c[2], c[3]);
  7067. glColor3fv(&c[28]);
  7068. }
  7069. glClear(GL_COLOR_BUFFER_BIT);
  7070. if (mod_z) {
  7071. glClear(GL_DEPTH_BUFFER_BIT);
  7072. }
  7073. if (test_xform)
  7074. auxMainLoop(perfpoint);
  7075. if (test_line)
  7076. auxMainLoop(perfline);
  7077. if (test_tmesh && !mod_texture)
  7078. auxMainLoop(perftmesh);
  7079. if (test_tmesh && mod_texture)
  7080. auxMainLoop(perftmeshtex);
  7081. if (test_poly && !mod_texture)
  7082. auxMainLoop(perfpoly);
  7083. if (test_poly && mod_texture)
  7084. auxMainLoop(perfpolytex);
  7085. if (test_qstrip && !mod_texture)
  7086. auxMainLoop(perfqstrip);
  7087. if (test_qstrip && mod_texture)
  7088. auxMainLoop(perfqstriptex);
  7089. if (test_fill)
  7090. auxMainLoop(perffill);
  7091. if (test_clear)
  7092. auxMainLoop(perfclear);
  7093. if (test_varray)
  7094. auxMainLoop(perfvarray);
  7095. #ifdef PORTME
  7096. if (test_char)
  7097. perfchar();
  7098. if (test_fill)
  7099. perffill();
  7100. if (test_dma)
  7101. perfpixels();
  7102. if (test_clear)
  7103. perfclear();
  7104. /*
  7105. if (test_texture)
  7106. perftexture();
  7107. */
  7108. #endif
  7109. }