I’m using openGL on android, time to emulate error

Asked

Viewed 258 times

0

I am testing an example found on the internet and at the time of execution gives me the following error on Logcat

03-23 09:43:22.286: E/androidruntime(1036): FATAL EXCEPTION: Glthread 72 03-23 09:43:22.286: E/androidruntime(1036): Process: with.obomprogramador.game.openglbasico2, PID: 1036 03-23 09:43:22.286: E/Androidruntime(1036): java.lang.Illegalargumentexception: No config Chosen 03-23 09:43:22.286: E/Androidruntime(1036): at android.opengl.Glsurfaceview$Baseconfigchooser.chooseConfig(Glsurfaceview.java:874) 03-23 09:43:22.286: E/androidruntime(1036): at android.opengl.Glsurfaceview$Eglhelper.start(Glsurfaceview.java:1024) 03-23 09:43:22.286: E/androidruntime(1036): at android.opengl.Glsurfaceview$Glthread.guardedRun(Glsurfaceview.java:1401) 03-23 09:43:22.286: E/androidruntime(1036): at android.opengl.Glsurfaceview$Glthread.run(Glsurfaceview.java:1240)

someone would tell me how to correct such a mistake.

  • Apparently it gives an error of "No config Chosen", check if you called the setEGLConfigChooser. More info on this link http://developer.android.com/reference/android/opengl/GLSurfaceView.html#setEGLConfigChooser(Boolean)

  • @Pedrohenrique o setEGLConfigChooser tem que estar na Main activity?

  • Hello, it has to be put on Opengl startup (more examples here http://www.programcreek.com/java-api-examples/index.php?api=android.opengl.GLSurfaceView). But I was looking at the documentation and if it is omitted it sets some default settings. Take away a doubt you are using an emulator or a real device?

  • @Pedrohenrique I used real device and emulator

1 answer

2


Two important facts:

  1. The emulator is not fully guaranteed. Your code can be perfect, and yet fail catastrophically in it.
  2. Between version 2.x and Android 4.x, certain behaviors change. The code that worked in 2.2/2.3 may not work the same way in 4.4.

Solution:

  1. Call setEGLContextClientVersion(2);
  2. Call setEGLConfigChooser(8, 8, 8, 8, 16, 0); using the default values

For example:

public class GameSurfaceView extends GLSurfaceView {
    private GameRenderer renderer;

    public GameSurfaceView(Context context) {
        super(context);
        setEGLContextClientVersion(2);
        setEGLConfigChooser(8, 8, 8, 8, 16, 0);
        renderer = new GameRenderer();//aonde GameRenderer implements GLSurfaceView.Renderer
        setRenderer(renderer);
    }
}

Remembering that Gamerenderer and Gamesurfaceview are your responsibility classes. I don’t know what name you gave to these classes in your project.

Browser other questions tagged

You are not signed in. Login or sign up in order to post.