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?
Thank you very much!
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.
I don’t want to display all the rectangles on the same scene. What I would like to do basically is:
User launches App. The QT GUI has 2 fields, length and width. You enter them and hit “ok show me this rectangle”.
Then, an OpenGL window opens and shows the rectangle. Now the user can watch them as long as he wants
The user hit esc or closes the windows, it closes, and the GUI comes back in the front, and works again.
2 and 3 again for any other time the user his “show”.
The problem is that my app is GUI-based, so all the time the mainloop is running, the GUI is frozen. Even when i destroyWindow, the GUI stays frozen.
So what I would need is:
a) a way to stop this loop
b) a way to only display one frame without loop
c) an idea to make my app run!
Thanksfor your help!
Yeah! I believe i have found something:-D
with function LeaveMainLoop()
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.
Or something else.
Never follow my advise, but here it is:
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