J
James Adam
In case anyone needs this, I've uploaded my tweaked version of the
latest rb-opengl bindings to:
http://www.lazyatom.com/software/opengl-0.32g.tar.gz
You'll need the Developer Tools and probably the GLUT source from
Apple already installed. Here's the README:
2005-04-26 :: James Adam <[email protected]>
2006-01-28 :: (Updated to rb-opengl-0.32g)
Ruby-OpenGL Bindings for Mac OS X
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D
So basically here's a tweaked version of the original OpenGL module
for the Mac. To compile, just follow the same instructions as normal:
Build it - don't worry too much about any warnings:
$ ruby extconf.rb
$ make
Test it out:
$ ruby sample/robot.rb
(press the 'e' and 's' keys to make the "robot" move...)
Install it:
$ make install
(or possibly "sudo make install", depending on where your ruby is)
Changes I've made
-----------------
extconf.rb:
Added -framework flags and correct include directories
Hacked to generate GLUT module even without detection of -lGLUT, since
mkmf can't deal with the Mac GLUT framework
*.c:
Edited #includes to use <OpenGL/gl.h> and <GLUT/glut.h>
glut.c:
I've added the function CheckLoop to the GLUT module in line with the
same function in Apple's GLUT. GLUT's MainLoop is blocking and forces
you to perform additoinal processing using GLUT's IdleFunc system,
which can sometimes be very undesirable (particularly if you are using
Ruby as the glue between two libraries which both feature this type of
loop). CheckLoop allows you to cycle through a *single* GLUT
processing loop, and then returns control to the calling
thread/process. Thus, by periodically calling CheckLoop, you can get
the scene to update without having GLUT seize control of the whole
application.
I've also added calls for Glut.GameModeString(mode_string) and
Glut.EnterGameMode(), allowing you to switch your application to
fullscreen.
Finally, a new method GLUT.BitmapCharacterX(char) for displaying
characters, since there seems to be a problem with the default
GLUT.BitmapCharacter method.
Problems
--------
For some reason, including the libraries from the command line fails.
For instance:
$ irb
irb(main):001:0> require 'opengl'; require 'glut'
=3D> true
... works fine, but:
$ irb -r opengl
/usr/local/lib/ruby/site_ruby/1.8/powerpc-darwin8.0.0/opengl.bundle:
[BUG] Bus Error
ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0.0]
Abort trap
... clearly fails. You can see the discussion of this problem
(something unfortunately inherent with IRB on the mac) here:
http://ruby-talk.org/cgi-bin/scat.rb/~poffice/news2/comp.lang.ruby/23917
Or the quick fix, detailed here:
http://ruby-talk.org/cgi-bin/scat.rb/~poffice/news2/comp.lang.ruby/24004
latest rb-opengl bindings to:
http://www.lazyatom.com/software/opengl-0.32g.tar.gz
You'll need the Developer Tools and probably the GLUT source from
Apple already installed. Here's the README:
2005-04-26 :: James Adam <[email protected]>
2006-01-28 :: (Updated to rb-opengl-0.32g)
Ruby-OpenGL Bindings for Mac OS X
=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=3D=
=3D=3D=3D=3D=3D=3D=3D=3D
So basically here's a tweaked version of the original OpenGL module
for the Mac. To compile, just follow the same instructions as normal:
Build it - don't worry too much about any warnings:
$ ruby extconf.rb
$ make
Test it out:
$ ruby sample/robot.rb
(press the 'e' and 's' keys to make the "robot" move...)
Install it:
$ make install
(or possibly "sudo make install", depending on where your ruby is)
Changes I've made
-----------------
extconf.rb:
Added -framework flags and correct include directories
Hacked to generate GLUT module even without detection of -lGLUT, since
mkmf can't deal with the Mac GLUT framework
*.c:
Edited #includes to use <OpenGL/gl.h> and <GLUT/glut.h>
glut.c:
I've added the function CheckLoop to the GLUT module in line with the
same function in Apple's GLUT. GLUT's MainLoop is blocking and forces
you to perform additoinal processing using GLUT's IdleFunc system,
which can sometimes be very undesirable (particularly if you are using
Ruby as the glue between two libraries which both feature this type of
loop). CheckLoop allows you to cycle through a *single* GLUT
processing loop, and then returns control to the calling
thread/process. Thus, by periodically calling CheckLoop, you can get
the scene to update without having GLUT seize control of the whole
application.
I've also added calls for Glut.GameModeString(mode_string) and
Glut.EnterGameMode(), allowing you to switch your application to
fullscreen.
Finally, a new method GLUT.BitmapCharacterX(char) for displaying
characters, since there seems to be a problem with the default
GLUT.BitmapCharacter method.
Problems
--------
For some reason, including the libraries from the command line fails.
For instance:
$ irb
irb(main):001:0> require 'opengl'; require 'glut'
=3D> true
... works fine, but:
$ irb -r opengl
/usr/local/lib/ruby/site_ruby/1.8/powerpc-darwin8.0.0/opengl.bundle:
[BUG] Bus Error
ruby 1.8.2 (2004-12-25) [powerpc-darwin8.0.0]
Abort trap
... clearly fails. You can see the discussion of this problem
(something unfortunately inherent with IRB on the mac) here:
http://ruby-talk.org/cgi-bin/scat.rb/~poffice/news2/comp.lang.ruby/23917
Or the quick fix, detailed here:
http://ruby-talk.org/cgi-bin/scat.rb/~poffice/news2/comp.lang.ruby/24004