Well, ok. I am sure it is really easy and dummy, but i cannot figure out how to kill the OpenGL output without exiting my application.
Let’s say i have a simple app, with a GUI (QT+Kdevelop) which allows the user to chose 2 lengths. I am using GLUT.
Then, when they hit ‘Ok’, an OpenGL output shows a rectangle with the specified size.
Then, when they hit ‘esc’, I would like the OpenGL to shut up, dans my program to continue, allowing the user to enter 2 new dimensions, and show a new rectangle.
I mean, the only way i have found yet is:
either: exit(); which quits the app
or : glutdestroyWindows. That works, the windows is killed, but the loop seems not to stop, the following code (after glutMainLoop()) isn’t executed. So, any idea?
May be I have not understood the question but…
You should request the new variables within the main loop using a while loop or simular structure to get the recursive behaviour you want. I assume you want the rectangles all added to the same ‘scene’?
When you exit the main loop this should signify that the use of the application is finished. This may require running a function prior to exiting to tidy up any loose ends (threads, mallocs etc.) before leaving.
Sorry but I am a bit of a beginner myself so this may be wrong.
Looks like you’ve run into one of the classic limitations of glut. You could either use something else (like the freeglut mentioned in the post above), or you might also consider multi-threading your app so that your Qt GUI runs in one thread, and the OpenGL window runs in another…
The very documentation of glutMainLoop indicates that the function should never return.
I suggest threading, but remember that OpenGL contexts are thread specific, so wherever GLUT is so will your OpenGL code. Kill the thread to kill the loop. Brute force, but that’s what it needs.
I have been repeating this on this forum. If you
really want to be “in control” of your application,
and epsecially if you are going to make it use
threads, stay away from glut. Simply, write some
functions that would replace what glut does. It is
not that difficult.
It is my understanding that glut is there to help
you learn to use OpenGL and to also do certain
quite primitive things. If you are developing
something a bit more serious, as you probably have
now discovered with this thread, you need to completely
replace glut…