Learn how easy it is to sync an existing GitHub or Google Code repo to a SourceForge project! See Demo


#62 Possibility for main event loop not in C

Easy (28)

Let's say we want to use Glut in another language than C, this is easily doable
via an FFI (Foreign Function Interface.) Now, the language's implementation may
not support native threads, but green threads only. This means that calling into
foreign code blocks all other threads.

In this scenario, the main event loop must be written in that language, not in C,
so the language's thread scheduler has a chance to run.

FreeGlut provides `glutMailLoopEvent' which is a step in the right direction, but
does not suffice (AFAICS.) You also need to expose X's ConnectionNumber,
where the main event loop in the other language can poll on. And you also need
access to Glut's ExecState to find out when the user closed the window.

I locally modified FreeGlut to expose both things via `glutGet' which works
perfectly. The modifications are trivial (adding two constants, and two switch cases),
so I won't provide a patch, unless you want me to.

Thanks for all your work!

Tobias Rittweiler
tcr, at, freebits, dot, de


  • This is a rather old item i see, but the patch would be welcome so we can evaluate it. Simple changes making more possible are always welcome.

    As a second thing, if we add this to the lib, would you be willing to provide a short doc detailing your usage case and some example code? I think many could profit from that.