Subject:
[ruby-ffi] Re: Rubygame now uses FFI
From:
John Croisant
Date:
10/26/09 1:10 AM
To:
ruby-ffi@googlegroups.com


On Sun, Oct 25, 2009 at 9:19 PM, Charles Oliver Nutter
<headius@headius.com> wrote:
>
> On Sun, Oct 25, 2009 at 1:45 PM, John Croisant <jacius@gmail.com> wrote:
>> Also, I'm afraid JRuby
>> users on Mac are out of luck until a JRuby equivalent of RSDL [2] is
>> written.
>>
>>  [1] http://github.com/ffi/ffi-jruby
>>  [2] http://github.com/knu/rsdl
>
> I'm not clear what RSDL is actually needed for. Can you explain? The
> readme and the minimal .c file was pretty limited in description.
>
> - Charlie

RSDL is essentially a wrapper around the Ruby interpreter, but it
performs some SDL initialization magic that is only necessary on Mac.
It has something to do with priming Cocoa to open a display window,
but the details are somewhat arcane, and the implementation is rather
messy. Without RSDL -- that is, using the plain Ruby (or JRuby)
interpreter -- Rubygame and Ruby/SDL applications just print a bunch
of gibberish to the console instead of opening a display window.

Due to the messy and obscure implementation hidden inside SDL, I'm not
sure there's any way around it except to create a Java program that
initializes SDL and then runs an embedded JRuby interpreter. It *may*
be possible to initiate some of the Cocoa stuff that SDL wants via FFI
or other means, but the mish-mash of C (SDL), Objective-C (Cocoa),
Java, and Ruby makes my head spin just thinking about it. A Java app
wrapper would probably be simpler -- although more inconvenient for
users, because it's one more thing to install, and it's annoying to
have to remember to use it instead of the usual Ruby interpreter.

I think (or at least hope) that this annoying issue will be solved in
SDL 1.3, but I have no clue when that will be released. It has been
"almost ready" several times over the past 2-3 years, but it has never
managed to get off the ground. I could possibly set up a binding to
the SDL 1.3 SVN version, but I'm generally not in the habit of using
unreleased software as dependencies.

My own feeling is that the best, simplest, cleanest course right now
is for Rubygame to provide an OpenGL back end, but I'm not sure how
soon I'll be able to attempt it. If someone with Java knowledge wants
to try making a JRuby-ish RSDL wrapper, I think that would also have a
good chance of letting Rubygame work on Mac JRuby in the meantime.

- John