PDA

View Full Version : Ruby Gems and OpenGL


Jaden
2007.03.30, 08:03 PM
I've been using Ruby with the rubysdl and ruby-opengl gems on one of my pcs to work on a 2D game. This has work splendidly and has given me a chance to use ruby. Something I'm quite enjoying.

My mac however, is having quite a hard time using the two gems in question. I used 'gem install -y' to install both packages, no errors were reported. But when any of my ruby scripts attempt: require 'sdl' or require 'opengl' I just get a file not found error.

Is there a step I'm missing? I have a sneaking suspicion it has something to do with a mix-up between the default ruby installation and my fresh ruby installation.

(And on an unrelated note, is rubysdl such an odd thing to be using on osx? All my google searches return few english pages.)

OneSadCookie
2007.03.30, 08:59 PM
I used RubySDL for a while until I made RubyGameShell (http://onesadcookie.com/trac/browser/RubyGameShellCommon). I'm also working on a new set of OpenGL bindings: GLEWby (http://onesadcookie.com/trac/browser/GLEWby). It's OK for the basics, but pointer and array handling is still a bit dodgy.

I'm afraid I don't know anything about the gem situation, however -- when I was using those things was long before rubygems existed.

Jaden
2007.04.02, 05:15 AM
Yeah, I had looked into your gameshell previously, but as cross-platform is an absolute requirement for me, I wasn't able to use it.

To be polite to anyone who has a similar problem, I'll do a quick run down of how I fixed this.

First, I used fink to reinstall ruby and all of it's dependencies. From Fink, I was also able to install ruby-opengl along with it's dependencies. Ruby/SDL was not available through Fink so I had to install that from source. The usual configure-make-install. I then discovered a little catch about Ruby/SDL on osx. Using the 'ruby' command to run your script will not work. You have to install a separate tool called rsdl.

Funny thing about that, the guy who made the tool no longer hosts it. It can however be grabbed from this site: http://www.kumaryu.net/cgi-bin/diary/files/rsdl.tar.gz It's a small tool that only links in some extra libraries needed on osx.

Also, the configuration script that comes with RSDL didn't work for me. I had to use the following command I found on the rubygame mailing list:

gcc rsdl.c -I/usr/local/include/SDL -I/sw/lib/ruby/1.8/powerpc-darwin/ `sdl-config --cflags` `sdl-config --libs` -lruby -o rsdl

That then gets dropped in usr/local/bin and tadaa, ruby/sdl now works. Of course, you have to use the 'rsdl' command to rub your scripts instead of 'ruby.'

I hope this eventually helps someone else.