Ruby Open GL on OS X?

Hi all.

I’m trying to use Ruby to write OpenGL programs for an assignment in a
graphics course.

I was previously using Ruby on Windows, and OGL ran pefectly fine in
that platform. I used the Ruby one click installer for Windows BTW.

I have since bought a mac laptop, and have been unable to find a good
OGL/GLUT binding library, that does not require arcane trickery to
install and use. I also browsed some of the old OpenGL related topics in
this mailing list, but most of the programs they link to are dead links
by now.

So, does anyone know of a good, easy to install OpenGL/GLUT library that
I can use on Mac OS X? Thanks in advance for the replies!

Talha S. wrote:

So, does anyone know of a good, easy to install OpenGL/GLUT library that
I can use on Mac OS X? Thanks in advance for the replies!

Did you try this?

http://rb-opengl.darwinports.com/

I’m not on OSX, so I can’t verify that it works…

On 10/15/06, Talha S. [email protected] wrote:

Hi all.

[snip]

So, does anyone know of a good, easy to install OpenGL/GLUT library that
I can use on Mac OS X? Thanks in advance for the replies!

Well, we haven’t made a release yet, but you might grab (via svn) and
build the files from http://rubyforge.org/projects/ruby-opengl/ and
give it a shot. I think it should work for Mac OS X.

—John

John G. wrote:

give it a shot. I think it should work for Mac OS X.
It’s good to know someone’s maintaining this very useful library.

Do you have any general plans for it, beyond maintenance?

I was browsing the svn tree and saw something that could be improved:
there are some explicit type checks that might not be necessary, such as
this in gl_ClipPlane():

 if (TYPE(arg2) == T_ARRAY)
ary2cdbl(arg2, equation, 4);
 else
rb_raise(rb_eTypeError, "type mismatch:%s",rb_class2name(arg1));

Since ary2cdbl() calls rb_Array() on its arg, conversion is done if the
arg is not an array. It’s not a big deal, but it’s nice to make an API
as duck-like as possible…

Btw I’m planning on rewriting a 3ds loader (was in c++, and not a free
license) in pure ruby. Do you think it would make sense to include it
with ruby-opengl?

John G. wrote:

On 10/15/06, Talha S. [email protected] wrote:

Hi all.

[snip]

So, does anyone know of a good, easy to install OpenGL/GLUT library that
I can use on Mac OS X? Thanks in advance for the replies!

Well, we haven’t made a release yet, but you might grab (via svn) and
build the files from http://rubyforge.org/projects/ruby-opengl/ and
give it a shot. I think it should work for Mac OS X.

—John

Thanks for all the replies.

Man, have I been having a tough time with ruby-opengl. The rakefile
simply aborts with the following error:


Pro530Rage:~/Desktop/gzz/trunk talhasyed$ rake --trace
(in /Users/talhasyed/Desktop/gzz/trunk)
** Invoke default (first_time)
** Invoke ext/gl/gl.bundle (first_time)
** Invoke ext/gl/gl.o (first_time)
** Invoke ext/gl/gl.c (first_time, not_needed)
** Execute ext/gl/gl.o

============================== compiling: ext/gl/gl.c --> ext/gl/gl.o
cc -g -O2 -pipe -fno-common -I/usr/local/lib/ruby/1.8/i686-darwin8.8.1
-F/System/Library/Frameworks -c -o ext/gl/gl.o ext/gl/gl.c
{standard input}:unknown:FATAL:can’t create output file: ext/gl/gl.o
rake aborted!
Command failed with status (1): [cc -g -O2 -pipe -fno-common
-I/usr/local/l…]
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:722:in sh' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:729:insh’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:812:in sh' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:807:insh’
/Users/talhasyed/Desktop/gzz/trunk/rakefile:69
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in
execute' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:inexecute’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:357:in invoke' /usr/local/lib/ruby/1.8/thread.rb:135:insynchronize’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:350:in invoke' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:364:ininvoke_prerequisites’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:999:in each' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:363:ininvoke_prerequisites’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:356:in invoke' /usr/local/lib/ruby/1.8/thread.rb:135:insynchronize’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:350:in invoke' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:364:ininvoke_prerequisites’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:999:in each' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:363:ininvoke_prerequisites’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:356:in invoke' /usr/local/lib/ruby/1.8/thread.rb:135:insynchronize’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:350:in invoke' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:inrun’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in `run’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/bin/rake:7
/usr/local/bin/rake:18


