【发布时间】:2011-09-29 23:03:46
【问题描述】:
我正在编写使用 GL10 的 3d 游戏,但我希望应用程序支持 GL11 或 GL20(如果可用)。支持所有 3 的最佳设计是什么?或者这是一个愚蠢的差事,我应该只专注于支持一个版本?
我目前的想法是将我的 render() 函数拆分为 renderGL10、renderGL11、renderGL20 并根据可用的 GL 实例调用适当的渲染函数。每个渲染函数内部都有 GL 版本的正确渲染方法; GL10 和 GL11 可能会有重叠。这是处理我的问题的适当方法还是有更好的方法?
public render(){
if (Gdx.graphics.isGL20Available()){
renderGL20();
} else if (Gdx.graphics.isGL11Available()){
renderGL11();
} else {
renderGL10();
}
}
编辑: 解决方法:如果gl1.x可用,gl10也可用(且gdx.gl10不为空)。所以,我的渲染代码一般应该如下结构:
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
}
}
【问题讨论】:
标签: java opengl-es opengl-es-2.0 libgdx