View Full Version : How to show window without glutMainLoop() ?
07-02-2002, 12:46 AM
I'm using GLUT, I could not manage to create a second window with OpenGL otherwise.
Anyway, I have:
glutIdleFunc(NULL); // No idle callback.
can I have a window shown somehow without calling glutMainLoop() ?
The problem is that glutMainLoop never returns, and I really just need to draw stuff and then ReadPixels() to a buffer. An endless loop is not what I want here.
I've (desperately) tried glutShowWindow() and glutPostRedisplay() but to no avail.
Thanks for any input,
07-02-2002, 01:46 AM
no go ... glut always needs you to drop into
glutMainloop() in order to process events.
However ... help is at hand ... check
I cannot build and distribute a new glut library (usage conditions bar this, but I have contacted Mark K at nVidia, but no response as yet!).
If you take the new source, build into your own library, you should be OK.
07-02-2002, 10:12 PM
That seems to be exactly what I am after!
If I only could build the thing... get 4080 errors with VS .NET :-/
After uncommenting the line #define GLUTCHECKLOOP in glut_event.c, I should just replace the 5 (or so) files and then rebuild all of GLUT: Build->Build GLUT32, right ? I admit I'm not very good at this...
07-03-2002, 12:23 AM
Must admit I built under IRIX and on a PC using Borland C++
Also, I'm sure that the sources are a little out of date, so I think the best thing to do is:
1. Make sure you can build the lib from sources, without any changes.
2. Apply the changes yourself to your own source code tree (saving originals, or course)
3. The re-build.
I will get round to updating the sources on-line when I can find a few spare moments.
Don't forget you can do lots in the "idle loop" ...
Let me know if you succeed! Should reall not be a problem if you can get the lib to build.
07-03-2002, 08:32 AM
I'm using Visual Studio .NET here.
I first compiled the original Win32 GLUT v3.7.6. It built fine.
I then made the appropriate changes myself. Basically I searched for "Rob" in your modified source files. I hope you had your name in every spot you made a change ;-)
So far it looks pretty good, although the "win32_winproc.c" file is really much different.
I've made the changes but I still get the error "cannot convert from 'void (__stdcall *)(void)' to 'GLUTwmcloseCB'" in win32_winproc.c and glut_win.c and I really don't know how to fix this. I've never been into the APIENTRY CALLBACK strange things anyway, pretty cryptic to me...
Hope you have time to look at it some time soon yourself :-P
07-04-2002, 06:24 AM
Check very carefully that you have transplanted the code correctly in glut.h AND glutint.h
GLUTwmcloseCB type is there just before the def of the window structure ...
make sure your c modules do in fact use glutint.h
email me on firstname.lastname@example.org for more
immediate returns on your queries ...
Sounds like we can put this one to rest quite soon!
07-04-2002, 06:38 AM
There is no reason why you cannot draw some geometry and do glReadPixels and then exit. You can put what ever code you want in the callbacks. I do this all the time to generate screenshots and animations without breaking the glut loop.
07-04-2002, 12:20 PM
It's done, working fine. I don't know if the window closing callback works but I don't need it anyway ;-) glutCheckLoop() works fine, thanks =)
ehm, have I understood it wrong then ? I thought glutMainLoop() *never* returns ?
Please elaborate on how you do it, pseudocode example please ?
07-04-2002, 11:52 PM
Hi, to answer for gumby too:
The sort of thing I do to e.g. capture an
AVI animation is to have in the display loop
a flag which can be checked to see if a I should capture frames and write AVI ...
This flag is switched on and off in the keyboard handling callbacks.
You can do this for most of the "additional" tweaks and things you need to do inside a display function.
I usually hang my display function off a timer too, rather than free run it (to give ME control over frame rates!)
Hope this helps.
P.S. You "ought" to use the new window closing stuff as when you shut a glut program down by closing ANY of its windows, all it does is "exit(0)", which simply kills the lot. This can be very nasty ... no chance to clean up and so on ... or even warn the user perhaps!
Powered by vBulletin® Version 4.2.0 Copyright © 2013 vBulletin Solutions, Inc. All rights reserved.