OpenGL and Ruby?

Discussion in 'Ruby' started by anne001, Jan 15, 2006.

  1. anne001

    anne001 Guest

    I would like to learn a little computer graphics. Courses I have looked
    at don't teach maya, zbrush etc, they teach computer programming with
    OpenGL.

    Can I use OpenGL with Ruby? Do I need to install anything extra (OX
    Tiger with ruby1.8).

    If I do need to install OpenGL, is this advice safe to follow on Tiger?

    http://groups.google.com/group/comp...87a9fd4b729d?q=openGL&rnum=3#f62c87a9fd4b729d

    How can I go about learning OpenGL and Ruby at the same time? (I have
    written a small program in Ruby, I am learning methods, object
    structure etc). Is there any documentation on how to use OpenGL from
    Ruby?
    anne001, Jan 15, 2006
    #1
    1. Advertising

  2. anne001

    anne001 Guest

    I tried to install openGL for ruby, opengl-0.32f and opengl-0.32g

    Ruby-OpenGL Bindings for Mac OS X
    =================================
    $ ruby extconf.rb

    I get an error
    can't find header files for ruby. I found a reference which suggests it
    is not finding ruby.h?
    How do I find ruby.h, and when I find it, what do I do next?
    anne001, Jan 15, 2006
    #2
    1. Advertising

  3. anne001

    anne001 Guest

    the first line of extconf.rb is

    require "mkmf", which is also the first line in programming ruby, ed 2
    page 277.

    If I just run that line, I get the same error message,
    ruby
    require "mkmf"
    can't find header files for ruby.

    I am using the ruby that comes with Tiger.

    I tried the make, and I found a recent mkmf.log file. But I don't think
    the extconf.rb ran all the way, so who knows what make does!

    any suggestion?
    anne001, Jan 15, 2006
    #3
  4. Requirements for using opengl are the opengl LIBRARIES (libGL,libGLU,
    and some applications use glut) and the ruby WRAPPER such as
    opengl-0.32
    and HEADERS for ruby.

    You need the headers from one of:
    {first look in the libraries /usr/local/lib/ruby/1.8/i686-linux/ruby.h
    (substitute for i686-linux your arch)
    Ruby should find it if it is there, but you can use a link to it.}
    OR
    {If it is not there, and ruby on your system is installed from
    packages,
    the header files are in a separate package with '-dev' in the name.
    Install that package.}
    OR
    {The headers that are required are in the top directory of the ruby
    source
    package. You can link/copy the files from the ruby source for the
    version you are using.}

    Older versions of ruby also used some other files that were provided in

    the top directory of the source package.

    Regarding the 'who knows what make does', there should never be
    a file 'Makefile' in the top directory of a package that contains the
    file 'extconf.rb' The purpose of executing 'ruby extconf.rb' is to
    verify
    that requirements have been met on the system. If all conditions are
    met,
    then a Makefile is created. If not, there is no Makefile.

    I do not know about special considerations for Tiger.

    There are many examples in the directory 'sample' of the wrapper.

    Best regards
    Gerald
    Gerald Murray, Jan 15, 2006
    #4
  5. anne001

    anne001 Guest

    thank you so much for your response.

    I did indeed find ruby.h in
    anne-g:/usr/lib/ruby/1.8/universal-darwin8.0

    >Ruby should find it if it is there, but you can use a link to it

    HOW DO I FIND A LINK TO IT?

    and I found mkmf.rb in the usr/lib/ruby/1.8 directory.
    I tried to debug mkmf.rb with puts. I found that it was looking for
    ruby.h in
    /usr/lib/ruby/1.8/powerpc-darwin8.0

    I jerryrigged it (using sudo to change the file) to look for ruby.h in
    the right directory.

    libdir = "/usr/lib/ruby/1.8"
    $extmk = libdir != Config::CONFIG["rubylibdir"]
    if not $extmk and File.exist?
    "/usr/lib/ruby/1.8/universal-darwin8.0/ruby.h"
    $hdrdir = $topdir ="/usr/lib/ruby/1.8/universal-darwin8.0"
    elsif File.exist? $srcdir + "/ruby.h"
    $topdir = Config::CONFIG["compile_dir"]
    $hdrdir = $srcdir
    else
    abort "can't find header files for ruby."
    end

    this took care of the header file error.

    checking for XAllowDeviceEvents() in -lXi... no
    checking for XMITMiscGetBugMode() in -lXext... no
    checking for XmuAddCloseDisplayHook() in -lXmu... no
    checking for XOpenDisplay() in -lX11... no
    checking for main() in -lGL... no
    checking for main() in -lMesaGL... no
    can't create OpenGL module!

    I have to figure out if this is also a path problem or if there are
    files missing.

    http://www.opengl.org/documentation/implementations.html
    According to this site, openGL does come with tiger.
    http://developer.apple.com/graphicsimaging/download/index.html
    Mac OS X v10.2 OpenGL CFM Software Development Kit (DMG)
    is from 2003. Do I need that?

    I wish mkmf.rb did not have this bug in the path, so I did not have to
    worry about what it does!
    IS THERE A FIX TO MKMF.RB so it won't have this path problem on the
    1.8.2 that comes pre-installed on Ruby? If so, where do I find it?

    thank you for helping me along

    anne
    anne001, Jan 16, 2006
    #5
  6. anne001

    anne001 Guest

    oups ignore the previous error messages
    the opengl-0.32g folder
    does not come with darwin option in the extconf.rb

    when I ran the extconf.rb which came with opengl-0.32f modified for
    tiger
    2005-04-26 :: James Adam <>
    I get the following error.

    ruby extconf.rb
    checking for main() in -lGL... no
    checking for main() in -lMesaGL... no
    checking for main() in -lGL... no
    can't create OpenGL module!
    I did check that opengl frameworks and glut frameworks are in the
    directory
    system/library/frameworks

    again, there seems to be a disconnect, it is looking for lGl when I
    have libGL
    system/library/frameworks/OpenGL.framework/Libraries anne$ ls
    libGL.dylib libGLSystem.dylib
    libGLImage.dylib libGLU.dylib
    libGLProgrammability.dylib

    It seems like the program is looking for a main function in a GL
    library. I tried this
    puts find_library("ibGL.dylib", func,
    "/System/Library/Frameworks/OpenGL.framework/Libraries/")
    and get
    checking for main() in -libGL.dylib... no
    tried without the extension
    checking for main() in -libGL... no
    tried with the whole name
    checking for main() in -llibGL... no

    It seems to me the problem is with finding an appropriate extconf.rb to
    install the opengl-0.32g onto my Tiger system!
    http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/112184
    did not work, it was for panther.
    Makefile.glut:40: *** missing separator. Stop.
    make: *** [glut.bundle] Error 2

    but I only found these two extconf, and obviously something is off.
    Hope someone out there knows what to do!
    anne001, Jan 16, 2006
    #6
  7. on unix, the
    checking for ? in -lX11 ..no
    means it is trying to test that function using a test program for the
    library.
    The library may be present, but has no symbols (and headers were not
    found.) OR the test program did not find the path to the library.
    So either correct the path, or add the header files, usually found in a
    package with the same name, but containing '-dev' in its name.

    the test for symbols is to use the nm command
    nm /usr/lib/libX11.so

    regards,
    Gerald
    Gerald Murray, Jan 16, 2006
    #7
  8. anne001

    anne001 Guest

    Thank you for your suggestion. I only saw it now

    I followed the instructions on
    http://blade.nagaokaut.ac.jp/cgi-bin/scat.rb/ruby/ruby-talk/90341
    without any understanding, but just as indicated

    except
    1. I kept the beginning of this line
    CFLAGS = -fno-common -arch i386 -arch ppc -g -Os -pipe
    -I/System/Library/Frameworks/OpenGL.framework/Headers
    -I/System/Library/Frameworks/GLUT.framework/Headers
    and
    2. I replaced powerpc-darwin8.0 to universal-darwin8.0 in the ruby
    section.

    I got a few warning messages
    make
    Now Making glut extend module
    gcc -fno-common -arch i386 -arch ppc -g -Os -pipe
    -I/System/Library/Frameworks/OpenGL.framework/Headers
    -I/System/Library/Frameworks/GLUT.framework/Headers -I.
    -I/usr/lib/ruby/1.8/universal-darwin8.0
    -I/usr/lib/ruby/1.8/universal-darwin8.0 -I. -I. -c glut.c
    glut.c: In function 'glut_KeyboardFunc':
    glut.c:147: warning: passing argument 1 of 'glutKeyboardFunc' from
    incompatible pointer type
    glut.c: In function 'glut_KeyboardFunc':
    glut.c:147: warning: passing argument 1 of 'glutKeyboardFunc' from
    incompatible pointer type
    cc -dynamic -bundle -undefined suppress -flat_namespace
    -L/usr/lib/ruby/1.8/universal-darwin8.0 -L/usr/lib
    -L/System/Library/Frameworks/OpenGL.framework/Libraries -L"/usr/lib" -o
    glut.bundle glut.o -ldl -lruby -lGLU -lGL -lobjc -framework GLUT
    Now Making opengl extend module
    cc -dynamic -bundle -undefined suppress -flat_namespace
    -L/usr/lib/ruby/1.8/universal-darwin8.0 -L/usr/lib
    -L/System/Library/Frameworks/OpenGL.framework/Libraries -L"/usr/lib" -o
    opengl.bundle glu.o ogl.o rbogl.o -ldl -lruby -lGLU -lGL -lobjc
    -framework GLUT

    robot.rb works with the letter e and s (esc (ascii code 27)) to stop
    it.

    then I ran sudo make install

    I don't know what I have achieved, but since ruby sample/robot.rb
    worked!
    I should be able to do something with opengl?

    I hope this is correct, and that it helps someone else!
    anne001, Jan 16, 2006
    #8
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alwin Blok

    ruby-opengl, ruby-glut

    Alwin Blok, Dec 30, 2003, in forum: Ruby
    Replies:
    5
    Views:
    176
    Alwin Blok
    Jan 21, 2004
  2. David Ross
    Replies:
    1
    Views:
    132
    Kaspar Schiess
    Sep 14, 2004
  3. Robert Maus

    Ruby and Opengl samples

    Robert Maus, Jan 9, 2006, in forum: Ruby
    Replies:
    0
    Views:
    77
    Robert Maus
    Jan 9, 2006
  4. Matthew Carlin

    Embedded Ruby and OpenGL

    Matthew Carlin, Jul 26, 2006, in forum: Ruby
    Replies:
    0
    Views:
    73
    Matthew Carlin
    Jul 26, 2006
  5. Kyle Pinkman

    Ruby/Opengl and RUDL

    Kyle Pinkman, Oct 4, 2006, in forum: Ruby
    Replies:
    3
    Views:
    109
    Kyle Pinkman
    Oct 5, 2006
Loading...

Share This Page