在三星S4上打开GL错误的配置错误 [英] Open GL Bad Config Error on Samsung S4

查看:84
本文介绍了在三星S4上打开GL错误的配置错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我在Samsung S4上遇到以下错误

I am getting the following error on Samsung S4

10-21 16:25:44.100: E/AndroidRuntime(29778): FATAL EXCEPTION: GLThread 11320
10-21 16:25:44.100: E/AndroidRuntime(29778): Process: <bundle ID>, PID: 29778
10-21 16:25:44.100: E/AndroidRuntime(29778): java.lang.RuntimeException: createContext failed: EGL_BAD_CONFIG
10-21 16:25:44.100: E/AndroidRuntime(29778): at android.opengl.GLSurfaceView$EglHelper.throwEglException(GLSurfaceView.java:1201)
10-21 16:25:44.100: E/AndroidRuntime(29778): at android.opengl.GLSurfaceView$EglHelper.throwEglException(GLSurfaceView.java:1192)
10-21 16:25:44.100: E/AndroidRuntime(29778): at android.opengl.GLSurfaceView$EglHelper.start(GLSurfaceView.java:1042)
10-21 16:25:44.100: E/AndroidRuntime(29778): at android.opengl.GLSurfaceView$GLThread.guardedRun(GLSurfaceView.java:1409)
10-21 16:25:44.100: E/AndroidRuntime(29778): at android.opengl.GLSurfaceView$GLThread.run(GLSurfaceView.java:1248)

该错误是由于:

this.setEGLContextFactory(new MyDefaultContextFactory());
this.setEGLConfigChooser(GL_RED_SIZE, GL_GREEN_SIZE, GL_BLUE_SIZE, GL_ALPHA_SIZE,
        GL_DEPTH_SIZE, 0);//<-this line
this.setDebugFlags(GLSurfaceView.DEBUG_CHECK_GL_ERROR
        | GLSurfaceView.DEBUG_LOG_GL_CALLS);
this.setPreserveEGLContextOnPause(true);
this.setEGLContextClientVersion(2);

通过的配置是:8,8,8,8,24

Where the configuration passed is : 8,8,8,8,24

最后移动上面的行是可行的.是什么原因呢?

Moving the above line at the end works though. Whats the reason for this?

PS:无论哪种情况,该代码都可以在Nexus5或MotoG上正常运行. 所有运行Kitkat 4.4.2的设备

PS: The code works fine on Nexus5 or MotoG in either case. All devices running Kitkat 4.4.2

推荐答案

我没有看到它在GLSurfaceView的android/opengl/GLSurfaceView.java"rel =" noreferrer>源代码,实际上似乎是setEGLContextClientVersion()必须在之前被称为setEGLConfigChooser()的情况

I don't see it clearly specified in the documentation, but from looking at the source code of GLSurfaceView, it really appears to be the case that setEGLContextClientVersion() must be called before setEGLConfigChooser().

不复制任何代码,因为我不确定这是否会侵犯版权,但是如果您拉出上面的代码链接,则可以继续进行以下操作:

Not copying any code because I'm not sure if that would violate copyrights, but you can follow along if you pull up the code link above:

  1. 代码中使用的setEGLContextChooser()重载会实例化一个新的ComponentSizeChoser,并将指定的大小传递给构造函数.
  2. ComponentSizeChooser的构造函数调用基类构造函数,将打包到配置规范中的指定大小传递给基本构造函数.基类是BaseConfigChooser.
  3. BaseConfigChooser的构造函数调用私有方法filterConfigSpec(),并向其传递配置规范
  4. filterConfigSpec()查看mEGLContextClientVersion成员变量的值,并使用它来确定EGL_RENDERABLE_TYPE属性的值,并将其添加到配置规范中.然后,它将使用此附加属性返回配置规范.
  5. 返回BaseConfigChooser构造函数,将修改后的配置规范分配给成员变量.
  6. 稍后将在调用chooseConfig()方法时使用此成员变量中的配置规范,并在其中选择实际配置.
  1. The overload of setEGLContextChooser() used in your code instantiates a new ComponentSizeChoser, with the specified sizes passed to the constructor.
  2. The constructor of ComponentSizeChooser invokes the base class constructor, passing the specified sizes packed into a config spec to the base constructor. The base class is BaseConfigChooser.
  3. The constructor of BaseConfigChooser invokes a private method filterConfigSpec(), passing it the config spec,
  4. filterConfigSpec() looks at the value of the mEGLContextClientVersion member variable, and uses it to determine the value of the EGL_RENDERABLE_TYPE attribute, which it adds to the config spec. It then returns the config spec with this additional attribute.
  5. Back in the BaseConfigChooser constructor, the modified config spec is assigned to a member variable.
  6. The config spec in this member variable is used later when the chooseConfig() method is called, where the actual configuration is selected.

mEGLContextClientVersionsetEGLContextClientVersion()设置的值.因此,仅当在setEGLContextChooser()之前调用setEGLContextClientVersion()时,用此方法设置的值才包括在配置选择中.

mEGLContextClientVersion is the value set by setEGLContextClientVersion(). Therefore, the value set with this method will only be included in the configuration selection if setEGLContextClientVersion() is called before setEGLContextChooser().

某些设备提供了同时支持ES 1.X和ES 2.0/3.0的配置,而其他设备则提供了针对1.X和2.0/3.0支持的单独配置.这很可能是为什么上下文创建在某些设备上以错误"顺序成功调用而在其他设备上却失败的原因.

Some devices provide configs that support both ES 1.X and ES 2.0/3.0, while others provide separate configs for 1.X and 2.0/3.0 support. This is most likely why the context creation succeeds with the calls in the "wrong" order on some devices, while it fails on others.

这篇关于在三星S4上打开GL错误的配置错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