fix(main): destroy temp egl context on init

This commit is contained in:
Swung0x48 2025-03-02 21:24:06 +08:00
parent 1aab5931ba
commit 9ae00d7bb2
3 changed files with 21 additions and 3 deletions

View File

@ -12,10 +12,12 @@
#define DEBUG 0
static EGLDisplay eglDisplay = EGL_NO_DISPLAY;
static EGLSurface eglSurface = EGL_NO_SURFACE;
static EGLContext eglContext = EGL_NO_CONTEXT;
void init_target_egl() {
EGLDisplay eglDisplay = EGL_NO_DISPLAY;
EGLSurface eglSurface = EGL_NO_SURFACE;
EGLContext eglContext = EGL_NO_CONTEXT;
LOAD_EGL(eglGetProcAddress);
LOAD_EGL(eglBindAPI);
@ -116,3 +118,16 @@ cleanup:
}
LOG_E("EGL initialization failed");
}
void destroy_temp_egl_ctx() {
LOAD_EGL(eglDestroySurface);
LOAD_EGL(eglDestroyContext);
LOAD_EGL(eglMakeCurrent);
LOAD_EGL(eglTerminate);
egl_eglMakeCurrent(eglDisplay, 0, 0, EGL_NO_CONTEXT);
egl_eglDestroySurface(eglDisplay, eglSurface);
egl_eglDestroyContext(eglDisplay, eglContext);
egl_eglTerminate(eglDisplay);
}

View File

@ -173,6 +173,7 @@ EGLBoolean mglues_eglMakeCurrent(EGLDisplay dpy, EGLSurface draw, EGLSurface rea
*/
void init_target_egl();
void destroy_temp_egl_ctx();
#ifdef __cplusplus

View File

@ -85,5 +85,7 @@ void proc_init() {
init_perfetto();
#endif
// Cleanup
destroy_temp_egl_ctx();
g_initialized = 1;
}