Is it possible to terminate a GLUT loop without terminating the entire program?
I'm trying to write a program that can do some calculations, pop open a window and draw a simulation using GLUT to visualize the sim using the calculations, , then terminate the window and output some results to a datafile. The above will actually run in a loop that will run many times, but so far I haven't found a way to break out of the GLUT loop without exiting the program completely.
What I am working on is running a genetic algorithm to help me find optimal parameters for the simulation. The way I have set it up, the GA loop is doing the selection and crossover/mutation to come up with parameters, then the GLUT loop uses these parameters to run the simulation. Once the simulation has run for a given time period, some measurements are outputted to a datafile and the window is terminated. These results are then fed back into the GA loop to update the population (hopefully improving over time).
// run the entire simulation, then terminate
Is there a way to jump out of the glutMainLoop() without terminating execution of the program, or is there perhaps a better way to set up the structure of my loop using GLUT (ie. the GA running inside the GLUT loop)?