Just thought I’d record my experiences of refactoring a fairly large OGL application from using the old 1.1.1 to the new JS231 (beta 03 to be specific). Many of these are noted elsewhere (might be worth collating into a migration doc) but repeated here for completeness.
- Global replace net.java.games.jogl with javax.media.opengl
- GLU is now in javax.media.opengl.glu which requires an additional step
- GLU objects are created ab initio with new GLU () - no need to keep pulling them out of the Drawable (but note the one per thread limit)
- Replace GLDrawable with GLAutoDrawable
- Except: GLDrawable no longer includes getSize () (any reason not to?)
- All GL calls where you pass in an array you need to add an extra offset parameter - 0 when refactoring (aside: this is particularly tedious and inelegant - do the extra method bindings really matter?)
- Some calls which used to allow a direct array argument now needs IntBuffer.wrap (array) (e.g., glDrawPixels)
- Consequently it would be really useful if you could go straight from a java.awt.image.DataBuffer to a java.nio.Buffer
- Some GL calls which used to be an ARB or vendor extension are gone and (generally) just knock off the ARB etc to get it to work (e.g., glActiveTexture)
- The Animator class is now in com.sun.opengl.util for some reason (??)
- Looks like noAutoRedrawMode is no longer needed
The good news for anyone else who has to do this is that after going through a tedious half day of refactoring, it did just work once it successfully compiled. I’m sure I’ll find an odd gotcha yet to come - the main one that worries me is the necessity to rewind buffers now (but I don’t think any of mine should be anywhere other than 0).
And some other random thoughts while doing this:
- Common calls such as glLightfv, glMaterialfv and glFogfv with a colour argument could do with a convenience method binding with 4 floats
- Now that GLU is pure Java could we have some more friendly signatures to some methods?, e.g., gluUnproject (Vector3f, Matrix4f, Matrix4f, int [], Vector3f)
- In fact can we go one step further and support javax.vecmath.Matrix4f/Vector3f throughout the apis?