Clone of mesa.
選択できるのは25トピックまでです。 トピックは、先頭が英数字で、英数字とダッシュ('-')を使用した35文字以内のものにしてください。

glxgears_fbconfig.c 16KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602
  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. * \file glxgears_fbconfig.c
  23. * Yet-another-version of gears. Originally ported to GLX by Brian Paul on
  24. * 23 March 2001. Modified to use fbconfigs by Ian Romanick on 10 Feb 2004.
  25. *
  26. * Command line options:
  27. * -info print GL implementation information
  28. *
  29. * \author Brian Paul
  30. * \author Ian Romanick <idr@us.ibm.com>
  31. */
  32. #define GLX_GLXEXT_PROTOTYPES
  33. #include <math.h>
  34. #include <stdlib.h>
  35. #include <stdio.h>
  36. #include <string.h>
  37. #include <X11/Xlib.h>
  38. #include <X11/keysym.h>
  39. #include <GL/gl.h>
  40. #include <GL/glx.h>
  41. #include <GL/glxext.h>
  42. #include <assert.h>
  43. #include "pbutil.h"
  44. /* I had to use the SGIX versions of these because for some reason glxext.h
  45. * doesn't define the core versions if GLX_VERSION_1_3 is defined, and glx.h
  46. * doesn't define them at all. One or both header files is clearly broken.
  47. */
  48. static PFNGLXCHOOSEFBCONFIGSGIXPROC choose_fbconfig = NULL;
  49. static PFNGLXGETVISUALFROMFBCONFIGSGIXPROC get_visual_from_fbconfig = NULL;
  50. static PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC create_new_context = NULL;
  51. #define BENCHMARK
  52. #ifdef BENCHMARK
  53. /* XXX this probably isn't very portable */
  54. #include <sys/time.h>
  55. #include <unistd.h>
  56. /* return current time (in seconds) */
  57. static int
  58. current_time(void)
  59. {
  60. struct timeval tv;
  61. #ifdef __VMS
  62. (void) gettimeofday(&tv, NULL );
  63. #else
  64. struct timezone tz;
  65. (void) gettimeofday(&tv, &tz);
  66. #endif
  67. return (int) tv.tv_sec;
  68. }
  69. #else /*BENCHMARK*/
  70. /* dummy */
  71. static int
  72. current_time(void)
  73. {
  74. return 0;
  75. }
  76. #endif /*BENCHMARK*/
  77. #ifndef M_PI
  78. #define M_PI 3.14159265
  79. #endif
  80. static GLfloat view_rotx = 20.0, view_roty = 30.0, view_rotz = 0.0;
  81. static GLint gear1, gear2, gear3;
  82. static GLfloat angle = 0.0;
  83. /*
  84. *
  85. * Draw a gear wheel. You'll probably want to call this function when
  86. * building a display list since we do a lot of trig here.
  87. *
  88. * Input: inner_radius - radius of hole at center
  89. * outer_radius - radius at center of teeth
  90. * width - width of gear
  91. * teeth - number of teeth
  92. * tooth_depth - depth of tooth
  93. */
  94. static void
  95. gear(GLfloat inner_radius, GLfloat outer_radius, GLfloat width,
  96. GLint teeth, GLfloat tooth_depth)
  97. {
  98. GLint i;
  99. GLfloat r0, r1, r2;
  100. GLfloat angle, da;
  101. GLfloat u, v, len;
  102. r0 = inner_radius;
  103. r1 = outer_radius - tooth_depth / 2.0;
  104. r2 = outer_radius + tooth_depth / 2.0;
  105. da = 2.0 * M_PI / teeth / 4.0;
  106. glShadeModel(GL_FLAT);
  107. glNormal3f(0.0, 0.0, 1.0);
  108. /* draw front face */
  109. glBegin(GL_QUAD_STRIP);
  110. for (i = 0; i <= teeth; i++) {
  111. angle = i * 2.0 * M_PI / teeth;
  112. glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
  113. glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
  114. if (i < teeth) {
  115. glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
  116. glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
  117. width * 0.5);
  118. }
  119. }
  120. glEnd();
  121. /* draw front sides of teeth */
  122. glBegin(GL_QUADS);
  123. da = 2.0 * M_PI / teeth / 4.0;
  124. for (i = 0; i < teeth; i++) {
  125. angle = i * 2.0 * M_PI / teeth;
  126. glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
  127. glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5);
  128. glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
  129. width * 0.5);
  130. glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
  131. width * 0.5);
  132. }
  133. glEnd();
  134. glNormal3f(0.0, 0.0, -1.0);
  135. /* draw back face */
  136. glBegin(GL_QUAD_STRIP);
  137. for (i = 0; i <= teeth; i++) {
  138. angle = i * 2.0 * M_PI / teeth;
  139. glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
  140. glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
  141. if (i < teeth) {
  142. glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
  143. -width * 0.5);
  144. glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
  145. }
  146. }
  147. glEnd();
  148. /* draw back sides of teeth */
  149. glBegin(GL_QUADS);
  150. da = 2.0 * M_PI / teeth / 4.0;
  151. for (i = 0; i < teeth; i++) {
  152. angle = i * 2.0 * M_PI / teeth;
  153. glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
  154. -width * 0.5);
  155. glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
  156. -width * 0.5);
  157. glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
  158. glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
  159. }
  160. glEnd();
  161. /* draw outward faces of teeth */
  162. glBegin(GL_QUAD_STRIP);
  163. for (i = 0; i < teeth; i++) {
  164. angle = i * 2.0 * M_PI / teeth;
  165. glVertex3f(r1 * cos(angle), r1 * sin(angle), width * 0.5);
  166. glVertex3f(r1 * cos(angle), r1 * sin(angle), -width * 0.5);
  167. u = r2 * cos(angle + da) - r1 * cos(angle);
  168. v = r2 * sin(angle + da) - r1 * sin(angle);
  169. len = sqrt(u * u + v * v);
  170. u /= len;
  171. v /= len;
  172. glNormal3f(v, -u, 0.0);
  173. glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), width * 0.5);
  174. glVertex3f(r2 * cos(angle + da), r2 * sin(angle + da), -width * 0.5);
  175. glNormal3f(cos(angle), sin(angle), 0.0);
  176. glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
  177. width * 0.5);
  178. glVertex3f(r2 * cos(angle + 2 * da), r2 * sin(angle + 2 * da),
  179. -width * 0.5);
  180. u = r1 * cos(angle + 3 * da) - r2 * cos(angle + 2 * da);
  181. v = r1 * sin(angle + 3 * da) - r2 * sin(angle + 2 * da);
  182. glNormal3f(v, -u, 0.0);
  183. glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
  184. width * 0.5);
  185. glVertex3f(r1 * cos(angle + 3 * da), r1 * sin(angle + 3 * da),
  186. -width * 0.5);
  187. glNormal3f(cos(angle), sin(angle), 0.0);
  188. }
  189. glVertex3f(r1 * cos(0), r1 * sin(0), width * 0.5);
  190. glVertex3f(r1 * cos(0), r1 * sin(0), -width * 0.5);
  191. glEnd();
  192. glShadeModel(GL_SMOOTH);
  193. /* draw inside radius cylinder */
  194. glBegin(GL_QUAD_STRIP);
  195. for (i = 0; i <= teeth; i++) {
  196. angle = i * 2.0 * M_PI / teeth;
  197. glNormal3f(-cos(angle), -sin(angle), 0.0);
  198. glVertex3f(r0 * cos(angle), r0 * sin(angle), -width * 0.5);
  199. glVertex3f(r0 * cos(angle), r0 * sin(angle), width * 0.5);
  200. }
  201. glEnd();
  202. }
  203. static void
  204. draw(void)
  205. {
  206. glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT);
  207. glPushMatrix();
  208. glRotatef(view_rotx, 1.0, 0.0, 0.0);
  209. glRotatef(view_roty, 0.0, 1.0, 0.0);
  210. glRotatef(view_rotz, 0.0, 0.0, 1.0);
  211. glPushMatrix();
  212. glTranslatef(-3.0, -2.0, 0.0);
  213. glRotatef(angle, 0.0, 0.0, 1.0);
  214. glCallList(gear1);
  215. glPopMatrix();
  216. glPushMatrix();
  217. glTranslatef(3.1, -2.0, 0.0);
  218. glRotatef(-2.0 * angle - 9.0, 0.0, 0.0, 1.0);
  219. glCallList(gear2);
  220. glPopMatrix();
  221. glPushMatrix();
  222. glTranslatef(-3.1, 4.2, 0.0);
  223. glRotatef(-2.0 * angle - 25.0, 0.0, 0.0, 1.0);
  224. glCallList(gear3);
  225. glPopMatrix();
  226. glPopMatrix();
  227. }
  228. /* new window size or exposure */
  229. static void
  230. reshape(int width, int height)
  231. {
  232. GLfloat h = (GLfloat) height / (GLfloat) width;
  233. glViewport(0, 0, (GLint) width, (GLint) height);
  234. glMatrixMode(GL_PROJECTION);
  235. glLoadIdentity();
  236. glFrustum(-1.0, 1.0, -h, h, 5.0, 60.0);
  237. glMatrixMode(GL_MODELVIEW);
  238. glLoadIdentity();
  239. glTranslatef(0.0, 0.0, -40.0);
  240. }
  241. static void
  242. init(void)
  243. {
  244. static GLfloat pos[4] = { 5.0, 5.0, 10.0, 0.0 };
  245. static GLfloat red[4] = { 0.8, 0.1, 0.0, 1.0 };
  246. static GLfloat green[4] = { 0.0, 0.8, 0.2, 1.0 };
  247. static GLfloat blue[4] = { 0.2, 0.2, 1.0, 1.0 };
  248. glLightfv(GL_LIGHT0, GL_POSITION, pos);
  249. glEnable(GL_CULL_FACE);
  250. glEnable(GL_LIGHTING);
  251. glEnable(GL_LIGHT0);
  252. glEnable(GL_DEPTH_TEST);
  253. /* make the gears */
  254. gear1 = glGenLists(1);
  255. glNewList(gear1, GL_COMPILE);
  256. glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, red);
  257. gear(1.0, 4.0, 1.0, 20, 0.7);
  258. glEndList();
  259. gear2 = glGenLists(1);
  260. glNewList(gear2, GL_COMPILE);
  261. glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, green);
  262. gear(0.5, 2.0, 2.0, 10, 0.7);
  263. glEndList();
  264. gear3 = glGenLists(1);
  265. glNewList(gear3, GL_COMPILE);
  266. glMaterialfv(GL_FRONT, GL_AMBIENT_AND_DIFFUSE, blue);
  267. gear(1.3, 2.0, 0.5, 10, 0.7);
  268. glEndList();
  269. glEnable(GL_NORMALIZE);
  270. }
  271. /**
  272. * Initialize fbconfig related function pointers.
  273. */
  274. static void
  275. init_fbconfig_functions(Display *dpy, int scrnum)
  276. {
  277. const char * glx_extensions;
  278. const char * match;
  279. static const char ext_name[] = "GLX_SGIX_fbconfig";
  280. const size_t len = strlen( ext_name );
  281. int major;
  282. int minor;
  283. GLboolean ext_version_supported;
  284. GLboolean glx_1_3_supported;
  285. /* Determine if GLX 1.3 or greater is supported.
  286. */
  287. glXQueryVersion(dpy, & major, & minor);
  288. glx_1_3_supported = (major == 1) && (minor >= 3);
  289. /* Determine if GLX_SGIX_fbconfig is supported.
  290. */
  291. glx_extensions = glXQueryExtensionsString(dpy, scrnum);
  292. match = strstr( glx_extensions, ext_name );
  293. ext_version_supported = (match != NULL)
  294. && ((match[len] == '\0') || (match[len] == ' '));
  295. printf( "GLX 1.3 is %ssupported.\n",
  296. (glx_1_3_supported) ? "" : "not " );
  297. printf( "%s is %ssupported.\n",
  298. ext_name, (ext_version_supported) ? "" : "not " );
  299. if ( glx_1_3_supported ) {
  300. choose_fbconfig = (PFNGLXCHOOSEFBCONFIGSGIXPROC) glXGetProcAddressARB(
  301. (GLubyte *) "glXChooseFBConfig");
  302. get_visual_from_fbconfig = (PFNGLXGETVISUALFROMFBCONFIGSGIXPROC) glXGetProcAddressARB(
  303. (GLubyte *) "glXGetVisualFromFBConfig");
  304. create_new_context = (PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC) glXGetProcAddressARB(
  305. (GLubyte *) "glXCreateNewContext");
  306. }
  307. else if ( ext_version_supported ) {
  308. choose_fbconfig = (PFNGLXCHOOSEFBCONFIGSGIXPROC) glXGetProcAddressARB(
  309. (GLubyte *) "glXChooseFBConfigSGIX");
  310. get_visual_from_fbconfig = (PFNGLXGETVISUALFROMFBCONFIGSGIXPROC) glXGetProcAddressARB(
  311. (GLubyte *) "glXGetVisualFromFBConfigSGIX");
  312. create_new_context = (PFNGLXCREATECONTEXTWITHCONFIGSGIXPROC) glXGetProcAddressARB(
  313. (GLubyte *) "glXCreateContextWithConfigSGIX");
  314. }
  315. else {
  316. printf( "This demo requires either GLX 1.3 or %s be supported.\n",
  317. ext_name );
  318. exit(1);
  319. }
  320. if ( choose_fbconfig == NULL ) {
  321. printf( "glXChooseFBConfig not found!\n" );
  322. exit(1);
  323. }
  324. if ( get_visual_from_fbconfig == NULL ) {
  325. printf( "glXGetVisualFromFBConfig not found!\n" );
  326. exit(1);
  327. }
  328. if ( create_new_context == NULL ) {
  329. printf( "glXCreateNewContext not found!\n" );
  330. exit(1);
  331. }
  332. }
  333. /*
  334. * Create an RGB, double-buffered window.
  335. * Return the window and context handles.
  336. */
  337. static void
  338. make_window( Display *dpy, const char *name,
  339. int x, int y, int width, int height,
  340. Window *winRet, GLXContext *ctxRet)
  341. {
  342. int attrib[] = { GLX_DRAWABLE_TYPE, GLX_WINDOW_BIT,
  343. GLX_RENDER_TYPE, GLX_RGBA_BIT,
  344. GLX_RED_SIZE, 1,
  345. GLX_GREEN_SIZE, 1,
  346. GLX_BLUE_SIZE, 1,
  347. GLX_DOUBLEBUFFER, GL_TRUE,
  348. GLX_DEPTH_SIZE, 1,
  349. None };
  350. GLXFBConfig * fbconfig;
  351. int num_configs;
  352. int scrnum;
  353. int i;
  354. XSetWindowAttributes attr;
  355. unsigned long mask;
  356. Window root;
  357. Window win;
  358. GLXContext ctx;
  359. XVisualInfo *visinfo;
  360. scrnum = DefaultScreen( dpy );
  361. root = RootWindow( dpy, scrnum );
  362. init_fbconfig_functions(dpy, scrnum);
  363. fbconfig = (*choose_fbconfig)(dpy, scrnum, attrib, & num_configs);
  364. if (fbconfig == NULL) {
  365. printf("Error: couldn't get an RGB, Double-buffered visual\n");
  366. exit(1);
  367. }
  368. printf("\nThe following fbconfigs meet the requirements. The first one "
  369. "will be used.\n\n");
  370. for ( i = 0 ; i < num_configs ; i++ ) {
  371. PrintFBConfigInfo(dpy, scrnum, fbconfig[i], GL_TRUE);
  372. }
  373. /* window attributes */
  374. visinfo = (*get_visual_from_fbconfig)(dpy, fbconfig[0]);
  375. assert(visinfo != NULL);
  376. attr.background_pixel = 0;
  377. attr.border_pixel = 0;
  378. attr.colormap = XCreateColormap( dpy, root, visinfo->visual, AllocNone);
  379. attr.event_mask = StructureNotifyMask | ExposureMask | KeyPressMask;
  380. mask = CWBackPixel | CWBorderPixel | CWColormap | CWEventMask;
  381. win = XCreateWindow( dpy, root, 0, 0, width, height,
  382. 0, visinfo->depth, InputOutput,
  383. visinfo->visual, mask, &attr );
  384. /* set hints and properties */
  385. {
  386. XSizeHints sizehints;
  387. sizehints.x = x;
  388. sizehints.y = y;
  389. sizehints.width = width;
  390. sizehints.height = height;
  391. sizehints.flags = USSize | USPosition;
  392. XSetNormalHints(dpy, win, &sizehints);
  393. XSetStandardProperties(dpy, win, name, name,
  394. None, (char **)NULL, 0, &sizehints);
  395. }
  396. ctx = (*create_new_context)(dpy, fbconfig[0], GLX_RGBA_TYPE, NULL, GL_TRUE);
  397. if (!ctx) {
  398. printf("Error: glXCreateNewContext failed\n");
  399. exit(1);
  400. }
  401. XFree(fbconfig);
  402. *winRet = win;
  403. *ctxRet = ctx;
  404. }
  405. static void
  406. event_loop(Display *dpy, Window win)
  407. {
  408. while (1) {
  409. while (XPending(dpy) > 0) {
  410. XEvent event;
  411. XNextEvent(dpy, &event);
  412. switch (event.type) {
  413. case Expose:
  414. /* we'll redraw below */
  415. break;
  416. case ConfigureNotify:
  417. reshape(event.xconfigure.width, event.xconfigure.height);
  418. break;
  419. case KeyPress:
  420. {
  421. char buffer[10];
  422. int r, code;
  423. code = XLookupKeysym(&event.xkey, 0);
  424. if (code == XK_Left) {
  425. view_roty += 5.0;
  426. }
  427. else if (code == XK_Right) {
  428. view_roty -= 5.0;
  429. }
  430. else if (code == XK_Up) {
  431. view_rotx += 5.0;
  432. }
  433. else if (code == XK_Down) {
  434. view_rotx -= 5.0;
  435. }
  436. else {
  437. r = XLookupString(&event.xkey, buffer, sizeof(buffer),
  438. NULL, NULL);
  439. if (buffer[0] == 27) {
  440. /* escape */
  441. return;
  442. }
  443. }
  444. }
  445. }
  446. }
  447. /* next frame */
  448. angle += 2.0;
  449. draw();
  450. glXSwapBuffers(dpy, win);
  451. /* calc framerate */
  452. {
  453. static int t0 = -1;
  454. static int frames = 0;
  455. int t = current_time();
  456. if (t0 < 0)
  457. t0 = t;
  458. frames++;
  459. if (t - t0 >= 5.0) {
  460. GLfloat seconds = t - t0;
  461. GLfloat fps = frames / seconds;
  462. printf("%d frames in %3.1f seconds = %6.3f FPS\n", frames, seconds,
  463. fps);
  464. t0 = t;
  465. frames = 0;
  466. }
  467. }
  468. }
  469. }
  470. int
  471. main(int argc, char *argv[])
  472. {
  473. Display *dpy;
  474. Window win;
  475. GLXContext ctx;
  476. const char *dpyName = NULL;
  477. GLboolean printInfo = GL_FALSE;
  478. int i;
  479. for (i = 1; i < argc; i++) {
  480. if (strcmp(argv[i], "-display") == 0) {
  481. dpyName = argv[i+1];
  482. i++;
  483. }
  484. else if (strcmp(argv[i], "-info") == 0) {
  485. printInfo = GL_TRUE;
  486. }
  487. }
  488. dpy = XOpenDisplay(dpyName);
  489. if (!dpy) {
  490. printf("Error: couldn't open display %s\n", XDisplayName(dpyName));
  491. return -1;
  492. }
  493. make_window(dpy, "glxgears", 0, 0, 300, 300, &win, &ctx);
  494. XMapWindow(dpy, win);
  495. glXMakeCurrent(dpy, win, ctx);
  496. if (printInfo) {
  497. printf("GL_RENDERER = %s\n", (char *) glGetString(GL_RENDERER));
  498. printf("GL_VERSION = %s\n", (char *) glGetString(GL_VERSION));
  499. printf("GL_VENDOR = %s\n", (char *) glGetString(GL_VENDOR));
  500. printf("GL_EXTENSIONS = %s\n", (char *) glGetString(GL_EXTENSIONS));
  501. }
  502. init();
  503. event_loop(dpy, win);
  504. glXDestroyContext(dpy, ctx);
  505. XDestroyWindow(dpy, win);
  506. XCloseDisplay(dpy);
  507. return 0;
  508. }