"Luís Oliveira" luismbo@gmail.com writes:
On Sat, Jul 12, 2008 at 10:49 PM, Jose A. Ortega Ruiz jao@gnu.org wrote:
what would be the best way to have an OpenGL/GLUT window open and manipulate it from a (non-blocked) REPL, maybe even while the GLUT main loop is running.
If you are using a multi-threaded Lisp, you can redefine e.g. your glut:display method and GLUT's main loop will pick it up. Otherwise, you'll have to interrupt the loop, redefine things, then resume it.
Yes, i'm using SBCL/Slime on Linux, and that seems to work so far. I guess that the best way to interrupt the loop (as i've been suggested in a private response) is to use restarts (one more thing for me to learn properly): maybe providing some predefined restarts in cl-opengl itself would be a good idea? (i could even try to send some patches, although i've done very little serious CL programming so far).
If you want to try GL commands at the REPL and watch their effect interactively then try something like this:
CL-USER> (let ((glut:*run-main-loop-after-display* nil)) (glut:display-window (make-instance 'glut:window))) NIL CL-USER> (progn (gl:clear-color 1 0 0 0) (gl:clear :color-buffer) (gl:flush))
Hmm, maybe i'm missing something basic here, but that doesn't work. The new window pops up, totally transparent, but the subsequent PROGN has no effect: the window remains transparent.
Running glut:main-loop in a separate thread seems to confuse GLUT, so when you need GLUT's help to handle some window event, you can call glut:main-loop-event which only handles at most one event per call, IIUC.
Yes, that seems to be the case. For instance, using a window instance with dimensions other than the defaults needs a call to glut:main-loop-event for the resizing to take effect. But then, as i mentioned before, no drawing takes place.
Cheers, jao