How to handle different versions of OpenGL in library
Posted by sarevok on Jun 02, 2012; 8:44pm
URL: https://forum.jogamp.org/How-to-handle-different-versions-of-OpenGL-in-library-tp4025129.html
Hello,
I want to write crossplatform library which will be compatible with JOGL2 and I stuck in one place.
I dont know how to handle different versions of OpenGL, including GLES ones...
Just look at my code:
public class MySimpleLib {
private GL gl;
public MySimpleLib(GL gl) {
this.gl = gl;
}
public void setModelMatrixMode() {
if (GLProfile.getDefault().isGL2())
gl.glMatrixMode(GL2.GL_MODELVIEW); << The method glMatrixMode(int) is undefined for the type GL
if (GLProfile.getDefault().isGL3())
gl.glMatrixMode(GL3.GL_MODELVIEW); << The method glMatrixMode(int) is undefined for the type GL
if (GLProfile.getDefault().isGLES1())
gl.glMatrixMode(GLES1.GL_MODELVIEW); << The method glMatrixMode(int) is undefined for the type GL
}
}
So I can cast it to gl to this.gl to different GL profiles ((GL2) gl).glMatrixMode(GL2.GL_MODELVIEW); but is that good aproach? It seems not for me...
So whats the correct way to handle different GL versions here, depending from choosen GLProfile? Any advices?