Griffon Groks JOGL
With the improvements from the last post, adding JOGL support to Griffon is now incredibly easy. Assuming you have a fairly recent revision from SVN, add the following closure to Config.groovy in the griffon closure:
extensions {
jarUrls = ["http://download.java.net/media/applet-launcher/applet-launcher.jar", "http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/jogl.jar"]
jnlpUrls = ["http://download.java.net/media/jogl/builds/archive/jsr-231-webstart-current/jogl.jnlp"]
}
There is a little setup you'll need to do to initialize the canvas:
class JoglDemoController {
// these will be injected by Griffon
def model
def view
void mvcGroupInit(Map args) {
model.canvas = new GLCanvas(createCaps())
model.animator = new Animator(model.canvas)
model.canvas.addGLEventListener(new Lesson03())
model.animator = new Animator(model.canvas)
model.animator.start()
}
def createCaps = {
def glCaps = new GLCapabilities()
glCaps.with {
setRedBits(8)
setBlueBits(8)
setGreenBits(8)
setAlphaBits(8)
}
return glCaps
}
}
Next, we add our canvas and helper variables to our model and view:
class JoglDemoModel {
@Bindable canvas
@Bindable animator
@Bindable gl
}
JoglDemoView.groovy
application(title:'jogldemo', size:[512,384]) {
widget(model.canvas)
}
On our canvas, we use a slightly tweaked Java file from the Nehe examples.
Lastly, we need jogl.jar. This will enable run-applet and run-webstart. To get run-app working, you would have to install your specific operating systems native OpenGL libraries(.dll's on Win, .so's on Linux, .jnilib's on OSX). Download jogl.jar and/or OS-specific files.
I used Lesson03 from Nehe mostly unmodified.