OpenGL on MacOS X (again)

I'm trying to get Ruby/OpenGL working for just me on my MacOS X box; I've looked at various things people have helpfully written in the past on the topic ( ruby-talk:89025 ) but unfortunately that was then, and the instructions don't seem to work for me on the current version of the opengl library.

I'd really appreciate it if someone who has Ruby/OpenGL working on Panther could write up a set of instructions for dummies; not just "you might want to get the Apple GLUT src" but "Here's a url to the GLUT src; download it, and run ... to get it compiled BEFORE the next step." Or whatever.

I really did try to apply the hacks listed in that thread to the current (0.32f) source, but I simply have no idea what I'm doing when it comes to getting other's packages to compile properly.

Help, please? :slight_smile:

···

--
(-, /\ \/ / /\/

: I'm trying to get Ruby/OpenGL working for just me on my MacOS X box;
: I've looked at various things people have helpfully written in the past
: on the topic ( ruby-talk:89025 ) but unfortunately that was then, and
: the instructions don't seem to work for me on the current version of
: the opengl library.

: I'd really appreciate it if someone who has Ruby/OpenGL working on
: Panther could write up a set of instructions for dummies; not just "you
: might want to get the Apple GLUT src" but "Here's a url to the GLUT
: src; download it, and run ... to get it compiled BEFORE the next step."
: Or whatever.

It would be nice if there were a binding that didn't use GLUT, because for
the most part it's unnecessary.

btw, I have similar issues with the ruby opengl bindings on Linux (I'm using
accelerated non mesa openGL on my box), and I just gave up trying to get
this to work properly.

To be fair, most scripting languages have issues with vendor supplied
openGL libs.

: I really did try to apply the hacks listed in that thread to the
: current (0.32f) source, but I simply have no idea what I'm doing when
: it comes to getting other's packages to compile properly.

: Help, please? :slight_smile:
: --
: (-, /\ \/ / /\/

···

Gavin Kistner <gavin@refinery.com> wrote:

I'm extremely interested in this as well. Please keep us looped, if you solve it.

James Edward Gray II

···

On Sep 9, 2004, at 4:53 PM, Gavin Kistner wrote:

I'm trying to get Ruby/OpenGL working for just me on my MacOS X box;

I installed freeglut from portage and it mostly works.
But I would not recommend installing portage to anybody who is not
prepared to patch it to get it working.

If anybody is interested have a look here:

Michal Suchanek

···

On Fri, Sep 10, 2004 at 09:49:42PM +0900, James Edward Gray II wrote:

On Sep 9, 2004, at 4:53 PM, Gavin Kistner wrote:

>I'm trying to get Ruby/OpenGL working for just me on my MacOS X box;

I'm extremely interested in this as well. Please keep us looped, if
you solve it.

Hi,

I just build Ruby/OpenGL 0.32f with glut on my Mac. Just replace the content of its extconf.rb with what's beneath (starting with #---extconf.rb). I just tested it on my Mac (Ruby 1.9 CVS, Mac OS X 10.3.5, last developer tools), but it should work. I you have any problem with it, do not hesitate :o). To test it, just do: ruby extconf.rb && make
Then try a sample: ruby sample/wrap.rb
If it works, you can then install it: sudo make install
I hope it helps ^o^
Some of it was inspired from stuff available on ruby-talk. The harder part was to know that you have to add '-framework Foundation' not to have an Objective-C error: 'objc: failed objc_getClass(NSObject) for GLUTApplication->isa->isa'
Bye,
Vincent Isambart

#---extconf.rb
require 'mkmf'

File.unlink('Makefile') if File.exist?('Makefile')
File.unlink('Makefile.ogl') if File.exist?('Makefile.ogl')
File.unlink('Makefile.glut') if File.exist?('Makefile.glut')

$CFLAGS = '-I. -I/System/Library/Frameworks/OpenGL.framework/Headers -I/System/Library/Frameworks/GLUT.framework/Headers'
$LDFLAGS = '-L/System/Library/Frameworks/OpenGL.framework/Libraries -framework GLUT -framework Foundation'
Dir.mkdir('GL') unless File.exist?('GL')
File.symlink('/System/Library/Frameworks/OpenGL.framework/Headers/gl.h', 'GL/gl.h') unless File.exist?('GL/gl.h')
File.symlink('/System/Library/Frameworks/OpenGL.framework/Headers/glu.h', 'GL/glu.h') unless File.exist?('GL/glu.h')
File.symlink('/System/Library/Frameworks/GLUT.framework/Headers/glut.h', 'GL/glut.h') unless File.exist?('GL/glut.h')

$objs = ['glu.o', 'ogl.o', 'rbogl.o']
create_makefile("opengl")
File.rename('Makefile', 'Makefile.ogl')

$objs = ['glut.o']
create_makefile("glut")
File.rename('Makefile', 'Makefile.glut')

modules = "glut.#{CONFIG['DLEXT']} opengl.#{CONFIG['DLEXT']}"

open('Makefile', 'w') {|f|
   v = $nmake ? '{$(srcdir)}' : ''
   f.write <<"MAKEFILE"
SHELL = /bin/sh
srcdir = #{$srcdir}
VPATH = $(srcdir)

all: #{modules}

opengl.#{CONFIG['DLEXT']}: #{v}rbogl.c #{v}ogl.c #{v}glu.c #{v}rbogl.h
  @echo Now Making opengl extend module
  @$(MAKE) -f Makefile.ogl

glut.#{CONFIG['DLEXT']}: #{v}glut.c
  @echo Now Making glut extend module
  @$(MAKE) -f Makefile.glut

clean:
  @$(MAKE) -f Makefile.ogl clean
  @$(MAKE) -f Makefile.glut clean

distclean:
  @$(MAKE) -f Makefile.ogl distclean
  @$(MAKE) -f Makefile.glut distclean

install: #{modules}
  @$(MAKE) -f Makefile.ogl install
  @$(MAKE) -f Makefile.glut install

site-install: #{modules}
  @$(MAKE) -f Makefile.ogl site-install
  @$(MAKE) -f Makefile.glut site-install
MAKEFILE
}

Hi,

The previous version of Ruby/OpenGL was not working with Ruby/GtkGLExt, only with GLUT. Here comes a better version of extconf.rb that will correct this problem. Forget the previous version - use this one ^o^

Vincent Isambart
#-------extconf.rb
require 'mkmf'

File.unlink('Makefile') if File.exist?('Makefile')
File.unlink('Makefile.ogl') if File.exist?('Makefile.ogl')
File.unlink('Makefile.glut') if File.exist?('Makefile.glut')

Dir.mkdir('GL') unless File.exist?('GL')
File.symlink('/System/Library/Frameworks/OpenGL.framework/Headers/gl.h', 'GL/gl.h') unless File.exist?('GL/gl.h')
File.symlink('/System/Library/Frameworks/OpenGL.framework/Headers/glu.h', 'GL/glu.h') unless File.exist?('GL/glu.h')
File.symlink('/System/Library/Frameworks/GLUT.framework/Headers/glut.h', 'GL/glut.h') unless File.exist?('GL/glut.h')

$CFLAGS = '-I. -I/System/Library/Frameworks/OpenGL.framework/Headers -I/System/Library/Frameworks/GLUT.framework/Headers'
$LDFLAGS = '-L/System/Library/Frameworks/OpenGL.framework/Libraries -lGL -lGLU'
$objs = ['glu.o', 'ogl.o', 'rbogl.o']
create_makefile("opengl")
File.rename('Makefile', 'Makefile.ogl')

$LDFLAGS = '-L/System/Library/Frameworks/OpenGL.framework/Libraries -framework GLUT -framework Foundation'
$objs = ['glut.o']
create_makefile("glut")
File.rename('Makefile', 'Makefile.glut')

modules = "glut.#{CONFIG['DLEXT']} opengl.#{CONFIG['DLEXT']}"

open('Makefile', 'w') {|f|
   v = $nmake ? '{$(srcdir)}' : ''
   f.write <<"MAKEFILE"
SHELL = /bin/sh
srcdir = #{$srcdir}
VPATH = $(srcdir)

all: #{modules}

opengl.#{CONFIG['DLEXT']}: #{v}rbogl.c #{v}ogl.c #{v}glu.c #{v}rbogl.h
  @echo Now Making opengl extend module
  @$(MAKE) -f Makefile.ogl

glut.#{CONFIG['DLEXT']}: #{v}glut.c
  @echo Now Making glut extend module
  @$(MAKE) -f Makefile.glut

clean:
  @$(MAKE) -f Makefile.ogl clean
  @$(MAKE) -f Makefile.glut clean

distclean:
  @$(MAKE) -f Makefile.ogl distclean
  @$(MAKE) -f Makefile.glut distclean

install: #{modules}
  @$(MAKE) -f Makefile.ogl install
  @$(MAKE) -f Makefile.glut install

site-install: #{modules}
  @$(MAKE) -f Makefile.ogl site-install
  @$(MAKE) -f Makefile.glut site-install
MAKEFILE
}

I'm going to try this at some point this weekend, but just to be clear, all that is needed is Ruby and Mac OS X.3.5? You didn't install any glut library, for example?

Thanks much for the tips.

James Edward Gray II

···

On Sep 10, 2004, at 11:27 AM, Vincent Isambart wrote:

Hi,

I just build Ruby/OpenGL 0.32f with glut on my Mac. Just replace the content of its extconf.rb with what's beneath (starting with #---extconf.rb). I just tested it on my Mac (Ruby 1.9 CVS, Mac OS X 10.3.5, last developer tools), but it should work. I you have any problem with it, do not hesitate :o). To test it, just do: ruby extconf.rb && make
Then try a sample: ruby sample/wrap.rb
If it works, you can then install it: sudo make install
I hope it helps ^o^

Great, this one works.
But the mail got somewhat wrepped so one has to unwrap it before loading
into ruby.

The freeglut version starts up much faster but the surface demo does not
work with it.

It is nice to have both :slight_smile:

Thanks

Michal Suchanek

···

On Sat, Sep 11, 2004 at 02:50:57AM +0900, Vincent Isambart wrote:

Hi,

The previous version of Ruby/OpenGL was not working with Ruby/GtkGLExt,
only with GLUT. Here comes a better version of extconf.rb that will
correct this problem. Forget the previous version - use this one ^o^

Hi,

I'm going to try this at some point this weekend, but just to be clear, all that is needed is Ruby and Mac OS X.3.5? You didn't install any glut library, for example?

My extconf.rb uses the GLUT from Apple (framework in /System/Library/Frameworks/GLUT.framework).
You where asking for something simple, and having to compile a library is not so simple (it can depend on whether you have fink/opendarwin or not, where you want to install it, whether you have/want to use X11...).
As there is already a version of GLUT on Mac OS X, I chose to use this one ^o^

Vincent Isambart

Actually, it was me who asked initially, but I do appreciate all your help. :slight_smile:

I followed your steps today flawlessly. Works great. Thanks for all the great help.

James Edward Gray II

···

On Sep 11, 2004, at 12:07 PM, Vincent Isambart wrote:

My extconf.rb uses the GLUT from Apple (framework in /System/Library/Frameworks/GLUT.framework).
You where asking for something simple, and having to compile a library is not so simple (it can depend on whether you have fink/opendarwin or not, where you want to install it, whether you have/want to use X11...).
As there is already a version of GLUT on Mac OS X, I chose to use this one ^o^

How is the OpenGL performance for Ruby bindings on
MacOSX? Just curious.

--David Ross

--- James Edward Gray II <james@grayproductions.net>
wrote:

···

On Sep 11, 2004, at 12:07 PM, Vincent Isambart > wrote:

> My extconf.rb uses the GLUT from Apple (framework
in
> /System/Library/Frameworks/GLUT.framework).
> You where asking for something simple, and having
to compile a library
> is not so simple (it can depend on whether you
have fink/opendarwin or
> not, where you want to install it, whether you
have/want to use
> X11...).
> As there is already a version of GLUT on Mac OS X,
I chose to use this
> one ^o^

Actually, it was me who asked initially, but I do
appreciate all your
help. :slight_smile:

I followed your steps today flawlessly. Works
great. Thanks for all
the great help.

James Edward Gray II

__________________________________
Do you Yahoo!?
Yahoo! Mail - 50x more storage than other providers!
http://promotions.yahoo.com/new_mail

I didn't run any benchmarks, but it seemed downright zippy from my very simple playing around on my Dual 2.0Ghz G5. Take that with a huge grain of salt, obviously.

James Edward Gray II

···

On Sep 11, 2004, at 6:53 PM, David Ross wrote:

How is the OpenGL performance for Ruby bindings on
MacOSX? Just curious.

Do you know about something like ruby-glxgears?
I can only say that the demos that run with the bindings can take a few
seconds to display in x11 and quite some time to display in an aqua window.
But I have nothing that would do some work continuously.
On an g3 500Mhz iMac with an ATI card.

Thanks

Michal Suchanek

···

On Sun, Sep 12, 2004 at 08:53:31AM +0900, David Ross wrote:

How is the OpenGL performance for Ruby bindings on
MacOSX? Just curious.