update: somehow I stumbled upon the answer to this. spooky, but I'm still open to suggestions for improvements/further-research.

Original question: I'm writing a toy program using Inline::C (which is awesome, BTW), but I have hit a painful roadblock. I'm calling a C function that will never return, so I need to call Perl code from this C event handler. What is the cleanest way to achieve this? I'm very strong in C, I'm pretty darn good in Perl, but mixing the two is rather new to me. XS, due to similarity to JNI, has scared me until this point, but I am afraid this is where I must go.

details:

Ok, folks, after fighting trying to get OpenGL.pm and SDL's OpenGL tools working on my system (thanks for the help everyone), I've given up on being able to hit 3D graphics from Perl.

My current tactic is to use Inline::C and write simple wrappers to GLUT. Freeglut is actually looking very promising as a library, so there is a lot of merit in trying this.

In a lame attempt to keep my program compiling on most platforms, I'd like to use the stock 1.3 freeglut that comes with Fedora Core 1. That is, a very old version.

As many of you know, glut has a function called "GlutMainLoop" that takes over control of a program and never lets it go. This defeats my goal of being able to script most of my game in Perl with bindings to GLUT.

Bottom line -- is there a method suitable for calling Perl functions from inline C code, or do I need to move to XS? I have been avoiding XS until now due to the annoyances of makefiles and various methods, not being exactly 'fun' for this side project.

Suggestions? For the record, I am enjoying these black arts of llama conjuring, and diving deeper is ok -- I could definitely use some pointers though.


In reply to Inline::C *back* into Perl by flyingmoose

Title:
Use:  <p> text here (a paragraph) </p>
and:  <code> code here </code>
to format your post, it's "PerlMonks-approved HTML":



  • Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
  • Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
  • Read Where should I post X? if you're not absolutely sure you're posting in the right place.
  • Please read these before you post! —
  • Posts may use any of the Perl Monks Approved HTML tags:
    a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
  • You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
            For:     Use:
    & &amp;
    < &lt;
    > &gt;
    [ &#91;
    ] &#93;
  • Link using PerlMonks shortcuts! What shortcuts can I use for linking?
  • See Writeup Formatting Tips and other pages linked from there for more info.