I have XCode installed, so cc and gcc should run pefectly. If anyone
does a lot of C, do the above errors ring a bell?

Do Yoshi’s bindings work in Mac OSX, because I think I will try those
next.

On 10/15/06, Joel VanderWerf [email protected] wrote:

build the files from http://rubyforge.org/projects/ruby-opengl/ and
give it a shot. I think it should work for Mac OS X.

It’s good to know someone’s maintaining this very useful library.

Do you have any general plans for it, beyond maintenance?

Short term plans:

  • Use mkrf instead of our own hand-written top-level Rakefile to build
    it (this is already partially in-place, but besides waiting for the
    next mkrf release, I still don’t know how to make rake decend down and
    use each of the extension-specific Rakefiles (see the included
    build.sh script for the interim kludge)).

Long term:

  • Get some scripts together to help us bring it up to date with
    current OpenGL (see utils/README).

Not sure whether to make a release before or after we make attempts to
bring it more up to date, since it currently doesn’t offer much if
anything beyond Yoshi’s last version (except maybe that it builds on
Mac OS X).

arg is not an array. It’s not a big deal, but it’s nice to make an API
as duck-like as possible…

Thanks for the tip! I’m only now just learning how to make extension
modules, and will file this tip away for future use.

Btw I’m planning on rewriting a 3ds loader (was in c++, and not a free
license) in pure ruby. Do you think it would make sense to include it
with ruby-opengl?

Not sure, but I suspect not. Do you think your loader might merit
having its own RubyForge project?

Anyhow, feel free to bring this up on our project mailing list.
ruby-opengl things are moving kinda’ slowly at the moment, as I’m
still learning and also currently job hunting.

—John

On Thu, 19 Oct 2006, Talha S. wrote:

build the files from http://rubyforge.org/projects/ruby-opengl/ and
Pro530Rage:~/Desktop/gzz/trunk talhasyed$ rake --trace
{standard input}:unknown:FATAL:can’t create output file: ext/gl/gl.o
rake aborted!

this looks like your disk is full and/or you have a permissions error.
try
running that command by hand and seeing if there’s any more info

-a

unknown wrote:

On Thu, 19 Oct 2006, Talha S. wrote:

build the files from http://rubyforge.org/projects/ruby-opengl/ and
Pro530Rage:~/Desktop/gzz/trunk talhasyed$ rake --trace
{standard input}:unknown:FATAL:can’t create output file: ext/gl/gl.o
rake aborted!

this looks like your disk is full and/or you have a permissions error.
try
running that command by hand and seeing if there’s any more info

-a

My bad, I posted the wrong log file in the post. I actually ran rake as
as sudo, and didn’t get that error, but another one which said that I
was missing -lGL, which appears to be an OpenGL library.


Pro530Rage:~/Desktop/ruby-opengl/trunk talhasyed$ sudo rake --trace
(in /Users/talhasyed/Desktop/ruby-opengl/trunk)
** Invoke default (first_time)
** Invoke ext/gl/gl.bundle (first_time)
** Invoke ext/gl/gl.o (first_time, not_needed)
** Invoke ext/gl/gl.c (first_time, not_needed)
** Invoke ext/common/rbogl.o (first_time, not_needed)
** Invoke ext/common/rbogl.h (first_time, not_needed)
** Invoke ext/common/rbogl.c (first_time, not_needed)
** Execute ext/gl/gl.bundle

