Part of the Khronos Group
OpenGL.org

The Industry's Foundation for High Performance Graphics

from games to virtual reality, mobile phones to supercomputers

Results 1 to 2 of 2

Thread: How to kill processes before closing the window (using GLUT && C++)

  1. #1
    Junior Member Newbie
    Join Date
    Jul 2004
    Posts
    9

    How to kill processes before closing the window (using GLUT && C++)

    I have the class X. I want to destruct it when user click [_] [x]-here (close window button). What should I do? I need it, because I mmap something in class X and I need to munmap it while exit.

    Example:

    X *myclass;

    int main(int argc, char** argv) {
    myclass = new X();

    //...
    // Some glut stuff..
    //...

    glutMainLoop();

    return 1;
    }

    How to delete myclass or destruct it (myclass->~X) while exit? Where?

    P.S.

    I use GLUT thread and create new window with GLUT too. TNX!

  2. #2
    Advanced Member Frequent Contributor plasmonster's Avatar
    Join Date
    Mar 2004
    Posts
    739

    Re: How to kill processes before closing the window (using GLUT && C++)

    Try the atexit() function.

    Code :
    #include <stdlib.h>
     
    void myAtExit()
    {
        // destroy stuff ...
    }
     
    int main(...)
    {
        ...
        atexit( myAtExit );
        glutMainLoop();
        return 0;
    }
    edit:

    I see that this has been answered in another forum.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •