Results 1 to 3 of 3

Thread: How to free memory in program using glut?

  1. #1
    Junior Member Newbie
    Join Date
    Mar 2005
    Posts
    14

    How to free memory in program using glut?

    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().

  2. #2
    Senior Member Frequent Contributor
    Join Date
    Aug 2004
    Location
    munich, germany
    Posts
    659

    Re: How to free memory in program using glut?

    you can use the atexit (or on_exit) function to
    register a function that is called when glut exits

    Code :
     void my_exit() {
    printf("goodbye\n");} 
     
    void main(int argc, char *argv[]) {
     
    atexit(my_exit);
     
    // go on with glut here...
    }

  3. #3
    Junior Member Newbie
    Join Date
    Mar 2005
    Posts
    14

    Re: How to free memory in program using glut?

    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

    Code :
     void my_exit() {
    printf("goodbye\n");} 
     
    void main(int argc, char *argv[]) {
     
    atexit(my_exit);
     
    // go on with glut here...
    }

Similar Threads

  1. Error when free memory
    By SagoO in forum OpenGL: Basic Coding
    Replies: 2
    Last Post: 04-03-2011, 11:54 AM
  2. How to free up memory
    By imported_adrian in forum COLLADA
    Replies: 0
    Last Post: 07-23-2010, 02:02 PM
  3. free video memory
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-05-2004, 02:10 PM
  4. how to free texture memory?
    By in forum OpenGL: Basic Coding
    Replies: 1
    Last Post: 05-27-2002, 03:15 AM
  5. Free texture memory?
    By Scorpion in forum OpenGL: Basic Coding
    Replies: 6
    Last Post: 05-10-2001, 01:12 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Proudly hosted by Digital Ocean