============================== linking ext/gl/gl.bundle
cc -bundle -lruby -framework GLUT -framework OpenGL -o ext/gl/gl.bundle
ext/gl/gl.o ext/common/rbogl.o -lGL
/usr/bin/ld: can’t locate file for: -lGL
collect2: ld returned 1 exit status
rake aborted!
Command failed with status (1): [cc -bundle -lruby -framework GLUT
-framewo…]
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:722:in sh' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:729:insh’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:812:in sh' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:807:insh’
/Users/talhasyed/Desktop/ruby-opengl/trunk/rakefile:76
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:in
execute' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:387:inexecute’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:357:in invoke' /usr/local/lib/ruby/1.8/thread.rb:135:insynchronize’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:350:in invoke' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:364:ininvoke_prerequisites’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:999:in each' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:363:ininvoke_prerequisites’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:356:in invoke' /usr/local/lib/ruby/1.8/thread.rb:135:insynchronize’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:350:in invoke' /usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:inrun’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:1906:in `run’
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/bin/rake:7
/usr/local/bin/rake:18
Pro530Rage:~/Desktop/ruby-opengl/trunk talhasyed$

FYI, when running Yoshi’s extconf.rb, I get a similar notification about
missing -lGl and some other libraries. Any OpenGl users familiar with
this library, and how to get it?

[email protected] wrote:

Talha S. wrote:

Posted via http://www.ruby-forum.com/.

You’re going to (at the least) add

/System/Library/Frameworks/OpenGL.framework/Libraries

to your LIBPATH. I assume it’s not too difficult to add this to the
rake file, but I’m not really a rake master, so I don’t have any great
advice there other than open it up and see if there’s someplace obvious
to throw it in.

You may need to make other changes … but hopefully you can glean them
out of this page:
http://www.macdevcenter.com/pub/a/mac/2005/04/01/opengl.html

Best,

-r

For now, I’ve gotten OpenGL working with DarwinPorts (woohoo!). But
thanks for the link - I’ll be sure to look into your suggestions on how
to make OpenGL work with a manual/regular installation of Ruby.

Talha S. wrote:

running that command by hand and seeing if there’s any more info
(in /Users/talhasyed/Desktop/ruby-opengl/trunk)
cc -bundle -lruby -framework GLUT -framework OpenGL -o ext/gl/gl.bundle
/Users/talhasyed/Desktop/ruby-opengl/trunk/rakefile:76
/usr/local/lib/ruby/gems/1.8/gems/rake-0.7.1/lib/rake.rb:363:in

FYI, when running Yoshi’s extconf.rb, I get a similar notification about
missing -lGl and some other libraries. Any OpenGl users familiar with
this library, and how to get it?


Posted via http://www.ruby-forum.com/.

You’re going to (at the least) add

/System/Library/Frameworks/OpenGL.framework/Libraries

to your LIBPATH. I assume it’s not too difficult to add this to the
rake file, but I’m not really a rake master, so I don’t have any great
advice there other than open it up and see if there’s someplace obvious
to throw it in.

You may need to make other changes … but hopefully you can glean them
out of this page:
http://www.macdevcenter.com/pub/a/mac/2005/04/01/opengl.html

Best,

-r

On 10/18/06, Talha S. [email protected] wrote:

[snip]

Do Yoshi’s bindings work in Mac OSX, because I think I will try those
next.

I think the extconf.rb would require some tweaking to work on OS X.

Posted by Talha S.
on 15.10.2006 21:01


I have since bought a mac laptop, and have been unable to find a good
OGL/GLUT binding library, that does not require arcane trickery to
install and use. I also browsed some of the old OpenGL related topics in
this mailing list, but most of the programs they link to are dead links
by now.

So, does anyone know of a good, easy to install OpenGL/GLUT library that
I can use on Mac OS X? Thanks in advance for the replies!

I’ve found this cross-platform OpenGL lib that also supports Mac OS X:

http://glfw.sourceforge.net/

On 10/18/06, Talha S. [email protected] wrote:

unknown wrote:

On Thu, 19 Oct 2006, Talha S. wrote:

[snip]

My bad, I posted the wrong log file in the post. I actually ran rake as
as sudo, and didn’t get that error, but another one which said that I
was missing -lGL, which appears to be an OpenGL library.

On GNU/Linux systems, -lGL is a linker option which means to link in
the libGL.so shared object (i.e. shared library). Mac OS X uses some
kind of alternative framework/dylib/bundle library system which I know
very little about.

[snip]

FYI, when running Yoshi’s extconf.rb, I get a similar notification about
missing -lGl and some other libraries. Any OpenGl users familiar with
this library, and how to get it?

Again, I don’t think Yoshi’s builds on Mac OS X without some tweaking.

The ruby-opengl on RubyForge (which is still basically Yoshi’s with
some added docs and a tweaked build procedure) should (I suppose) work
fine on Mac and Windows (as well as GNU/Linux, of course) after the
next mkrf release (which should be any day now). Actually, if you
install mkrf from svn, you should be able to use that ruby-opengl if
you don’t mind running the rake command for each individual extension
(gl, glu, glut).

—John

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs