delete buffers, destroy window upon exit
This commit is contained in:
parent
6827cf4d9a
commit
0c46a12365
|
@ -28,6 +28,8 @@ struct object
|
||||||
static struct object Objects[NUM_OBJECTS];
|
static struct object Objects[NUM_OBJECTS];
|
||||||
static GLuint NumObjects;
|
static GLuint NumObjects;
|
||||||
|
|
||||||
|
static GLuint Win;
|
||||||
|
|
||||||
static GLfloat Xrot = 0, Yrot = 0, Zrot = 0;
|
static GLfloat Xrot = 0, Yrot = 0, Zrot = 0;
|
||||||
static GLboolean Anim = GL_TRUE;
|
static GLboolean Anim = GL_TRUE;
|
||||||
|
|
||||||
|
@ -118,6 +120,14 @@ static void Reshape( int width, int height )
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
static void FreeBuffers(void)
|
||||||
|
{
|
||||||
|
int i;
|
||||||
|
for (i = 0; i < NUM_OBJECTS; i++)
|
||||||
|
glDeleteBuffersARB(1, &Objects[i].BufferID);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
static void Key( unsigned char key, int x, int y )
|
static void Key( unsigned char key, int x, int y )
|
||||||
{
|
{
|
||||||
const GLfloat step = 3.0;
|
const GLfloat step = 3.0;
|
||||||
|
@ -138,6 +148,8 @@ static void Key( unsigned char key, int x, int y )
|
||||||
Zrot += step;
|
Zrot += step;
|
||||||
break;
|
break;
|
||||||
case 27:
|
case 27:
|
||||||
|
FreeBuffers();
|
||||||
|
glutDestroyWindow(Win);
|
||||||
exit(0);
|
exit(0);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
@ -346,7 +358,7 @@ int main( int argc, char *argv[] )
|
||||||
glutInitWindowPosition( 0, 0 );
|
glutInitWindowPosition( 0, 0 );
|
||||||
glutInitWindowSize( 600, 300 );
|
glutInitWindowSize( 600, 300 );
|
||||||
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
|
glutInitDisplayMode( GLUT_RGB | GLUT_DOUBLE );
|
||||||
glutCreateWindow(argv[0]);
|
Win = glutCreateWindow(argv[0]);
|
||||||
glutReshapeFunc( Reshape );
|
glutReshapeFunc( Reshape );
|
||||||
glutKeyboardFunc( Key );
|
glutKeyboardFunc( Key );
|
||||||
glutSpecialFunc( SpecialKey );
|
glutSpecialFunc( SpecialKey );
|
||||||
|
|
Loading…
Reference in New Issue