I am writing a 3d game that is using GL10, but I'd like the application to support GL11 or GL20 if available. What is the best design for supporting all 3? Or is this a fool's errand and I should just focus on supporting one version?
My current idea is to split my render() function into renderGL10, renderGL11, renderGL20 and call the appropriate render function based on the available GL instance. Inside each render function is the proper way to render for the GL version; there will likely be overlap for GL10 and GL11. Is this an appropriate way to handle my problem or is there a better way?
public render(){
if (Gdx.graphics.isGL20Available()){
renderGL20();
} else if (Gdx.graphics.isGL11Available()){
renderGL11();
} else {
renderGL10();
}
}
EDIT: Solution: If gl1.x is available, gl10 is also available (and Gdx.gl10 is not null). So, my render code should generally be structured as follows:
public render(){
// Use Gdx.gl for any gl calls common to all versions
if (Gdx.graphics.isGL20Available()){
// Use Gdx.GL20 for all gl calls
} else {
if (Gdx.graphics.isGL11Available()){
// Use Gdx.gl11 for any gl11 call not supported by gl10
}
// Use Gdx.gl10 for all gl calls
}
}