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.
 
 
 
 
 
 

640 lignes
17 KiB

  1. /*
  2. * libcaca Colour ASCII-Art library
  3. * Copyright (c) 2002-2006 Sam Hocevar <sam@zoy.org>
  4. * All Rights Reserved
  5. *
  6. * $Id$
  7. *
  8. * This library is free software; you can redistribute it and/or
  9. * modify it under the terms of the Do What The Fuck You Want To
  10. * Public License, Version 2, as published by Sam Hocevar. See
  11. * http://sam.zoy.org/wtfpl/COPYING for more details.
  12. */
  13. /*
  14. * This file contains the libcaca OpenGL input and output driver
  15. */
  16. #include "config.h"
  17. #include "common.h"
  18. #if defined(USE_GL)
  19. #ifdef HAVE_OPENGL_GL_H
  20. # include <OpenGL/gl.h>
  21. # include <GLUT/glut.h>
  22. #else
  23. # include <GL/gl.h>
  24. # include <GL/glut.h>
  25. # include <GL/freeglut_ext.h>
  26. #endif
  27. #include <string.h>
  28. #include <stdlib.h>
  29. #include <stdio.h>
  30. #include "caca.h"
  31. #include "caca_internals.h"
  32. #include "cucul.h"
  33. #include "cucul_internals.h"
  34. /*
  35. * Global variables
  36. */
  37. static caca_display_t *gl_d; /* FIXME: we ought to get rid of this */
  38. /*
  39. * Local functions
  40. */
  41. static void gl_handle_keyboard(unsigned char, int, int);
  42. static void gl_handle_special_key(int, int, int);
  43. static void gl_handle_reshape(int, int);
  44. static void gl_handle_mouse(int, int, int, int);
  45. static void gl_handle_mouse_motion(int, int);
  46. #ifdef HAVE_GLUTCLOSEFUNC
  47. static void gl_handle_close(void);
  48. #endif
  49. static void _display(void);
  50. struct driver_private
  51. {
  52. int window;
  53. unsigned int width, height;
  54. unsigned int new_width, new_height;
  55. float font_width, font_height;
  56. float incx, incy;
  57. int id[(128 - 32)];
  58. int id_uni[8]; /* Hack, fixme*/
  59. unsigned char close;
  60. unsigned char bit;
  61. unsigned char mouse_changed, mouse_clicked;
  62. unsigned int mouse_x, mouse_y;
  63. unsigned int mouse_button, mouse_state;
  64. unsigned char key;
  65. int special_key;
  66. float sw, sh;
  67. };
  68. static int gl_init_graphics(caca_display_t *dp)
  69. {
  70. char *empty_texture;
  71. char const *geometry;
  72. char *argv[2] = { "", NULL };
  73. unsigned int width = 0, height = 0;
  74. int argc = 1;
  75. int i;
  76. dp->drv.p = malloc(sizeof(struct driver_private));
  77. gl_d = dp;
  78. #if defined(HAVE_GETENV)
  79. geometry = getenv("CACA_GEOMETRY");
  80. if(geometry && *geometry)
  81. sscanf(geometry, "%ux%u", &width, &height);
  82. #endif
  83. if(width && height)
  84. _cucul_set_canvas_size(dp->cv, width, height);
  85. dp->drv.p->font_width = 9;
  86. dp->drv.p->font_height = 15;
  87. dp->drv.p->width = dp->cv->width * dp->drv.p->font_width;
  88. dp->drv.p->height = dp->cv->height * dp->drv.p->font_height;
  89. #ifdef HAVE_GLUTCLOSEFUNC
  90. dp->drv.p->close = 0;
  91. #endif
  92. dp->drv.p->bit = 0;
  93. dp->drv.p->mouse_changed = dp->drv.p->mouse_clicked = 0;
  94. dp->drv.p->mouse_button = dp->drv.p->mouse_state = 0;
  95. dp->drv.p->key = 0;
  96. dp->drv.p->special_key = 0;
  97. dp->drv.p->sw = 9.0f / 16.0f;
  98. dp->drv.p->sh = 15.0f / 16.0f;
  99. glutInit(&argc, argv);
  100. glutInitDisplayMode(GLUT_RGB | GLUT_DOUBLE);
  101. glutInitWindowSize(dp->drv.p->width, dp->drv.p->height);
  102. dp->drv.p->window = glutCreateWindow("caca for GL");
  103. gluOrtho2D(0, dp->drv.p->width, dp->drv.p->height, 0);
  104. glDisable(GL_CULL_FACE);
  105. glDisable(GL_DEPTH_TEST);
  106. glutKeyboardFunc(gl_handle_keyboard);
  107. glutSpecialFunc(gl_handle_special_key);
  108. glutReshapeFunc(gl_handle_reshape);
  109. glutDisplayFunc(_display);
  110. #ifdef HAVE_GLUTCLOSEFUNC
  111. glutCloseFunc(gl_handle_close);
  112. #endif
  113. glutMouseFunc(gl_handle_mouse);
  114. glutMotionFunc(gl_handle_mouse_motion);
  115. glutPassiveMotionFunc(gl_handle_mouse_motion);
  116. glLoadIdentity();
  117. glMatrixMode(GL_PROJECTION);
  118. glPushMatrix();
  119. glLoadIdentity();
  120. gluOrtho2D(0, dp->drv.p->width, dp->drv.p->height, 0);
  121. glMatrixMode(GL_MODELVIEW);
  122. glClear(GL_COLOR_BUFFER_BIT);
  123. empty_texture = malloc(16 * 16 * 4);
  124. if(empty_texture == NULL)
  125. return -1;
  126. memset(empty_texture, 0xff, 16 * 16 * 4);
  127. glEnable(GL_TEXTURE_2D);
  128. for(i = 32; i < 128; i++)
  129. {
  130. glGenTextures(1, (GLuint*)&dp->drv.p->id[i - 32]);
  131. glBindTexture(GL_TEXTURE_2D, dp->drv.p->id[i - 32]);
  132. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  133. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  134. glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8,
  135. 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, empty_texture);
  136. }
  137. for(i = 0; i < 8; i++)
  138. {
  139. glGenTextures(1, (GLuint*)&dp->drv.p->id_uni[i]);
  140. glBindTexture(GL_TEXTURE_2D, dp->drv.p->id_uni[i]);
  141. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, GL_LINEAR);
  142. glTexParameteri(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, GL_LINEAR);
  143. glTexImage2D(GL_TEXTURE_2D, 0, GL_RGB8,
  144. 16, 16, 0, GL_RGB, GL_UNSIGNED_BYTE, empty_texture);
  145. }
  146. for(i = 32; i < 128; i++)
  147. {
  148. glDisable(GL_TEXTURE_2D);
  149. glClear(GL_COLOR_BUFFER_BIT);
  150. glColor3f(1, 1, 1);
  151. glRasterPos2f(0, 15);
  152. glutBitmapCharacter(GLUT_BITMAP_9_BY_15, i);
  153. glEnable(GL_TEXTURE_2D);
  154. glBindTexture(GL_TEXTURE_2D, dp->drv.p->id[i - 32]);
  155. glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
  156. 0, dp->drv.p->height - 16, 16, 16, 0);
  157. #ifdef HAVE_GLUTCHECKLOOP
  158. glutCheckLoop();
  159. #else
  160. glutMainLoopEvent();
  161. #endif
  162. glutSwapBuffers();
  163. }
  164. /* CP437 hack */
  165. for(i = 0; i < 8; i++)
  166. {
  167. glDisable(GL_TEXTURE_2D);
  168. glClear(GL_COLOR_BUFFER_BIT);
  169. glColor3f(1, 1, 1);
  170. glTranslatef(0.5,0.5,0);
  171. if(i==0) /* 0x00002580*/
  172. {
  173. glBegin(GL_QUADS);
  174. glVertex2f(0,0); glVertex2f(9,0); glVertex2f(9,7); glVertex2f(0,7);
  175. glEnd();
  176. }
  177. else if(i==1) /* 0x00002584*/
  178. {
  179. glBegin(GL_QUADS);
  180. glVertex2f(0,7); glVertex2f(9,7); glVertex2f(9,15); glVertex2f(0,15);
  181. glEnd();
  182. }
  183. else if(i==2) /* 0x00002588*/
  184. {
  185. glBegin(GL_QUADS);
  186. glVertex2f(0,0); glVertex2f(9,0); glVertex2f(9,15); glVertex2f(0,15);
  187. glEnd();
  188. }
  189. else if(i==3) /* 0x0000258c*/
  190. {
  191. glBegin(GL_QUADS);
  192. glVertex2f(0,0); glVertex2f(4,0); glVertex2f(4,15); glVertex2f(0,15);
  193. glEnd();
  194. }
  195. else if(i==4) /* 0x00002590*/
  196. {
  197. glBegin(GL_QUADS);
  198. glVertex2f(4,0); glVertex2f(9,0); glVertex2f(9,15); glVertex2f(4,15);
  199. glEnd();
  200. }
  201. else if(i>=5) /* 0x00002591*/
  202. {
  203. int a, j, k = i-5;
  204. for(j = dp->drv.p->font_height; j--; )
  205. for(a = dp->drv.p->font_width; a--; )
  206. {
  207. if(((a + 2 * (j & 1)) & 3) > k)
  208. continue;
  209. glBegin(GL_POINTS);
  210. glVertex2f(a, j);
  211. glEnd();
  212. }
  213. }
  214. glEnable(GL_TEXTURE_2D);
  215. glBindTexture(GL_TEXTURE_2D, dp->drv.p->id_uni[i]);
  216. glCopyTexImage2D(GL_TEXTURE_2D, 0, GL_RGB,
  217. 0, dp->drv.p->height - 16, 16, 16, 0);
  218. #ifdef HAVE_GLUTCHECKLOOP
  219. glutCheckLoop();
  220. #else
  221. glutMainLoopEvent();
  222. #endif
  223. glutSwapBuffers();
  224. glutPostRedisplay();
  225. }
  226. return 0;
  227. }
  228. static int gl_end_graphics(caca_display_t *dp)
  229. {
  230. glutDestroyWindow(dp->drv.p->window);
  231. free(dp->drv.p);
  232. return 0;
  233. }
  234. static int gl_set_display_title(caca_display_t *dp, char const *title)
  235. {
  236. glutSetWindowTitle(title);
  237. return 0;
  238. }
  239. static unsigned int gl_get_display_width(caca_display_t *dp)
  240. {
  241. return dp->drv.p->width;
  242. }
  243. static unsigned int gl_get_display_height(caca_display_t *dp)
  244. {
  245. return dp->drv.p->height;
  246. }
  247. static void gl_display(caca_display_t *dp)
  248. {
  249. unsigned int x, y, line;
  250. glClear(GL_COLOR_BUFFER_BIT);
  251. line = 0;
  252. for(y = 0; y < dp->drv.p->height; y += dp->drv.p->font_height)
  253. {
  254. uint32_t *attr = dp->cv->attr + line * dp->cv->width;
  255. for(x = 0; x < dp->drv.p->width; x += dp->drv.p->font_width)
  256. {
  257. uint16_t bg = _cucul_argb32_to_rgb12bg(*attr++);
  258. glDisable(GL_TEXTURE_2D);
  259. glColor3b(((bg & 0xf00) >> 8) * 8,
  260. ((bg & 0x0f0) >> 4) * 8,
  261. (bg & 0x00f) * 8);
  262. glBegin(GL_QUADS);
  263. glVertex2f(x, y);
  264. glVertex2f(x + dp->drv.p->font_width, y);
  265. glVertex2f(x + dp->drv.p->font_width,
  266. y + dp->drv.p->font_height);
  267. glVertex2f(x, y + dp->drv.p->font_height);
  268. glEnd();
  269. }
  270. line++;
  271. }
  272. /* 2nd pass, avoids changing render state too much */
  273. glEnable(GL_BLEND);
  274. glEnable(GL_TEXTURE_2D);
  275. glBlendFunc(GL_ONE, GL_ONE);
  276. line = 0;
  277. for(y = 0; y < dp->drv.p->height; y += dp->drv.p->font_height)
  278. {
  279. uint32_t *attr = dp->cv->attr + line * dp->cv->width;
  280. uint32_t *chars = dp->cv->chars + line * dp->cv->width;
  281. for(x = 0; x < dp->drv.p->width; x += dp->drv.p->font_width)
  282. {
  283. uint32_t cv = *chars++;
  284. if(cv > 0x00000020 && cv < 0x00000080)
  285. {
  286. uint16_t fg = _cucul_argb32_to_rgb12fg(*attr);
  287. glBindTexture(GL_TEXTURE_2D, dp->drv.p->id[cv - 32]);
  288. glColor3b(((fg & 0xf00) >> 8) * 8,
  289. ((fg & 0x0f0) >> 4) * 8,
  290. (fg & 0x00f) * 8);
  291. glBegin(GL_QUADS);
  292. glTexCoord2f(0, dp->drv.p->sh);
  293. glVertex2f(x, y);
  294. glTexCoord2f(dp->drv.p->sw, dp->drv.p->sh);
  295. glVertex2f(x + dp->drv.p->font_width, y);
  296. glTexCoord2f(dp->drv.p->sw, 0);
  297. glVertex2f(x + dp->drv.p->font_width,
  298. y + dp->drv.p->font_height);
  299. glTexCoord2f(0, 0);
  300. glVertex2f(x, y + dp->drv.p->font_height);
  301. glEnd();
  302. }
  303. else if(cv!=' ')
  304. {
  305. switch(cv)
  306. {
  307. case 0x00002580: glBindTexture(GL_TEXTURE_2D, dp->drv.p->id_uni[0]); break;
  308. case 0x00002584: glBindTexture(GL_TEXTURE_2D, dp->drv.p->id_uni[1]); break;
  309. case 0x00002588: glBindTexture(GL_TEXTURE_2D, dp->drv.p->id_uni[2]); break;
  310. case 0x0000258c: glBindTexture(GL_TEXTURE_2D, dp->drv.p->id_uni[3]); break;
  311. case 0x00002590: glBindTexture(GL_TEXTURE_2D, dp->drv.p->id_uni[4]); break;
  312. case 0x00002591: glBindTexture(GL_TEXTURE_2D, dp->drv.p->id_uni[5]); break;
  313. case 0x00002592: glBindTexture(GL_TEXTURE_2D, dp->drv.p->id_uni[6]); break;
  314. case 0x00002593: glBindTexture(GL_TEXTURE_2D, dp->drv.p->id_uni[7]); break;
  315. default: glBindTexture(GL_TEXTURE_2D, dp->drv.p->id['?' - 32]); break;
  316. }
  317. uint16_t fg = _cucul_argb32_to_rgb12fg(*attr);
  318. glColor3b(((fg & 0xf00) >> 8) * 8,
  319. ((fg & 0x0f0) >> 4) * 8,
  320. (fg & 0x00f) * 8);
  321. glBegin(GL_QUADS);
  322. glTexCoord2f(0, dp->drv.p->sh);
  323. glVertex2f(x, y);
  324. glTexCoord2f(dp->drv.p->sw, dp->drv.p->sh);
  325. glVertex2f(x + dp->drv.p->font_width, y);
  326. glTexCoord2f(dp->drv.p->sw, 0);
  327. glVertex2f(x + dp->drv.p->font_width,
  328. y + dp->drv.p->font_height);
  329. glTexCoord2f(0, 0);
  330. glVertex2f(x, y + dp->drv.p->font_height);
  331. glEnd();
  332. }
  333. attr++;
  334. }
  335. line++;
  336. }
  337. glDisable(GL_BLEND);
  338. glDisable(GL_TEXTURE_2D);
  339. #ifdef HAVE_GLUTCHECKLOOP
  340. glutCheckLoop();
  341. #else
  342. glutMainLoopEvent();
  343. #endif
  344. glutSwapBuffers();
  345. glutPostRedisplay();
  346. }
  347. static void gl_handle_resize(caca_display_t *dp)
  348. {
  349. dp->drv.p->width = dp->drv.p->new_width;
  350. dp->drv.p->height = dp->drv.p->new_height;
  351. glMatrixMode(GL_PROJECTION);
  352. glPushMatrix();
  353. glLoadIdentity();
  354. glViewport(0, 0, dp->drv.p->width, dp->drv.p->height);
  355. gluOrtho2D(0, dp->drv.p->width, dp->drv.p->height, 0);
  356. glMatrixMode(GL_MODELVIEW);
  357. }
  358. static int gl_get_event(caca_display_t *dp, caca_event_t *ev)
  359. {
  360. #ifdef HAVE_GLUTCHECKLOOP
  361. glutCheckLoop();
  362. #else
  363. glutMainLoopEvent();
  364. #endif
  365. #ifdef HAVE_GLUTCLOSEFUNC
  366. if(dp->drv.p->close)
  367. {
  368. dp->drv.p->close = 0;
  369. ev->type = CACA_EVENT_QUIT;
  370. return 1;
  371. }
  372. #endif
  373. if(dp->resize.resized)
  374. {
  375. ev->type = CACA_EVENT_RESIZE;
  376. ev->data.resize.w = dp->cv->width;
  377. ev->data.resize.h = dp->cv->height;
  378. return 1;
  379. }
  380. if(dp->drv.p->mouse_changed)
  381. {
  382. ev->type = CACA_EVENT_MOUSE_MOTION;
  383. ev->data.mouse.x = dp->mouse.x;
  384. ev->data.mouse.y = dp->mouse.y;
  385. dp->drv.p->mouse_changed = 0;
  386. if(dp->drv.p->mouse_clicked)
  387. {
  388. _push_event(dp, ev);
  389. ev->type = CACA_EVENT_MOUSE_PRESS;
  390. ev->data.mouse.button = dp->drv.p->mouse_button;
  391. dp->drv.p->mouse_clicked = 0;
  392. }
  393. return 1;
  394. }
  395. if(dp->drv.p->key != 0)
  396. {
  397. ev->type = CACA_EVENT_KEY_PRESS;
  398. ev->data.key.ch = dp->drv.p->key;
  399. ev->data.key.ucs4 = (uint32_t)dp->drv.p->key;
  400. ev->data.key.utf8[0] = dp->drv.p->key;
  401. ev->data.key.utf8[1] = '\0';
  402. dp->drv.p->key = 0;
  403. return 1;
  404. }
  405. if(dp->drv.p->special_key != 0)
  406. {
  407. switch(dp->drv.p->special_key)
  408. {
  409. case GLUT_KEY_F1 : ev->data.key.ch = CACA_KEY_F1; break;
  410. case GLUT_KEY_F2 : ev->data.key.ch = CACA_KEY_F2; break;
  411. case GLUT_KEY_F3 : ev->data.key.ch = CACA_KEY_F3; break;
  412. case GLUT_KEY_F4 : ev->data.key.ch = CACA_KEY_F4; break;
  413. case GLUT_KEY_F5 : ev->data.key.ch = CACA_KEY_F5; break;
  414. case GLUT_KEY_F6 : ev->data.key.ch = CACA_KEY_F6; break;
  415. case GLUT_KEY_F7 : ev->data.key.ch = CACA_KEY_F7; break;
  416. case GLUT_KEY_F8 : ev->data.key.ch = CACA_KEY_F8; break;
  417. case GLUT_KEY_F9 : ev->data.key.ch = CACA_KEY_F9; break;
  418. case GLUT_KEY_F10: ev->data.key.ch = CACA_KEY_F10; break;
  419. case GLUT_KEY_F11: ev->data.key.ch = CACA_KEY_F11; break;
  420. case GLUT_KEY_F12: ev->data.key.ch = CACA_KEY_F12; break;
  421. case GLUT_KEY_LEFT : ev->data.key.ch = CACA_KEY_LEFT; break;
  422. case GLUT_KEY_RIGHT: ev->data.key.ch = CACA_KEY_RIGHT; break;
  423. case GLUT_KEY_UP : ev->data.key.ch = CACA_KEY_UP; break;
  424. case GLUT_KEY_DOWN : ev->data.key.ch = CACA_KEY_DOWN; break;
  425. case GLUT_KEY_PAGE_UP : ev->data.key.ch = CACA_KEY_PAGEUP; break;
  426. case GLUT_KEY_PAGE_DOWN : ev->data.key.ch = CACA_KEY_PAGEDOWN;
  427. break;
  428. case GLUT_KEY_HOME : ev->data.key.ch = CACA_KEY_HOME; break;
  429. case GLUT_KEY_END : ev->data.key.ch = CACA_KEY_END; break;
  430. case GLUT_KEY_INSERT : ev->data.key.ch = CACA_KEY_INSERT; break;
  431. default: ev->type = CACA_EVENT_NONE; return 0;
  432. }
  433. ev->type = CACA_EVENT_KEY_PRESS;
  434. ev->data.key.ucs4 = 0;
  435. ev->data.key.utf8[0] = '\0';
  436. dp->drv.p->special_key = 0;
  437. return 1;
  438. }
  439. ev->type = CACA_EVENT_NONE;
  440. return 0;
  441. }
  442. static void gl_set_mouse(caca_display_t *dp, int flag)
  443. {
  444. if(flag)
  445. glutSetCursor(GLUT_CURSOR_RIGHT_ARROW);
  446. else
  447. glutSetCursor(GLUT_CURSOR_NONE);
  448. }
  449. /*
  450. * XXX: following functions are local
  451. */
  452. static void gl_handle_keyboard(unsigned char key, int x, int y)
  453. {
  454. caca_display_t *dp = gl_d;
  455. dp->drv.p->key = key;
  456. }
  457. static void gl_handle_special_key(int key, int x, int y)
  458. {
  459. caca_display_t *dp = gl_d;
  460. dp->drv.p->special_key = key;
  461. }
  462. static void gl_handle_reshape(int w, int h)
  463. {
  464. caca_display_t *dp = gl_d;
  465. if(dp->drv.p->bit) /* Do not handle reshaping at the first time */
  466. {
  467. dp->drv.p->new_width = w;
  468. dp->drv.p->new_height = h;
  469. dp->resize.w = w / dp->drv.p->font_width;
  470. dp->resize.h = (h / dp->drv.p->font_height) + 1;
  471. dp->resize.resized = 1;
  472. }
  473. else
  474. dp->drv.p->bit = 1;
  475. }
  476. static void gl_handle_mouse(int button, int state, int x, int y)
  477. {
  478. caca_display_t *dp = gl_d;
  479. dp->drv.p->mouse_clicked = 1;
  480. dp->drv.p->mouse_button = button;
  481. dp->drv.p->mouse_state = state;
  482. dp->drv.p->mouse_x = x / dp->drv.p->font_width;
  483. dp->drv.p->mouse_y = y / dp->drv.p->font_height;
  484. dp->mouse.x = dp->drv.p->mouse_x;
  485. dp->mouse.y = dp->drv.p->mouse_y;
  486. dp->drv.p->mouse_changed = 1;
  487. }
  488. static void gl_handle_mouse_motion(int x, int y)
  489. {
  490. caca_display_t *dp = gl_d;
  491. dp->drv.p->mouse_x = x / dp->drv.p->font_width;
  492. dp->drv.p->mouse_y = y / dp->drv.p->font_height;
  493. dp->mouse.x = dp->drv.p->mouse_x;
  494. dp->mouse.y = dp->drv.p->mouse_y;
  495. dp->drv.p->mouse_changed = 1;
  496. }
  497. #ifdef HAVE_GLUTCLOSEFUNC
  498. static void gl_handle_close(void)
  499. {
  500. caca_display_t *dp = gl_d;
  501. dp->drv.p->close = 1;
  502. }
  503. #endif
  504. static void _display(void)
  505. {
  506. caca_display_t *dp = gl_d;
  507. gl_display(dp);
  508. }
  509. /*
  510. * Driver initialisation
  511. */
  512. int gl_install(caca_display_t *dp)
  513. {
  514. #if defined(HAVE_GETENV) && defined(GLUT_XLIB_IMPLEMENTATION)
  515. if(!getenv("DISPLAY") || !*(getenv("DISPLAY")))
  516. return -1;
  517. #endif
  518. dp->drv.driver = CACA_DRIVER_GL;
  519. dp->drv.init_graphics = gl_init_graphics;
  520. dp->drv.end_graphics = gl_end_graphics;
  521. dp->drv.set_display_title = gl_set_display_title;
  522. dp->drv.get_display_width = gl_get_display_width;
  523. dp->drv.get_display_height = gl_get_display_height;
  524. dp->drv.display = gl_display;
  525. dp->drv.handle_resize = gl_handle_resize;
  526. dp->drv.get_event = gl_get_event;
  527. dp->drv.set_mouse = gl_set_mouse;
  528. return 0;
  529. }
  530. #endif /* USE_GL */