一个强制的解决方案是根据Android 的源代码制作您的自定义版本 GLSurfaceView 类。
在源代码中,您可以找到一个名为的方法swap:
/**
* Display the current render surface.
* @return the EGL error code from eglSwapBuffers.
*/
public int swap() {
if (! mEgl.eglSwapBuffers(mEglDisplay, mEglSurface)) {
return mEgl.eglGetError();
}
return EGL10.EGL_SUCCESS;
}
这应该是你想要的。然而不幸的是,它是一个私有内部类的方法,称为EglHelper.
/**
* An EGL helper class.
*/
private static class EglHelper {
因此,在您的自定义 GLSurfaceView 类(从 Google 的源代码复制)中,将此类EglHelper公开,您可以使用EglHelper.swap方法。
public static class EglHelper {