Experiments with ruby-processing (processing-2.2.1) and JRubyArt for processing-3.0

Tuesday 24 August 2010

Running Ruby- Processing Opengl Apps on a 64 bit box

Hardware Considerations

When I came to upgrading my linux-box recently, the obvious choice was a bare bones system with a dual core AMD 64 bit processor (cheap and powerful enough). I couldn't see any point in running a 32 bit operating system on it so I installed Kubuntu 64 bit OS which provides, as default a Nouveau graphics driver to support a NVIDIA graphics processor. This driver only supports 2D acceleration, and 3D acceleration is provided by software emulation (mesa driver, slow). However the Ubuntu distro gives you the option of installing proprietary NVIDIA drivers, either using the scripts provided by Ubuntu, or direct from NVIDIA (but you are warned not to !!). Do a bit of research before installing the latest drivers directly from NVIDIA, ideally you should be comfortable compiling a kernel, updating grub etc. I usually find myself compiling a custom kernel for some reason other, so I opted for the latest drivers from NVIDIA, but then I've been using linux for at least six years.

OpenGL drivers

Like vanilla (java) processing the native libraries for opengl included are 32 bit, which is absolutely as it should be, however I don't think it should not stay that way!!!!
Fortunately the 64 bit native libraries already available, they are just stuck in a jar.
Larry Kyrala produced a script to extract the relevant 64 bit *.so files for vanilla processing. I present a modified version here.
Famous last words "It Worked For Me", I offer no guarantees and you may need to further modify the script for your installation. Depending on where you install your gems you may need to have root authority to run the script.


#!/usr/bin/env ruby

########################
# fix-rp5-opengl.rb
# based on a script by
# Larry Kyrala for
# vanilla processing
# extracts 64-bit native linux binaries
# for opengl (properly backs-up 32-bit binaries)
########################

require 'fileutils'

# script to fix ruby-processing for 64-bit linux
rp5_dir = "/var/lib/gems/1.9.1/gems/ruby-processing-1.0.9"

library_dir = File.join(rp5_dir,"library","opengl","library");
backup_dir = File.join(library_dir,"original-native");
unpack_dir = File.join(library_dir,"unpack-amd64");
Dir.mkdir backup_dir unless File.exists?(backup_dir)
Dir.mkdir unpack_dir unless File.exists?(unpack_dir)

jars = Dir.glob(File.join(library_dir,"*.jar")).select {|f| f =~ /linux-amd64/ }
jars.each do |jar_file|
  system "unzip -o #{jar_file} -d #{unpack_dir}"
end  

libraries = Dir.glob(File.join(unpack_dir,"*.so"))
libraries.each do |so_file|
  src = File.join(library_dir,File.basename(so_file))
  unless File.exists?(File.join(backup_dir,File.basename(so_file)))
    FileUtils.mv(src, backup_dir)
  end
  FileUtils.cp(so_file, library_dir, :preserve => true)
end
 


Ruby-Processing Issue

Presently there is an unresolved opengl issue with sketch resizing with ruby-processing. In practice that means you can only run ruby-processing opengl sketches in full-screen mode on linux.
Adding the line at the beginning of the sketch
full_screen
is often all you need to do to get the sketch to run.

No comments:

Post a Comment

Followers

About Me

My photo
I have developed JRubyArt and propane new versions of ruby-processing for JRuby-9.1.5.0 and processing-3.2.2