我端起我的游戏到Android和决定去与NativeActivity的,而不是Java的活动和JNI调用(我不回避JNI,只是虽然这将是建立纯粹的C / C回调和OpenGL上下文创建/销毁++更方便) 。
我知道GLSurfaceView有setPreserveEGLContextOnPause功能,但毕竟是在Java中,而不是在本地应用。 创建我用下面的代码方面:
EGLConfig config;
EGLSurface surface;
EGLContext context;
EGLDisplay display = eglGetDisplay(EGL_DEFAULT_DISPLAY);
eglInitialize(display, 0, 0);
eglChooseConfig(display, attribs, &config, 1, &numConfigs);
eglGetConfigAttrib(display, config, EGL_NATIVE_VISUAL_ID, &format);
ANativeWindow_setBuffersGeometry(engine->app->window, 0, 0, format);
surface = eglCreateWindowSurface(display, config, engine->app->window, NULL);
const EGLint contextAttribs[] = {
EGL_CONTEXT_CLIENT_VERSION, 2,
EGL_NONE
};
context = eglCreateContext(display, config, NULL, contextAttribs);
if (eglMakeCurrent(display, surface, surface, context) == EGL_FALSE) {
ERR("Unable to eglMakeCurrent");
return -1;
}
我也知道,setPreserveEGLContextOnPause是不是100%可靠的,我应该检查一下东西是手动销毁,但如果它不是 - 我想跳过更快的加载的缘故资产重装部分。
基本上我想要做的就是使用setPreserveEGLContextOnPause(或同类产品的NDK的世界)。 可能吗? 被GLSurfaceView被实例化的Android的EGL调用窗帘后面?