G3DRuby - A Ruby Library for Advanced 3D Graphics

About G3DRuby

After writing a number of OpenGL 3D demos in C++ (sponeil.org), I got tired of doing it. The Sandbox framework I wrote served me well enough for creating graphics demos, but the more I use other languages, the more tedious C++ feels to me. I developed a taste for Ruby, but there was no support for advanced 3D features like shaders, so I decided to write G3DRuby.

G3DRuby is a Ruby extension for the G3D library, which I feel is a very clean set of wrapper classes for many of the more advanced OpenGL features (shaders, vertex arrays, framebuffer objects, etc.) It also has 2D and 3D fonts, mesh building features, collision detection/response, and binary file handling routines (i.e. textures, Quake files, BSP trees) that make it perfect for building light-weight games and demos entirely in Ruby.

Documentation

There is very little documentation specific to G3DRuby at this time. For now you'll have to use the G3D documentation and the existing Ruby samples until I can write documentation specific to G3DRuby. For the most part, G3DRuby works exactly the same way G3D works. For the supported classes, the vast majority of the methods are identical. Overloaded and defaulted parameters are supported, most operator overloads are supported, getters and setters have been added for public members, and so on. Pointers, and G3D references, have been converted to Ruby references where possible. (Methods that take void pointers, like Texture::fromMemory, are not supported.)

Nested classes and templatized classes presented a bit of a problem, so I flattened them. Texture::Settings in C++ became Texture_Settings in Ruby (a top-level class in the G3D module). For templatized classes, like G3D::Array and G3D::VAR, I decided to create a separate class instance for each type I wanted to support. This is a bit of a pain, but will provide much better memory usage and performance than using arrays of Ruby objects. I do use Ruby arrays in a few places where small, fixed-size arrays of simple data types are used as public member variables (like float[3]).

Screenshots

Here are screenshots from three G3D demos I've ported to Ruby. All demos have been tested in Windows and Linux (Ubuntu 6.10). I apologize for the low frame rates. My GeForce 6800 started overheating and locking my system up, so I had to underclock it. The C++ demos all run the same speed. ;-)

GLSL Bump and Parallax Mapping Demo

Vertex Array Demo

Quake Model (MD2) Demo