From db1a77f0d052fec3b671d5e863c710cb86022cd5 Mon Sep 17 00:00:00 2001 From: Sam Hocevar Date: Sun, 16 Dec 2007 11:54:43 +0000 Subject: [PATCH] * Only call glutInit() once through the program's lifetime. * Free the internal font when closing the GL driver. * Hide the window when closing the GL driver, because freeglut's glutDestroyWindow() does not really closes the window. --- caca/driver_gl.c | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/caca/driver_gl.c b/caca/driver_gl.c index e49dafc..88e337a 100644 --- a/caca/driver_gl.c +++ b/caca/driver_gl.c @@ -44,6 +44,7 @@ * Global variables */ +static int glut_init; static caca_display_t *gl_d; /* FIXME: we ought to get rid of this */ /* @@ -139,7 +140,11 @@ static int gl_init_graphics(caca_display_t *dp) dp->drv.p->sw = ((float)dp->drv.p->font_width) / 16.0f; dp->drv.p->sh = ((float)dp->drv.p->font_height) / 16.0f; - glutInit(&argc, argv); + if(!glut_init) + { + glut_init = 1; + glutInit(&argc, argv); + } glutInitDisplayMode(GLUT_RGBA | GLUT_DOUBLE); glutInitWindowSize(dp->drv.p->width, dp->drv.p->height); @@ -186,7 +191,9 @@ static int gl_init_graphics(caca_display_t *dp) static int gl_end_graphics(caca_display_t *dp) { + glutHideWindow(); glutDestroyWindow(dp->drv.p->window); + cucul_free_font(dp->drv.p->f); free(dp->drv.p->txid); free(dp->drv.p); return 0;