Android — GLSurfaceView EGL_BAD_ALLOC

前端 未结 1 946
终归单人心
终归单人心 2020-12-08 11:46

My program switches between two Activities that each inflate a derived GLSurfaceView that uses VBOs. After switching back and forth between the two

相关标签:
1条回答
  • 2020-12-08 12:42

    Annoyingly I can't post a comment yet, but I think you mean onResume, not onRestart. Your Activity can be paused without being stopped, which would cause onPause, but not onRestart.

    This image (from the Activity docs) shows this activity life cycle very nicely:

    http://developer.android.com/images/activity_lifecycle.png

    In short, remember to pass onPause and onResume to both your super and to the GLSurfaceView.

    From http://android-developers.blogspot.com/2009/04/introducing-glsurfaceview.html:

    public class ClearActivity extends Activity {
        ... snip ...
    
        @Override
        protected void onPause() {
            super.onPause();
            mGLView.onPause();
        }
    
        @Override
        protected void onResume() {
            super.onResume();
            mGLView.onResume();
        }
    
        private GLSurfaceView mGLView;
    }
    
    0 讨论(0)
提交回复
热议问题