diff options
author | Brian Paul <brian.paul@tungstengraphics.com> | 2005-08-09 15:13:32 +0000 |
---|---|---|
committer | Brian Paul <brian.paul@tungstengraphics.com> | 2005-08-09 15:13:32 +0000 |
commit | a1a6fa2fa18c4982aa8151042df7d04551e47981 (patch) | |
tree | 945e9e18a844247c8bc3dcc2a1e2ae1c608fd50a /progs | |
parent | ecde87054c48cc8c92c118a6efa848516bf0bf1c (diff) | |
download | external_mesa3d-a1a6fa2fa18c4982aa8151042df7d04551e47981.zip external_mesa3d-a1a6fa2fa18c4982aa8151042df7d04551e47981.tar.gz external_mesa3d-a1a6fa2fa18c4982aa8151042df7d04551e47981.tar.bz2 |
free display lists and destroy window upon exit
Diffstat (limited to 'progs')
-rw-r--r-- | progs/demos/gears.c | 35 |
1 files changed, 24 insertions, 11 deletions
diff --git a/progs/demos/gears.c b/progs/demos/gears.c index fc797eb..679fac4 100644 --- a/progs/demos/gears.c +++ b/progs/demos/gears.c @@ -26,6 +26,7 @@ static GLint T0 = 0; static GLint Frames = 0; static GLint autoexit = 0; +static GLint win = 0; /** @@ -164,6 +165,15 @@ static GLint gear1, gear2, gear3; static GLfloat angle = 0.0; static void +cleanup(void) +{ + glDeleteLists(gear1, 1); + glDeleteLists(gear2, 1); + glDeleteLists(gear3, 1); + glutDestroyWindow(win); +} + +static void draw(void) { glClear(GL_COLOR_BUFFER_BIT | GL_DEPTH_BUFFER_BIT); @@ -198,16 +208,18 @@ draw(void) Frames++; { - GLint t = glutGet(GLUT_ELAPSED_TIME); - if (t - T0 >= 5000) { - GLfloat seconds = (t - T0) / 1000.0; - GLfloat fps = Frames / seconds; - printf("%d frames in %6.3f seconds = %6.3f FPS\n", Frames, seconds, fps); - T0 = t; - Frames = 0; - if ((t >= 999.0 * autoexit) && (autoexit)) - exit(0); - } + GLint t = glutGet(GLUT_ELAPSED_TIME); + if (t - T0 >= 5000) { + GLfloat seconds = (t - T0) / 1000.0; + GLfloat fps = Frames / seconds; + printf("%d frames in %6.3f seconds = %6.3f FPS\n", Frames, seconds, fps); + T0 = t; + Frames = 0; + if ((t >= 999.0 * autoexit) && (autoexit)) { + cleanup(); + exit(0); + } + } } } @@ -239,6 +251,7 @@ key(unsigned char k, int x, int y) view_rotz -= 5.0; break; case 27: /* Escape */ + cleanup(); exit(0); break; default: @@ -352,7 +365,7 @@ int main(int argc, char *argv[]) glutInitWindowPosition(0, 0); glutInitWindowSize(300, 300); - glutCreateWindow("Gears"); + win = glutCreateWindow("Gears"); init(argc, argv); glutDisplayFunc(draw); |