Chapter 4. Using OpenGL with FXRuby
Prev |  | Next

## Chapter 4. Using OpenGL with FXRuby

Abstract

FOX provides extensive support for OpenGL through its `FXGLCanvas` and `FXGLViewer` widgets, and FXRuby in turn provides interfaces to those classes. By combining FXRuby with the OpenGL interface for Ruby (described below) you can develop very powerful 3-D graphics applications. This chapter gives you the information you'll need to get started.

## What is OpenGL?

OpenGL is a platform-independent API for 2D and 3D graphics. The home page is http://www.opengl.org. Because it's a fairly open standard, highly optimized OpenGL drivers are available for most operating systems (including Windows and Linux).

## OpenGL Extensions for Ruby

This extension module, developed by Yoshiyuki Kusano, provides interfaces to not only the basic OpenGL API, but also the GLU and GLUT APIs. As of this writing, the currently released version is 0.32b and is available for download from http://www2.giganet.net/~yoshi/rbogl-0.32b.tgz. Be sure to check the Ruby Application Archive for the latest version of this extension as it is still under development.

Once you've downloaded the tarball, you should extract its contents to the working directory of your choice by typing:

    $ tar xzf rbogl-0.32b.tgz

After executing this command you should have a new `opengl` (not `rbogl-0.32b`) subdirectory. Change to this directory and then type:

    $ ruby extconf.rb

This should create a `Makefile` configured appropriately for your local Ruby installation. To now build the OpenGL module, type:

    $ make

You can safely ignore the warning(s) about `glut_KeyboardFunc` when it's compiling `glut.c`. Well, I ignore them and it hasn't hurt me yet ;) Assuming you get an otherwise clean build, install the OpenGL extensions by typing:

    $ make install

Please note that I'm not the maintainer of this particular Ruby extension, so I can't really accept bug fixes for it. But if you're having trouble integrating Ruby/OpenGL with FXRuby, let me know and we'll see what we can do.

Prev | Up | Next
Chapter 3. Hello, World! | Home | Chapter 5. Using Scintilla with FXRuby