开发者

libgdx in android

I am developing a game using LibGdx, when i tried to run the game in motorola atrix which is of 2.2.2 version, it is not accepting GL10 and giving null for gl object. Can anyone help me on this.

i have my Gl related code in my render() method, what i think is, in libgdx they are using OpenGl10, but in the phones they may have a support for lower version of Gl. Am i correct in this Scenario?

Here is my code,

public class Game2D implements InputProcessor, ApplicationListener  
{  
public void create()   
{  
//init开发者_JS百科ializing all   
}   
public void render() {
GL10 gl = Gdx.graphics.getGL10();
gl.glClear(GL10.GL_COLOR_BUFFER_BIT);                           
}  
}   

the GL10 object in the code is giving null when we run in the phone, but it is running fine in the emulator..


Did you initialize it in your Android class that extends AndroidApplication?

It should look something like:

public void onCreate(final Bundle savedInstanceState) {
    super.onCreate( savedInstanceState );
    this.initialize(new Game2D, false);
}

The param "false" tells the app to use OpenGL ES 1.0 (GL10) thus:

OpenGL ES 1.0 == GL10
OpenGL ES 1.1 == GL11
OpenGL ES 2.0 == GL20
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