I’m using GLUT, I could not manage to create a second window with OpenGL otherwise.
Anyway, I have:
glutDisplayFunc(MyDisplayFunction);
glutReshapeFunc(MyReshapeFunction);
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.
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…
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
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.
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.
Rob.
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!