This is the most basic of steps before getting anything done with LWJGL and JRuby, so I figured I would document it to help people with the initial hurdles.
Before doing anything with LWJGL and JRuby, you need to set things up correctly so that LWJGL can find its native extensions. The easiest way I found to do this was the following (tested on Linux):
- Install JRuby with RVM
- Download LWJGL
- Put lwdgj.jar in ./lib/java
- Unzip the native extensions (flatten out the directory, ignore solaris) and put them into ./lib/java/native
- Create a
.rvmrcin the root of the dir with the following code in it:
This sets the
JRUBY_OPTS environment variable, which tells JRuby to append these arguments to all JRuby operations. This obviously doesn’t work for deployment, but during development it makes thing very handy.
Now to write some Ruby code to get a window up and running!
First we need to require java, and the lwjgl jar file:
Drawing the window is now very straightforward:
# Just a basic display using lwjgl
Display.display_mode = DisplayMode.new(800, 600)
We can then write a little bin file to get this to run:
And there we go, we have a window!
Next, we’ll start to write some OpenGL!
The full source can be dowloaded from GitHub