How to get a SurfaceHolder with a valid Surface (needed by EGL.eglCreateWindowSurface)?

前端 未结 2 1228
悲&欢浪女
悲&欢浪女 2021-02-15 06:37

I try to initialize GLES with EGL (because I want to draw from the main thread instead of using a Renderer and drawing from inside onDrawFrame). I get the error: \"Make sure the

相关标签:
2条回答
  • 2021-02-15 07:08

    Implement SurfaceHolder.Callback, and wait until you're told that the surface has been created. Also pay attention to when it is destroyed. You should only rely on the surface being valid between matching create and destroy calls.

    0 讨论(0)
  • 2021-02-15 07:12

    The check valid for surface should be did when surface is created. So, surface.isValid() should be called in onSurfaceCreated or onSurfaceChanged, obviously, you should add surfaceholder.callback.

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