Clone of mesa.
Vous ne pouvez pas sélectionner plus de 25 sujets Les noms de sujets doivent commencer par une lettre ou un nombre, peuvent contenir des tirets ('-') et peuvent comporter jusqu'à 35 caractères.

glxgears.c 17KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651
  1. /*
  2. * Copyright (C) 1999-2001 Brian Paul All Rights Reserved.
  3. *
  4. * Permission is hereby granted, free of charge, to any person obtaining a
  5. * copy of this software and associated documentation files (the "Software"),
  6. * to deal in the Software without restriction, including without limitation
  7. * the rights to use, copy, modify, merge, publish, distribute, sublicense,
  8. * and/or sell copies of the Software, and to permit persons to whom the
  9. * Software is furnished to do so, subject to the following conditions:
  10. *
  11. * The above copyright notice and this permission notice shall be included
  12. * in all copies or substantial portions of the Software.
  13. *
  14. * THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
  15. * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
  16. * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
  17. * BRIAN PAUL BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN
  18. * AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
  19. * CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
  20. */
  21. /*
  22. * This is a port of the infamous "gears" demo to straight GLX (i.e. no GLUT)
  23. * Port by Brian Paul 23 March 2001
  24. *
  25. * Command line options:
  26. * -info print GL implementation information
  27. * -stereo use stereo enabled GLX visual
  28. *
  29. */
  30. #include <math.h>
  31. #include <stdlib.h>
  32. #include <stdio.h>
  33. #include <string.h>
  34. #include <X11/Xlib.h>
  35. #include <X11/keysym.h>
  36. #include <GL/gl.h>
  37. #include <GL/glx.h>
  38. #define BENCHMARK
  39. #ifdef BENCHMARK
  40. /* XXX this probably isn't very portable */
  41. #include <sys/time.h>
  42. #include <unistd.h>
  43. /* return current time (in seconds) */
  44. static double
  45. current_time(void)
  46. {
  47. struct timeval tv;
  48. #ifdef __VMS
  49. (void) gettimeofday(&tv, NULL );
  50. #else
  51. struct timezone tz;
  52. (void) gettimeofday(&tv, &tz);
  53. #endif
  54. return (double) tv.tv_sec + tv.tv_usec / 1000000.0;
  55. }
  56. #else /*BENCHMARK*/
  57. /* dummy */
  58. static double
  59. current_time(void)
  60. {
  61. /* update this function for other platforms! */
  62. static double t = 0.0;
  63. static int warn = 1;
  64. if (warn) {
  65. fprintf(stderr, "Warning: current_time() not implemented!!\n");
  66. warn = 0;
  67. }
  68. return t += 1.0;
  69. }
  70. #endif /*BENCHMARK*/
  71. #ifndef M_PI
  72. #define M_PI 3.14159265
  73. #endif
  74. static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0;
  75. static GLint gear1, gear2, gear3;
  76. static GLfloat angle = 0.0;
  77. static GLboolean fullscreen = GL_FALSE; /* Create a single fullscreen window */
  78. static GLboolean stereo = GL_FALSE; /* Enable stereo. */
  79. static GLfloat eyesep = 5.0; /* Eye separation. */
  80. static GLfloat fix_point = 40.0; /* Fixation point distance. */
  81. static GLfloat left, right, asp; /* Stereo frustum params. */
  82. /*
  83. *
  84. * Draw a gear wheel. You'll probably want to call this function when
  85. * building a display list since we do a lot of trig here.
  86. *
  87. * Input: inner_radius - radius of hole at center
  88. * outer_radius - radius at center of teeth
  89. * width - width of gear
  90. * teeth - number of teeth
  91. * tooth_depth - depth of tooth
  92. */
  93. static void
  94. gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width,
  95. GLint teeth, GLfloat tooth_depth)
  96. {
  97. GLint i;
  98. GLfloat r0, r1, r2;
  99. GLfloat angle, da;
  100. GLfloat u, v, len;
  101. r0 = inner_radius;
  102. r1 = outer_radius - tooth_depth / 2.0;
  103. r2 = outer_radius + tooth_depth / 2.0;
  104. da = 2.0 * M_PI / teeth / 4.0;
  105. glShadeModel(GL_FLAT);
  106. glNormal3f(0.0, 0.0, 1.0);
  107. /* draw front face */
  108. glBegin(GL_QUAD_STRIP);
  109. for (i = 0; i <= teeth; i++) {
  110. angle = i * 2.0 * M_PI / teeth;
  111. glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
  112. glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
  113. if (i < teeth) {
  114. glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
  115. glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
  116. width * 0.5);
  117. }
  118. }
  119. glEnd();
  120. /* draw front sides of teeth */
  121. glBegin(GL_QUADS);
  122. da = 2.0 * M_PI / teeth / 4.0;
  123. for (i = 0; i < teeth; i++) {
  124. angle = i * 2.0 * M_PI / teeth;
  125. glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
  126. glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5);
  127. glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
  128. width * 0.5);
  129. glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
  130. width * 0.5);
  131. }
  132. glEnd();
  133. glNormal3f(0.0, 0.0, -1.0);
  134. /* draw back face */
  135. glBegin(GL_QUAD_STRIP);
  136. for (i = 0; i <= teeth; i++) {
  137. angle = i * 2.0 * M_PI / teeth;
  138. glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
  139. glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
  140. if (i < teeth) {
  141. glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
  142. -width * 0.5);
  143. glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
  144. }
  145. }
  146. glEnd();
  147. /* draw back sides of teeth */
  148. glBegin(GL_QUADS);
  149. da = 2.0 * M_PI / teeth / 4.0;
  150. for (i = 0; i < teeth; i++) {
  151. angle = i * 2.0 * M_PI / teeth;
  152. glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
  153. -width * 0.5);
  154. glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
  155. -width * 0.5);
  156. glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
  157. glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
  158. }
  159. glEnd();
  160. /* draw outward faces of teeth */
  161. glBegin(GL_QUAD_STRIP);
  162. for (i = 0; i < teeth; i++) {
  163. angle = i * 2.0 * M_PI / teeth;
  164. glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
  165. glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
  166. u = r2 * cos(angle + da) - r1 * cos(angle);
  167. v = r2 * sin(angle + da) - r1 * sin(angle);
  168. len = sqrt(u * u + v * v);
  169. u /= len;
  170. v /= len;
  171. glNormal3f(v, -u, 0.0);
  172. glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5);
  173. glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
  174. glNormal3f(cos(angle), sin(angle), 0.0);
  175. glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
  176. width * 0.5);
  177. glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
  178. -width * 0.5);
  179. u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da);
  180. v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da);
  181. glNormal3f(v, -u, 0.0);
  182. glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
  183. width * 0.5);
  184. glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
  185. -width * 0.5);
  186. glNormal3f(cos(angle), sin(angle), 0.0);
  187. }
  188. glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5);
  189. glVertex3f(r1 * cos(0), r1 * sin(0), -width * 0.5);
  190. glEnd();
  191. glShadeModel(GL_SMOOTH);
  192. /* draw inside radius cylinder */
  193. glBegin(GL_QUAD_STRIP);
  194. for (i = 0; i <= teeth; i++) {
  195. angle = i * 2.0 * M_PI / teeth;
  196. glNormal3f(-cos(angle), -sin(angle), 0.0);
  197. glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
  198. glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
  199. }
  200. glEnd();
  201. }
  202. static void
  203. draw(void)
  204. {
  205. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  206. glPushMatrix();
  207. glRotatef(view_rotx, 1.0, 0.0, 0.0);
  208. glRotatef(view_roty, 0.0, 1.0, 0.0);
  209. glRotatef(view_rotz, 0.0, 0.0, 1.0);
  210. glPushMatrix();
  211. glTranslatef(-3.0, -2.0, 0.0);
  212. glRotatef(angle, 0.0, 0.0, 1.0);
  213. glCallList(gear1);
  214. glPopMatrix();
  215. glPushMatrix();
  216. glTranslatef(3.1, -2.0, 0.0);
  217. glRotatef(-2.0 * angle - 9.0, 0.0, 0.0, 1.0);
  218. glCallList(gear2);
  219. glPopMatrix();
  220. glPushMatrix();
  221. glTranslatef(-3.1, 4.2, 0.0);
  222. glRotatef(-2.0 * angle - 25.0, 0.0, 0.0, 1.0);
  223. glCallList(gear3);
  224. glPopMatrix();
  225. glPopMatrix();
  226. }
  227. static void
  228. draw_gears(void)
  229. {
  230. if (stereo) {
  231. /* First left eye. */
  232. glDrawBuffer(GL_BACK_LEFT);
  233. glMatrixMode(GL_PROJECTION);
  234. glLoadIdentity();
  235. glFrustum(left, right, -asp, asp, 5.0, 60.0);
  236. glMatrixMode(GL_MODELVIEW);
  237. glPushMatrix();
  238. glTranslated(+0.5 * eyesep, 0.0, 0.0);
  239. draw();
  240. glPopMatrix();
  241. /* Then right eye. */
  242. glDrawBuffer(GL_BACK_RIGHT);
  243. glMatrixMode(GL_PROJECTION);
  244. glLoadIdentity();
  245. glFrustum(-right, -left, -asp, asp, 5.0, 60.0);
  246. glMatrixMode(GL_MODELVIEW);
  247. glPushMatrix();
  248. glTranslated(-0.5 * eyesep, 0.0, 0.0);
  249. draw();
  250. glPopMatrix();
  251. }
  252. else {
  253. draw();
  254. }
  255. }
  256. /** Draw single frame, do SwapBuffers, compute FPS */
  257. static void
  258. draw_frame(Display *dpy, Window win)
  259. {
  260. static int frames = 0;
  261. static double tRot0 = -1.0, tRate0 = -1.0;
  262. double dt, t = current_time();
  263. if (tRot0 < 0.0)
  264. tRot0 = t;
  265. dt = t - tRot0;
  266. tRot0 = t;
  267. /* advance rotation for next frame */
  268. angle += 70.0 * dt; /* 70 degrees per second */
  269. if (angle > 3600.0)
  270. angle -= 3600.0;
  271. draw_gears();
  272. glXSwapBuffers(dpy, win);
  273. frames++;
  274. if (tRate0 < 0.0)
  275. tRate0 = t;
  276. if (t - tRate0 >= 5.0) {
  277. GLfloat seconds = t - tRate0;
  278. GLfloat fps = frames / seconds;
  279. printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds,
  280. fps);
  281. tRate0 = t;
  282. frames = 0;
  283. }
  284. }
  285. /* new window size or exposure */
  286. static void
  287. reshape(int width, int height)
  288. {
  289. glViewport(0, 0, (GLint) width, (GLint) height);
  290. if (stereo) {
  291. GLfloat w;
  292. asp = (GLfloat) height / (GLfloat) width;
  293. w = fix_point * (1.0 / 5.0);
  294. left = -5.0 * ((w - 0.5 * eyesep) / fix_point);
  295. right = 5.0 * ((w + 0.5 * eyesep) / fix_point);
  296. }
  297. else {
  298. GLfloat h = (GLfloat) height / (GLfloat) width;
  299. glMatrixMode(GL_PROJECTION);
  300. glLoadIdentity();
  301. glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0);
  302. }
  303. glMatrixMode(GL_MODELVIEW);
  304. glLoadIdentity();
  305. glTranslatef(0.0, 0.0, -40.0);
  306. }
  307. static void
  308. init(void)
  309. {
  310. static GLfloat pos[4] = { 5.0, 5.0, 10.0, 0.0 };
  311. static GLfloat red[4] = { 0.8, 0.1, 0.0, 1.0 };
  312. static GLfloat green[4] = { 0.0, 0.8, 0.2, 1.0 };
  313. static GLfloat blue[4] = { 0.2, 0.2, 1.0, 1.0 };
  314. glLightfv(GL_LIGHT0, GL_POSITION, pos);
  315. glEnable(GL_CULL_FACE);
  316. glEnable(GL_LIGHTING);
  317. glEnable(GL_LIGHT0);
  318. glEnable(GL_DEPTH_TEST);
  319. /* make the gears */
  320. gear1 = glGenLists(1);
  321. glNewList(gear1, GL_COMPILE);
  322. glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
  323. gear(1.0, 4.0, 1.0, 20, 0.7);
  324. glEndList();
  325. gear2 = glGenLists(1);
  326. glNewList(gear2, GL_COMPILE);
  327. glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
  328. gear(0.5, 2.0, 2.0, 10, 0.7);
  329. glEndList();
  330. gear3 = glGenLists(1);
  331. glNewList(gear3, GL_COMPILE);
  332. glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
  333. gear(1.3, 2.0, 0.5, 10, 0.7);
  334. glEndList();
  335. glEnable(GL_NORMALIZE);
  336. }
  337. /*
  338. * Create an RGB, double-buffered window.
  339. * Return the window and context handles.
  340. */
  341. static void
  342. make_window( Display *dpy, const char *name,
  343. int x, int y, int width, int height,
  344. Window *winRet, GLXContext *ctxRet)
  345. {
  346. int attribs[] = { GLX_RGBA,
  347. GLX_RED_SIZE, 1,
  348. GLX_GREEN_SIZE, 1,
  349. GLX_BLUE_SIZE, 1,
  350. GLX_DOUBLEBUFFER,
  351. GLX_DEPTH_SIZE, 1,
  352. None };
  353. int stereoAttribs[] = { GLX_RGBA,
  354. GLX_RED_SIZE, 1,
  355. GLX_GREEN_SIZE, 1,
  356. GLX_BLUE_SIZE, 1,
  357. GLX_DOUBLEBUFFER,
  358. GLX_DEPTH_SIZE, 1,
  359. GLX_STEREO,
  360. None };
  361. int scrnum;
  362. XSetWindowAttributes attr;
  363. unsigned long mask;
  364. Window root;
  365. Window win;
  366. GLXContext ctx;
  367. XVisualInfo *visinfo;
  368. scrnum = DefaultScreen( dpy );
  369. root = RootWindow( dpy, scrnum );
  370. if (fullscreen) {
  371. x = 0; y = 0;
  372. width = DisplayWidth( dpy, scrnum );
  373. height = DisplayHeight( dpy, scrnum );
  374. }
  375. if (stereo)
  376. visinfo = glXChooseVisual( dpy, scrnum, stereoAttribs );
  377. else
  378. visinfo = glXChooseVisual( dpy, scrnum, attribs );
  379. if (!visinfo) {
  380. if (stereo) {
  381. printf("Error: couldn't get an RGB, "
  382. "Double-buffered, Stereo visual\n");
  383. } else
  384. printf("Error: couldn't get an RGB, Double-buffered visual\n");
  385. exit(1);
  386. }
  387. /* window attributes */
  388. attr.background_pixel = 0;
  389. attr.border_pixel = 0;
  390. attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone);
  391. attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
  392. attr.override_redirect = fullscreen;
  393. mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask | CWOverrideRedirect;
  394. win = XCreateWindow( dpy, root, x, y, width, height,
  395. 0, visinfo->depth, InputOutput,
  396. visinfo->visual, mask, &attr );
  397. /* set hints and properties */
  398. {
  399. XSizeHints sizehints;
  400. sizehints.x = x;
  401. sizehints.y = y;
  402. sizehints.width = width;
  403. sizehints.height = height;
  404. sizehints.flags = USSize | USPosition;
  405. XSetNormalHints(dpy, win, &sizehints);
  406. XSetStandardProperties(dpy, win, name, name,
  407. None, (char **)NULL, 0, &sizehints);
  408. }
  409. ctx = glXCreateContext( dpy, visinfo, NULL, True );
  410. if (!ctx) {
  411. printf("Error: glXCreateContext failed\n");
  412. exit(1);
  413. }
  414. XFree(visinfo);
  415. *winRet = win;
  416. *ctxRet = ctx;
  417. }
  418. /**
  419. * Handle one X event.
  420. * \return 1 if time to exit, 0 otherwise
  421. */
  422. static int
  423. handle_event(Display *dpy, Window win, XEvent *event)
  424. {
  425. switch (event->type) {
  426. case Expose:
  427. /* we'll redraw below */
  428. break;
  429. case ConfigureNotify:
  430. reshape(event->xconfigure.width, event->xconfigure.height);
  431. break;
  432. case KeyPress:
  433. {
  434. char buffer[10];
  435. int r, code;
  436. code = XLookupKeysym(&event->xkey, 0);
  437. if (code == XK_Left) {
  438. view_roty += 5.0;
  439. }
  440. else if (code == XK_Right) {
  441. view_roty -= 5.0;
  442. }
  443. else if (code == XK_Up) {
  444. view_rotx += 5.0;
  445. }
  446. else if (code == XK_Down) {
  447. view_rotx -= 5.0;
  448. }
  449. else {
  450. r = XLookupString(&event->xkey, buffer, sizeof(buffer),
  451. NULL, NULL);
  452. if (buffer[0] == 27) {
  453. /* escape */
  454. return 1;
  455. }
  456. }
  457. }
  458. }
  459. return 0;
  460. }
  461. static void
  462. event_loop(Display *dpy, Window win)
  463. {
  464. while (1) {
  465. while (XPending(dpy) > 0) {
  466. XEvent event;
  467. XNextEvent(dpy, &event);
  468. if (handle_event(dpy, win, &event))
  469. return;
  470. }
  471. draw_frame(dpy, win);
  472. }
  473. }
  474. static void
  475. usage(void)
  476. {
  477. printf("Usage:\n");
  478. printf(" -display <displayname> set the display to run on\n");
  479. printf(" -stereo run in stereo mode\n");
  480. printf(" -fullscreen run in fullscreen mode\n");
  481. printf(" -info display OpenGL renderer info\n");
  482. printf(" -geometry WxH+X+Y window geometry\n");
  483. }
  484. int
  485. main(int argc, char *argv[])
  486. {
  487. unsigned int winWidth = 300, winHeight = 300;
  488. int x = 0, y = 0;
  489. Display *dpy;
  490. Window win;
  491. GLXContext ctx;
  492. char *dpyName = NULL;
  493. GLboolean printInfo = GL_FALSE;
  494. int i;
  495. for (i = 1; i < argc; i++) {
  496. if (strcmp(argv[i], "-display") == 0) {
  497. dpyName = argv[i+1];
  498. i++;
  499. }
  500. else if (strcmp(argv[i], "-info") == 0) {
  501. printInfo = GL_TRUE;
  502. }
  503. else if (strcmp(argv[i], "-stereo") == 0) {
  504. stereo = GL_TRUE;
  505. }
  506. else if (strcmp(argv[i], "-fullscreen") == 0) {
  507. fullscreen = GL_TRUE;
  508. }
  509. else if (i < argc-1 && strcmp(argv[i], "-geometry") == 0) {
  510. XParseGeometry(argv[i+1], &x, &y, &winWidth, &winHeight);
  511. i++;
  512. }
  513. else {
  514. usage();
  515. return -1;
  516. }
  517. }
  518. dpy = XOpenDisplay(dpyName);
  519. if (!dpy) {
  520. printf("Error: couldn't open display %s\n",
  521. dpyName ? dpyName : getenv("DISPLAY"));
  522. return -1;
  523. }
  524. make_window(dpy, "glxgears", x, y, winWidth, winHeight, &win, &ctx);
  525. XMapWindow(dpy, win);
  526. glXMakeCurrent(dpy, win, ctx);
  527. if (printInfo) {
  528. printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
  529. printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
  530. printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
  531. printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
  532. }
  533. init();
  534. /* Set initial projection/viewing transformation.
  535. * We can't be sure we'll get a ConfigureNotify event when the window
  536. * first appears.
  537. */
  538. reshape(winWidth, winHeight);
  539. event_loop(dpy, win);
  540. glDeleteLists(gear1, 1);
  541. glDeleteLists(gear2, 1);
  542. glDeleteLists(gear3, 1);
  543. glXDestroyContext(dpy, ctx);
  544. XDestroyWindow(dpy, win);
  545. XCloseDisplay(dpy);
  546. return 0;
  547. }