Opengls eglCreateWindowSurface GL Error EGL_BAD_ALLOC

后端 未结 2 993
佛祖请我去吃肉
佛祖请我去吃肉 2021-01-12 06:51

I am getting eglCreateWindowSurface GL Error EGL_BAD_ALLOC when open app first time after installing in Samsung Galaxy S6 and same code working fine in other de

相关标签:
2条回答
  • 2021-01-12 07:35

    I solved the OpenGL error EGL_BAD_ALLOC

    This error occurs due to I am not handling renderer properly with activity life cycle.

    0 讨论(0)
  • 2021-01-12 07:35

    Workaround-to-losing-the-opengl-context-when-android-pauses

    So your Activity's onPause() should look like this:

    @Override
    public void onPause() {
        eglSurface.setVisibility(View.GONE);
        super.onPause();
        ...
    }
    

    And you restore your GLSurfaceView to the hierarchy not from onResume() but from onWindowFocusChanged() :

    @Override
    public void onWindowFocusChanged(boolean hasFocus) {
        super.onWindowFocusChanged(hasFocus);
        if (hasFocus && eglSurface.getVisibility() == View.GONE) {
             eglSurface.setVisibility(View.VISIBLE);
        }
        ...
    }
    

    See also:

    eglCreateWindowSurface: native_window_api_connect failed

    fixing-common-android-lifecycle-issues

    Links

    GLSurfaceView, GLSurfaceView.Renderer

    0 讨论(0)
提交回复
热议问题