GLProfile intersections

I have just begun porting my engine over to the jogl 2 architecture and I’ve developed one concern for it:

While porting I was interested in always using the most general profile so that if I needed to switch to a different profile, as much code could be reused as possible.

I’ve written wrappers around the different texture types available in opengl 2 (1d, 2d, 3d, cubemap, and rectangular). Unfortunately, the glTexImage1D/3D and the SubImage versions aren’t available in a super-interface for GL2 and GL3. The closest intersection is the GL2ES2, but that removes some methods shared by both GL2 and GL3.

As a developer who’s interested in just the desktop profiles, it’s very awkward to have both methods available in GL2 and GL3 but I cannot program to just one interface. I’ve taken to doing something like:


class JoglProfileUtil {
  static void glMethod(GL gl, args ...) {
       if (gl.isGL2()) {
             gl.getGL2().glMethod(args ...);
       } else if (gl.isGL3()) {
             gl.getGL3().glMethod(args ...);
       } else 
             // fail
  }
   ... and then more
}

This way looks okay in the code, but I’d prefer a desktop intersection between the newer versions of OpenGL. Maybe this is really hard or there were other reasons for not doing it, but I think it would be of great help to engine-writers that have to write code for pre-3.1 versions and 3.1+.

So far, these methods I’ve had to abstract: glTexImage1D, glTexImage3D, glTexSubImage1D, glTexSubImage3D, glFramebufferTexture1D, glFramebufferTexture3D, glReadBuffer, glDrawBuffer, and glDrawBuffers.

Thanks

Good point - thank you.

I see … there is room for a GL2GL3 common sub-interface,
and it makes sense to integrate it. Will do.

Wooo thank you thank you!
and so ends my youthful exuberance. :stuck_out_tongue:

Intersecting profile GL2GL3 is alive … (nightlies) …
Sorry … I messed up the builds thought … will produce a new beta tomorrow or so …

Great, thank you so much