Glut close handling

Issue #41 resolved
Shameek Ganguly created an issue

App does not terminate as expected if the GLUT window is closed, it exits right away after a callback to glutCluseFunc. It is a problem since no matter how the app has been closed, I need to close down remote connections with the robot before my app terminates. So, heres the proposed changes:

In ChaiGlutHandler.cpp:

glutInitDisplayMode(GLUT_RGB | GLUT_DEPTH | GLUT_DOUBLE);
      glutCreateWindow("scl_busylizzy");
      glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE, GLUT_ACTION_CONTINUE_EXECUTION);
      glutCloseFunc(closeChaiGlut);

In CMyApp.cpp::setpMySimulation():

#ifdef GRAPHICS_ON
        //lastly, check if user has ended the graphics, then end the ui too and set the app to terminate:

        if(scl_chai_glut_interface::CChaiGlobals::getData()->GLOB_chaiDbptr->running_ == false)
        {
            m_ui_handler->endSimulation();
            scl::CDatabase::getData()->running_ = false;
        }
#endif

Comments (4)

  1. Samir Menon repo owner

    This is expected behavior. ChaiGlutHandlers has a lot of hard-coded behaviors. As such, you might notice that ChaiGlutHandlers is actually "NOT" in the lib. It is always compiled with apps.

    You clearly have control over your app so do what you want.

    You have a few options even if you want to use the default ChaiGlutHandlers:

    (a) Copy over ChaiGlutHandlers*pp to your app and change whatever you want. (b) Write a function to catch Ctrl+c http://stackoverflow.com/questions/1641182/how-can-i-catch-a-ctrl-c-event-c And terminate with Ctrl+c

  2. Log in to comment