FreeGlut and Lush

Leon Bottou <[email protected]>
Newsgroups gmane.lisp.lush.devel
Message-ID <[email protected]>
Until recently Lush was relying on GLUT for its OpenGL interface.
I am working on using FreeGLUT as well.

The main difficulty is with intertwinning the glut event loop with the lush event loop.  
The Lush event loop is designed for this.  But Glut was not.
The code to do this with Glut was quite nasty:
             jmp_buf glut_event_jmp;
             void glut_idle_jmp(void) { longjmp(glut_event_jmp, 1); }
             ......
             if (! setjmp(glut_event_jmp) ) {
                glutIdleFunc(glut_idle_jmp);
                glutMainLoop();
             }
plus a number of hacks dependent on the internals of glut,
in order to handle timers and the close box in the window frames.
Relying on the internals of glut was not too big a problem
since the souce code of glut was ...ahem... frozen.

Freeglut makes this a lot easier with glutMainLoopEvent().  
But this is not exactly enough.  
Three features are missing for completely 
intertwinning the event loops.

- We need to find out which is the connection number for X11.  I suggest 
	  glutGet(GLUT_CONNECTION_NUMBER)
  This should return -1 when not applicable (windows).

- We need to know how much time there is before the next glut timer fires.  I suggest
         glutGet(GLUT_TIME_TO_NEXT_TIMER)
  This could return -1 when no timers are set.
  The function   fgNextTimer() already calculates this (see freeglut_main.c)

- Finally we need to make sure that 
        glutSetOption(GLUT_ACTION_ON_WINDOW_CLOSE,
                               GLUT_ACTION_CONTINUE_EXECUTION);
  works properly.  In glut-2.2.0, this is does not do the right thing:
     - It leaves glutMainLoopEvent() as soon as a window is closed
       regardless of the needs of other glut windows.
     - When it returns to glutMainLoopEvent(), it posts redisplay
       messages for the dead window.  I am afraid that few 
       routines are ready to deal with dead windows.
       Assertions fail.

An updated interface for lush will show up at:
http://cvs.sourceforge.net/viewcvs.py/lush/lush/packages/opengl/glut.lsh
in about 5 hours...

- Leon Bottou




-------------------------------------------------------
This SF.Net email is sponsored by: Oracle 10g
Get certified on the hottest thing ever to hit the market... Oracle 10g. 
Take an Oracle 10g class now, and we'll give you the exam FREE. 
http://ads.osdn.com/?ad_id=3149&alloc_id=8166&op=click
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.