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
I solved the OpenGL error EGL_BAD_ALLOC
This error occurs due to I am not handling renderer properly with activity life cycle.
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
GLSurfaceView, GLSurfaceView.Renderer