PDA

View Full Version : How to free memory in program using glut?



suniuin
07-18-2005, 09:06 PM
hello all,

I'm thinking how to "delete[] something_pointer" using glut.

I can "new" memory before calling glutMainLoop(),
but how to "delete" it? It should follow glutMainLoop(), but this does not work because I test it that program doesn't run thing after glutMainLoop().

RigidBody
07-18-2005, 09:34 PM
you can use the atexit (or on_exit) function to
register a function that is called when glut exits


void my_exit() {
printf("goodbye\n");}

void main(int argc, char *argv[]) {

atexit(my_exit);

// go on with glut here...
}

suniuin
07-18-2005, 10:02 PM
Thanks, RigidBody!


Originally posted by RigidBody:
you can use the atexit (or on_exit) function to
register a function that is called when glut exits


void my_exit() {
printf("goodbye\n");}

void main(int argc, char *argv[]) {

atexit(my_exit);

// go on with glut here...
}