This is the mail archive of the guile@sourceware.cygnus.com mailing list for the Guile project.


Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]

Guile/GL/GLUT and POSIX threads trick (any hope?).



I'm working on a project where I'd really like to combine Guile and
GLUT.  Ideally, I'd like to have GLUT running its main loop in one
thread, and guile running a gh_repl in another.  As a bonus, I'd
*really* like to allow GLUT idle callbacks to call guile functions via
gh_call, etc.

I'm using scheme functions to handle the graphics via g-wrap GL/GLUT
bindings.  This already works fine with GtkGLarea, but I'd like to
swich to GLUT because for this project it's simpler, and it provides
primitive font support.

Is there any combination of mutexes, etc. at the C level that would be
likely to make this work safely?  I'm guessing not (at least not
without some low-level tinkering), but I thought I'd ask.  I can
imagine that at the very least, I might need to break gh_repl into a
separate thread-safe gh_read so that I could do something like this:

  /* In guile thread */

  while(not_at_eof) {
    SCM val = gh_read();
    lock_gh_mutex(); /* Just a pthread mutex... */
    gh_eval(val);
    unlock_gh_mutex();
  }

  --------------------------------

  /* In GLUT callbacks */

  lock_gh_mutex();
  gh_call0(some_thunk);
  unlock_gh_mutex();

Of course this doesn't even start to address signal safety, etc.

The overall goal is to have a readline based prompt where I can tinker
with things that affect (manage) the GLUT graphics, including the
callbacks.

Thoughts, suggestions?

Thanks.

-- 
Rob Browning <rlb@cs.utexas.edu> PGP=E80E0D04F521A094 532B97F5D64E3930

Index Nav: [Date Index] [Subject Index] [Author Index] [Thread Index]
Message Nav: [Date Prev] [Date Next] [Thread Prev] [Thread Next]