PDA

View Full Version : Exit Main Loop



SamK
06-10-2006, 03:27 PM
How do you exit the main loop? Using Fortran to call C function containing openGL. After one chart, we want to return to Fortran to request another chart of do other computing, we don't want to kill the program. It takes a minute or two to load the big array. It is not practical to restart the program for each chart.

Bob
06-10-2006, 06:55 PM
Exit what main loop? OpenGL doesn't have a main loop, and since you don't know how to exit it I assume you didn't write it youself.

Please, be more specific when you ask questions. We don't know anything other that what you write. Provide details and don't assume we know what you talk about just because you know.

SamK
06-11-2006, 11:02 AM
Bob,

Thank you for understanding. There is something called: glutMainLoop(). It starts with glutDisplayFunc() and includes any code up to glutMainLoop(). OpenGL Programming Guide, p18, states that, 'it is never exited'. This means we start the big fortran program, call C and pass it data for the graph, OpenGL in the C program draws the object, and then we are stuck. There is no way to get back to the fortran program to do anything, like request another chart, because we have found no description of a graceful way to exit the: """glutMainLoop()""" without killing the graph, which kills the whole program, and we have to start all over again. Now you know the main loop we're talking about.

Apparently, a Mr. S.J.Baker understood the problem and wrote an article titled, "Hacking the glutMainLoop." But his web site doesn't work, so we can't read the article.

Using the Fortran "system call" to call a stand alone C-OpenGL program would work, but it gets into Memory Sharing to pass in the big Fortran array, which makes it a monster.

It takes up to two minutes to start the Fortran program and read in all the data files. We could have it create a disk file with just the data for one graph, then call the C-OpenGL program, have it open the file, read the data, do the graph, die, and return to the Fortran progam. That would work, but what a mess!

f90GL, using openGL from within Fortran might work, but it could not be made functional, even though William Mitchell at "nist.gov" tried, because we have a 64bit quad computer.

All of this, because we cannot get out of "glutMainLoop()" without killing the whole program.

I trust that sufficiently describes the problem. We are hoping that you would cordially describe a method of exiting the glutMainLoop.

Thank you.

Bob
06-11-2006, 11:18 AM
As the Red Book says, you cannot safely exit the main loop in GLUT. That's just the way it is. There are alternatives to GLUT, like GLFW and SDL, or even the native platform API line Win32 or X. Don't know if you can use them, but fact is that if you need to exit the main loop in GLUT, GLUT is not the windowing API you should use. You have to start looking for another API.

Rob The Bloke
06-16-2006, 07:47 PM
you can exit the glut main loop via, glutLeaveMainLoop (http://freeglut.sourceforge.net/docs/api.php#EventProcessing) . Of course, this requires you to use freeglut or openglut. The original version of glut does not conatin this functionality...

otherwise, you can call exit() to kill the app, and register an atexit function to get notification of when the exit func is called.