destroy gles surfaces resources

This commit is contained in:
martinfouilleul 2023-02-20 19:38:24 +01:00
parent 2dccfa5547
commit 64d7b31e5c
7 changed files with 2877 additions and 2857 deletions

View File

@ -124,7 +124,8 @@ f.write("void mg_gl_load_gl43(mg_gl_api* api, mg_gl_load_proc loadProc);\n")
f.write("void mg_gl_load_gles31(mg_gl_api* api, mg_gl_load_proc loadProc);\n") f.write("void mg_gl_load_gles31(mg_gl_api* api, mg_gl_load_proc loadProc);\n")
f.write("void mg_gl_load_gles32(mg_gl_api* api, mg_gl_load_proc loadProc);\n\n") f.write("void mg_gl_load_gles32(mg_gl_api* api, mg_gl_load_proc loadProc);\n\n")
f.write("void mg_gl_select_api(mg_gl_api* api);\n\n") f.write("void mg_gl_select_api(mg_gl_api* api);\n")
f.write("mg_gl_api* mg_gl_get_api(void);\n\n")
emit_end_guard(f, loaderName) emit_end_guard(f, loaderName)
f.close() f.close()
@ -153,6 +154,7 @@ emit_loader(f, 'gl43', gl43)
emit_loader(f, 'gles31', gles31) emit_loader(f, 'gles31', gles31)
emit_loader(f, 'gles32', gles32) emit_loader(f, 'gles32', gles32)
f.write("void mg_gl_select_api(mg_gl_api* api){ __mgGLAPI = api; }\n\n") f.write("void mg_gl_select_api(mg_gl_api* api){ __mgGLAPI = api; }\n")
f.write("mg_gl_api* mg_gl_get_api(void) { return(__mgGLAPI); }\n\n")
f.close() f.close()

File diff suppressed because it is too large Load Diff

View File

@ -1719,4 +1719,5 @@ void mg_gl_load_gles32(mg_gl_api* api, mg_gl_load_proc loadProc)
} }
void mg_gl_select_api(mg_gl_api* api){ __mgGLAPI = api; } void mg_gl_select_api(mg_gl_api* api){ __mgGLAPI = api; }
mg_gl_api* mg_gl_get_api(void) { return(__mgGLAPI); }

View File

@ -18,5 +18,6 @@ void mg_gl_load_gles31(mg_gl_api* api, mg_gl_load_proc loadProc);
void mg_gl_load_gles32(mg_gl_api* api, mg_gl_load_proc loadProc); void mg_gl_load_gles32(mg_gl_api* api, mg_gl_load_proc loadProc);
void mg_gl_select_api(mg_gl_api* api); void mg_gl_select_api(mg_gl_api* api);
mg_gl_api* mg_gl_get_api(void);
#endif // __GL_LOADER_H__ #endif // __GL_LOADER_H__

View File

@ -33,13 +33,22 @@ typedef struct mg_egl_surface
void mg_egl_surface_destroy(mg_surface_data* interface) void mg_egl_surface_destroy(mg_surface_data* interface)
{ {
mg_egl_surface* surface = (mg_egl_surface*)interface; mg_egl_surface* surface = (mg_egl_surface*)interface;
if(&surface->api == mg_gl_get_api())
{
mg_gl_select_api(0);
}
if(eglGetCurrentContext() == surface->eglContext)
{
eglMakeCurrent(surface->eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
}
eglDestroyContext(surface->eglDisplay, surface->eglContext);
eglDestroySurface(surface->eglDisplay, surface->eglSurface);
@autoreleasepool @autoreleasepool
{ {
[surface->layer release]; [surface->layer release];
} }
//////////////////////////////////////////////////
//TODO
//////////////////////////////////////////////////
free(surface); free(surface);
} }

View File

@ -35,9 +35,17 @@ void mg_egl_surface_destroy(mg_surface_data* interface)
{ {
mg_egl_surface* surface = (mg_egl_surface*)interface; mg_egl_surface* surface = (mg_egl_surface*)interface;
////////////////////////////////////////////////// if(&surface->api == mg_gl_get_api())
//TODO {
////////////////////////////////////////////////// mg_gl_select_api(0);
}
if(eglGetCurrentContext() == surface->eglContext)
{
eglMakeCurrent(surface->eglDisplay, EGL_NO_SURFACE, EGL_NO_SURFACE, EGL_NO_CONTEXT);
}
eglDestroyContext(surface->eglDisplay, surface->eglContext);
eglDestroySurface(surface->eglDisplay, surface->eglSurface);
DestroyWindow(surface->hWnd); DestroyWindow(surface->hWnd);
free(surface); free(surface);
} }

View File

@ -25,7 +25,6 @@ Overview
[/] Keep dummy window/dummy context around for gl context creation, and don't reload wgl functions every time [/] Keep dummy window/dummy context around for gl context creation, and don't reload wgl functions every time
[!] Sort out gles contents scaling for high dpi on osx [!] Sort out gles contents scaling for high dpi on osx
[!] Properly destroy egl surfaces
[!] win32 surfaces: only register surface child window once? [!] win32 surfaces: only register surface child window once?
[!] Make linking with libEGL optional, even if EGL backend is compiled in milepost? [!] Make linking with libEGL optional, even if EGL backend is compiled in milepost?
[!] Bundle examples with their own resources?? (e.g. avoiding clashes in metal libs files in bin directory) [!] Bundle examples with their own resources?? (e.g. avoiding clashes in metal libs files in bin directory)