From e4015c52a4417dbb541b674a6b49b79ba30fd27f Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Fri, 21 Oct 2022 17:32:23 +0200 Subject: [PATCH] c: store handles inside mx struct * test: 0-initialize context struct This bug flew under the radar because the struct does not actually need to be initialized so far, but adding handles here requires it. Update all of the tests, even the compile-only tests, for consistency reasons. (And to prevent copy/paste disasters in the future) * example: zero-initialize context structs See previous commit. * c: add handle field to mx context This can be used to store the handle when combining the internal loader with an MX context, in a way that doesn't require static global state. * c: store _gl_handle in mx context * c: store _gles2_handle in mx context * c: store _gles1_handle in mx context * c: store _vulkan_handle in mx context closes: #385 --- example/c++/hellowindow2_macro.cpp | 2 +- example/c++/hellowindow2_mx.cpp | 2 +- example/c++/multiwin_mx/multiwin_mx.cpp | 2 +- glad/generator/c/templates/base_template.h | 4 +++ glad/generator/c/templates/loader/gl.c | 26 ++++++++++--------- glad/generator/c/templates/loader/gl.h | 2 +- glad/generator/c/templates/loader/gles1.c | 26 ++++++++++--------- glad/generator/c/templates/loader/gles1.h | 2 +- glad/generator/c/templates/loader/gles2.c | 26 ++++++++++--------- glad/generator/c/templates/loader/gles2.h | 2 +- glad/generator/c/templates/loader/vulkan.c | 26 ++++++++++--------- glad/generator/c/templates/loader/vulkan.h | 2 +- glad/generator/c/templates/template_utils.h | 6 ++++- test/c/compile/gl/header-only+mx/001/test.c | 2 +- test/c/compile/gl/header-only+mx/002/test.c | 2 +- test/c/compile/gl/header-only+mx/003/test.c | 2 +- test/c/compile/gl/header-only+mx/004/test.c | 2 +- test/c/compile/gl/header-only+mx/005/test.c | 2 +- test/c/compile/gl/header-only+mx/006/test.c | 2 +- test/c/compile/gl/header-only+mx/007/test.c | 2 +- test/c/compile/gl/mx+mx-global/001/test.c | 2 +- test/c/compile/gl/mx+mx-global/002/test.c | 2 +- test/c/compile/gl/mx+mx-global/003/test.c | 2 +- test/c/compile/gl/mx+mx-global/004/test.c | 2 +- test/c/compile/gl/mx+mx-global/005/test.c | 2 +- test/c/compile/gl/mx+mx-global/006/test.c | 2 +- test/c/compile/gl/mx+mx-global/007/test.c | 2 +- .../compile/vulkan/header-only+mx/001/test.c | 2 +- .../compile/vulkan/header-only+mx/002/test.c | 2 +- test/c/compile/vulkan/mx+mx-global/001/test.c | 2 +- test/c/compile/vulkan/mx+mx-global/002/test.c | 2 +- test/c/run/gl/mx/001/test.c | 2 +- test/c/run/gl/mx/002/test.c | 2 +- test/c/run/gl/mx/003/test.c | 2 +- test/c/run/gl/mx/004/test.c | 2 +- 35 files changed, 94 insertions(+), 78 deletions(-) diff --git a/example/c++/hellowindow2_macro.cpp b/example/c++/hellowindow2_macro.cpp index 18971567..0d56808a 100644 --- a/example/c++/hellowindow2_macro.cpp +++ b/example/c++/hellowindow2_macro.cpp @@ -64,7 +64,7 @@ int main() #endif #ifdef GLAD_OPTION_GL_MX - GladGLContext context; + GladGLContext context = {}; #ifdef GLAD_OPTION_GL_LOADER int version = gladLoaderLoadGLContext(&context); #else diff --git a/example/c++/hellowindow2_mx.cpp b/example/c++/hellowindow2_mx.cpp index d0b96df8..bf4c86d3 100644 --- a/example/c++/hellowindow2_mx.cpp +++ b/example/c++/hellowindow2_mx.cpp @@ -48,7 +48,7 @@ int main() // Set the required callback functions glfwSetKeyCallback(window, key_callback); - GladGLContext context; + GladGLContext context = {}; int version = gladLoadGLContext(&context, glfwGetProcAddress); if (version == 0) { diff --git a/example/c++/multiwin_mx/multiwin_mx.cpp b/example/c++/multiwin_mx/multiwin_mx.cpp index 550b707e..5db6ad87 100644 --- a/example/c++/multiwin_mx/multiwin_mx.cpp +++ b/example/c++/multiwin_mx/multiwin_mx.cpp @@ -78,7 +78,7 @@ GLFWwindow* create_window(const char *name, int major, int minor) { GladGLContext* create_context(GLFWwindow *window) { glfwMakeContextCurrent(window); - GladGLContext* context = (GladGLContext*) malloc(sizeof(GladGLContext)); + GladGLContext* context = (GladGLContext*) calloc(1, sizeof(GladGLContext)); if (!context) return NULL; int version = gladLoadGLContext(context, glfwGetProcAddress); diff --git a/glad/generator/c/templates/base_template.h b/glad/generator/c/templates/base_template.h index 7f9d0338..4583ef7c 100644 --- a/glad/generator/c/templates/base_template.h +++ b/glad/generator/c/templates/base_template.h @@ -76,6 +76,10 @@ typedef struct Glad{{ feature_set.name|api }}Context { {{ command.name|pfn }} {{ command.name|ctx(member=True) }}; {% endcall %} {% endfor %} + +{% if options.loader %} + void* glad_loader_handle; +{% endif %} } Glad{{ feature_set.name|api }}Context; {% if options.mx_global %} diff --git a/glad/generator/c/templates/loader/gl.c b/glad/generator/c/templates/loader/gl.c index 52a98ad9..9da45e41 100644 --- a/glad/generator/c/templates/loader/gl.c +++ b/glad/generator/c/templates/loader/gl.c @@ -23,9 +23,11 @@ static GLADapiproc glad_gl_get_proc(void *vuserptr, const char *name) { return result; } -static void* _gl_handle = NULL; +{% if not options.mx %} +static void* {{ template_utils.handle() }} = NULL; +{% endif %} -static void* glad_gl_dlopen_handle(void) { +static void* glad_gl_dlopen_handle({{ template_utils.context_arg(def='void') }}) { #if GLAD_PLATFORM_APPLE static const char *NAMES[] = { "../Frameworks/OpenGL.framework/OpenGL", @@ -45,11 +47,11 @@ static void* glad_gl_dlopen_handle(void) { }; #endif - if (_gl_handle == NULL) { - _gl_handle = glad_get_dlopen_handle(NAMES, sizeof(NAMES) / sizeof(NAMES[0])); + if ({{ template_utils.handle() }} == NULL) { + {{ template_utils.handle() }} = glad_get_dlopen_handle(NAMES, sizeof(NAMES) / sizeof(NAMES[0])); } - return _gl_handle; + return {{ template_utils.handle() }}; } static struct _glad_gl_userptr glad_gl_build_userptr(void *handle) { @@ -76,15 +78,15 @@ int gladLoaderLoadGL{{ 'Context' if options.mx }}({{ template_utils.context_arg( int did_load = 0; struct _glad_gl_userptr userptr; - did_load = _gl_handle == NULL; - handle = glad_gl_dlopen_handle(); + did_load = {{ template_utils.handle() }} == NULL; + handle = glad_gl_dlopen_handle({{ 'context' if options.mx }}); if (handle) { userptr = glad_gl_build_userptr(handle); version = gladLoadGL{{ 'Context' if options.mx }}UserPtr({{ 'context,' if options.mx }}glad_gl_get_proc, &userptr); if (did_load) { - gladLoaderUnloadGL(); + gladLoaderUnloadGL{{ 'Context' if options.mx }}({{ 'context' if options.mx }}); } } @@ -109,10 +111,10 @@ int gladLoaderLoadGL(void) { } {% endif %} -void gladLoaderUnloadGL(void) { - if (_gl_handle != NULL) { - glad_close_dlopen_handle(_gl_handle); - _gl_handle = NULL; +void gladLoaderUnloadGL{{ 'Context' if options.mx }}({{ template_utils.context_arg(def='void') }}) { + if ({{ template_utils.handle() }} != NULL) { + glad_close_dlopen_handle({{ template_utils.handle() }}); + {{ template_utils.handle() }} = NULL; {% if options.on_demand %} glad_gl_internal_loader_global_userptr.handle = NULL; {% endif %} diff --git a/glad/generator/c/templates/loader/gl.h b/glad/generator/c/templates/loader/gl.h index d7f01735..5d9db059 100644 --- a/glad/generator/c/templates/loader/gl.h +++ b/glad/generator/c/templates/loader/gl.h @@ -7,6 +7,6 @@ GLAD_API_CALL int gladLoaderLoadGL{{ 'Context' if options.mx }}({{ template_util {% if options.mx_global %} GLAD_API_CALL int gladLoaderLoadGL(void); {% endif %} -GLAD_API_CALL void gladLoaderUnloadGL(void); +GLAD_API_CALL void gladLoaderUnloadGL{{ 'Context' if options.mx }}({{ template_utils.context_arg(def='void') }}); #endif diff --git a/glad/generator/c/templates/loader/gles1.c b/glad/generator/c/templates/loader/gles1.c index 2abd5f42..b6f8cf71 100644 --- a/glad/generator/c/templates/loader/gles1.c +++ b/glad/generator/c/templates/loader/gles1.c @@ -24,9 +24,11 @@ static GLADapiproc glad_gles1_get_proc(void *vuserptr, const char* name) { return result; } -static void* _gles1_handle = NULL; +{% if not options.mx %} +static void* {{ template_utils.handle() }} = NULL; +{% endif %} -static void* glad_gles1_dlopen_handle(void) { +static void* glad_gles1_dlopen_handle({{ template_utils.context_arg(def='void') }}) { #if GLAD_PLATFORM_APPLE static const char *NAMES[] = {"libGLESv1_CM.dylib"}; #elif GLAD_PLATFORM_WIN32 @@ -35,11 +37,11 @@ static void* glad_gles1_dlopen_handle(void) { static const char *NAMES[] = {"libGLESv1_CM.so.1", "libGLESv1_CM.so", "libGLES_CM.so.1"}; #endif - if (_gles1_handle == NULL) { - _gles1_handle = glad_get_dlopen_handle(NAMES, sizeof(NAMES) / sizeof(NAMES[0])); + if ({{ template_utils.handle() }} == NULL) { + {{ template_utils.handle() }} = glad_get_dlopen_handle(NAMES, sizeof(NAMES) / sizeof(NAMES[0])); } - return _gles1_handle; + return {{ template_utils.handle() }}; } static struct _glad_gles1_userptr glad_gles1_build_userptr(void *handle) { @@ -60,15 +62,15 @@ int gladLoaderLoadGLES1{{ 'Context' if options.mx }}({{ template_utils.context_a return 0; } - did_load = _gles1_handle == NULL; - handle = glad_gles1_dlopen_handle(); + did_load = {{ template_utils.handle() }} == NULL; + handle = glad_gles1_dlopen_handle({{ 'context' if options.mx }}); if (handle != NULL) { userptr = glad_gles1_build_userptr(handle); version = gladLoadGLES1{{ 'Context' if options.mx }}UserPtr({{ 'context, ' if options.mx }}glad_gles1_get_proc, &userptr); if (!version && did_load) { - gladLoaderUnloadGLES1(); + gladLoaderUnloadGLES1{{ 'Context' if options.mx }}({{ 'context' if options.mx }}); } } @@ -93,10 +95,10 @@ int gladLoaderLoadGLES1(void) { } {% endif %} -void gladLoaderUnloadGLES1(void) { - if (_gles1_handle != NULL) { - glad_close_dlopen_handle(_gles1_handle); - _gles1_handle = NULL; +void gladLoaderUnloadGLES1{{ 'Context' if options.mx }}({{ template_utils.context_arg(def='void') }}) { + if ({{ template_utils.handle() }} != NULL) { + glad_close_dlopen_handle({{ template_utils.handle() }}); + {{ template_utils.handle() }} = NULL; {% if options.on_demand %} glad_gles1_internal_loader_global_userptr.handle = NULL; {% endif %} diff --git a/glad/generator/c/templates/loader/gles1.h b/glad/generator/c/templates/loader/gles1.h index 2c0da482..46dfa75f 100644 --- a/glad/generator/c/templates/loader/gles1.h +++ b/glad/generator/c/templates/loader/gles1.h @@ -12,6 +12,6 @@ GLAD_API_CALL int gladLoaderLoadGLES1{{ 'Context' if options.mx }}({{ template_u {% if options.mx_global %} GLAD_API_CALL int gladLoaderLoadGLES1(void); {% endif %} -GLAD_API_CALL void gladLoaderUnloadGLES1(void); +GLAD_API_CALL void gladLoaderUnloadGLES1{{ 'Context' if options.mx }}({{ template_utils.context_arg(def='void') }}); #endif /* GLAD_GLES1 */ diff --git a/glad/generator/c/templates/loader/gles2.c b/glad/generator/c/templates/loader/gles2.c index cb545e83..996da543 100644 --- a/glad/generator/c/templates/loader/gles2.c +++ b/glad/generator/c/templates/loader/gles2.c @@ -32,9 +32,11 @@ static GLADapiproc glad_gles2_get_proc(void *vuserptr, const char* name) { return result; } -static void* _gles2_handle = NULL; +{% if not options.mx %} +static void* {{ template_utils.handle() }} = NULL; +{% endif %} -static void* glad_gles2_dlopen_handle(void) { +static void* glad_gles2_dlopen_handle({{ template_utils.context_arg(def='void') }}) { #if GLAD_PLATFORM_EMSCRIPTEN #elif GLAD_PLATFORM_APPLE static const char *NAMES[] = {"libGLESv2.dylib"}; @@ -47,11 +49,11 @@ static void* glad_gles2_dlopen_handle(void) { #if GLAD_PLATFORM_EMSCRIPTEN return NULL; #else - if (_gles2_handle == NULL) { - _gles2_handle = glad_get_dlopen_handle(NAMES, sizeof(NAMES) / sizeof(NAMES[0])); + if ({{ template_utils.handle() }} == NULL) { + {{ template_utils.handle() }} = glad_get_dlopen_handle(NAMES, sizeof(NAMES) / sizeof(NAMES[0])); } - return _gles2_handle; + return {{ template_utils.handle() }}; #endif } @@ -81,15 +83,15 @@ int gladLoaderLoadGLES2{{ 'Context' if options.mx }}({{ template_utils.context_a return 0; } - did_load = _gles2_handle == NULL; - handle = glad_gles2_dlopen_handle(); + did_load = {{ template_utils.handle() }} == NULL; + handle = glad_gles2_dlopen_handle({{ 'context' if options.mx }}); if (handle != NULL) { userptr = glad_gles2_build_userptr(handle); version = gladLoadGLES2{{ 'Context' if options.mx }}UserPtr({{ 'context, ' if options.mx }}glad_gles2_get_proc, &userptr); if (!version && did_load) { - gladLoaderUnloadGLES2(); + gladLoaderUnloadGLES2{{ 'Context' if options.mx }}({{ 'context' if options.mx }}); } } #endif @@ -115,10 +117,10 @@ int gladLoaderLoadGLES2(void) { } {% endif %} -void gladLoaderUnloadGLES2(void) { - if (_gles2_handle != NULL) { - glad_close_dlopen_handle(_gles2_handle); - _gles2_handle = NULL; +void gladLoaderUnloadGLES2{{ 'Context' if options.mx }}({{ template_utils.context_arg(def='void') }}) { + if ({{ template_utils.handle() }} != NULL) { + glad_close_dlopen_handle({{ template_utils.handle() }}); + {{ template_utils.handle() }} = NULL; {% if options.on_demand %} glad_gles2_internal_loader_global_userptr.get_proc_address_ptr = NULL; {% endif %} diff --git a/glad/generator/c/templates/loader/gles2.h b/glad/generator/c/templates/loader/gles2.h index cc509369..7e673982 100644 --- a/glad/generator/c/templates/loader/gles2.h +++ b/glad/generator/c/templates/loader/gles2.h @@ -12,7 +12,7 @@ GLAD_API_CALL int gladLoaderLoadGLES2{{ 'Context' if options.mx }}({{ template_u {% if options.mx_global %} GLAD_API_CALL int gladLoaderLoadGLES2(void); {% endif %} -GLAD_API_CALL void gladLoaderUnloadGLES2(void); +GLAD_API_CALL void gladLoaderUnloadGLES2{{ 'Context' if options.mx }}({{ template_utils.context_arg(def='void') }}); #endif /* GLAD_GLES2 */ diff --git a/glad/generator/c/templates/loader/vulkan.c b/glad/generator/c/templates/loader/vulkan.c index 62988a5e..caf2886c 100644 --- a/glad/generator/c/templates/loader/vulkan.c +++ b/glad/generator/c/templates/loader/vulkan.c @@ -56,9 +56,11 @@ static GLADapiproc glad_vulkan_get_proc(void *vuserptr, const char *name) { } -static void* _vulkan_handle; +{% if not options.mx %} +static void* {{ template_utils.handle() }} = NULL; +{% endif %} -static void* glad_vulkan_dlopen_handle(void) { +static void* glad_vulkan_dlopen_handle({{ template_utils.context_arg(def='void') }}) { static const char *NAMES[] = { #if GLAD_PLATFORM_APPLE "libvulkan.1.dylib", @@ -71,11 +73,11 @@ static void* glad_vulkan_dlopen_handle(void) { #endif }; - if (_vulkan_handle == NULL) { - _vulkan_handle = glad_get_dlopen_handle(NAMES, sizeof(NAMES) / sizeof(NAMES[0])); + if ({{ template_utils.handle() }} == NULL) { + {{ template_utils.handle() }} = glad_get_dlopen_handle(NAMES, sizeof(NAMES) / sizeof(NAMES[0])); } - return _vulkan_handle; + return {{ template_utils.handle() }}; } static struct _glad_vulkan_userptr glad_vulkan_build_userptr(void *handle, VkInstance instance, VkDevice device) { @@ -95,8 +97,8 @@ int gladLoaderLoadVulkan{{ 'Context' if options.mx }}({{ template_utils.context_ int did_load = 0; struct _glad_vulkan_userptr userptr; - did_load = _vulkan_handle == NULL; - handle = glad_vulkan_dlopen_handle(); + did_load = {{ template_utils.handle() }} == NULL; + handle = glad_vulkan_dlopen_handle({{ 'context' if options.mx }}); if (handle != NULL) { userptr = glad_vulkan_build_userptr(handle, instance, device); @@ -105,7 +107,7 @@ int gladLoaderLoadVulkan{{ 'Context' if options.mx }}({{ template_utils.context_ } if (!version && did_load) { - gladLoaderUnloadVulkan(); + gladLoaderUnloadVulkan{{ 'Context' if options.mx }}({{ 'context' if options.mx }}); } } @@ -139,10 +141,10 @@ int gladLoaderLoadVulkan(VkInstance instance, VkPhysicalDevice physical_device, } {% endif %} -void gladLoaderUnloadVulkan(void) { - if (_vulkan_handle != NULL) { - glad_close_dlopen_handle(_vulkan_handle); - _vulkan_handle = NULL; +void gladLoaderUnloadVulkan{{ 'Context' if options.mx }}({{ template_utils.context_arg(def='void') }}) { + if ({{ template_utils.handle() }} != NULL) { + glad_close_dlopen_handle({{ template_utils.handle() }}); + {{ template_utils.handle() }} = NULL; {% if options.on_demand %} glad_vulkan_internal_loader_global_userptr.vk_handle = NULL; {% endif %} diff --git a/glad/generator/c/templates/loader/vulkan.h b/glad/generator/c/templates/loader/vulkan.h index fadaeac7..4e3c99de 100644 --- a/glad/generator/c/templates/loader/vulkan.h +++ b/glad/generator/c/templates/loader/vulkan.h @@ -7,7 +7,7 @@ GLAD_API_CALL int gladLoaderLoadVulkan{{ 'Context' if options.mx }}({{ template_ {% if options.mx_global %} GLAD_API_CALL int gladLoaderLoadVulkan(VkInstance instance, VkPhysicalDevice physical_device, VkDevice device); {% endif %} -GLAD_API_CALL void gladLoaderUnloadVulkan(void); +GLAD_API_CALL void gladLoaderUnloadVulkan{{ 'Context' if options.mx }}({{ template_utils.context_arg(def='void') }}); {% if options.on_demand %} GLAD_API_CALL void gladLoaderSetVulkanInstance(VkInstance instance); diff --git a/glad/generator/c/templates/template_utils.h b/glad/generator/c/templates/template_utils.h index d2396e62..cc958644 100644 --- a/glad/generator/c/templates/template_utils.h +++ b/glad/generator/c/templates/template_utils.h @@ -10,6 +10,10 @@ {{ 'Glad' + feature_set.name|api + 'Context *context' + suffix if options.mx else def }} {%- endmacro %} +{% macro handle() -%} +{{ 'context->glad' if options.mx else '_glad_' + feature_set.name|api }}_loader_handle +{%- endmacro %} + {% macro protect(symbol) %} {% set protections = spec.protections(symbol, feature_set=feature_set) %} @@ -126,4 +130,4 @@ GLAD_API_CALL {{ command.name|pfn }} glad_debug_{{ command.name }}; #else {{ caller() }} = { 0 }; #endif -{% endmacro %} \ No newline at end of file +{% endmacro %} diff --git a/test/c/compile/gl/header-only+mx/001/test.c b/test/c/compile/gl/header-only+mx/001/test.c index 3972b564..02b2b120 100644 --- a/test/c/compile/gl/header-only+mx/001/test.c +++ b/test/c/compile/gl/header-only+mx/001/test.c @@ -10,7 +10,7 @@ #include int main(void) { - GladGLContext gl; + GladGLContext gl = {0}; (void) gladLoaderLoadGL(); (void) gladLoaderLoadGLContext(&gl); return 0; diff --git a/test/c/compile/gl/header-only+mx/002/test.c b/test/c/compile/gl/header-only+mx/002/test.c index 5619ea4e..ee2cf3de 100644 --- a/test/c/compile/gl/header-only+mx/002/test.c +++ b/test/c/compile/gl/header-only+mx/002/test.c @@ -10,7 +10,7 @@ #include int main(void) { - GladGLContext gl; + GladGLContext gl = {0}; (void) gladLoaderLoadGL(); (void) gladLoaderLoadGLContext(&gl); return 0; diff --git a/test/c/compile/gl/header-only+mx/003/test.c b/test/c/compile/gl/header-only+mx/003/test.c index 1ad0d9e1..f55e20b2 100644 --- a/test/c/compile/gl/header-only+mx/003/test.c +++ b/test/c/compile/gl/header-only+mx/003/test.c @@ -10,7 +10,7 @@ #include int main(void) { - GladGLContext gl; + GladGLContext gl = {0}; (void) gladLoaderLoadGL(); (void) gladLoaderLoadGLContext(&gl); return 0; diff --git a/test/c/compile/gl/header-only+mx/004/test.c b/test/c/compile/gl/header-only+mx/004/test.c index 1af88b71..a39c3648 100644 --- a/test/c/compile/gl/header-only+mx/004/test.c +++ b/test/c/compile/gl/header-only+mx/004/test.c @@ -10,7 +10,7 @@ #include int main(void) { - GladGLContext gl; + GladGLContext gl = {0}; (void) gladLoaderLoadGL(); (void) gladLoaderLoadGLContext(&gl); return 0; diff --git a/test/c/compile/gl/header-only+mx/005/test.c b/test/c/compile/gl/header-only+mx/005/test.c index 1161c01f..0eeaf3d2 100644 --- a/test/c/compile/gl/header-only+mx/005/test.c +++ b/test/c/compile/gl/header-only+mx/005/test.c @@ -10,7 +10,7 @@ #include int main(void) { - GladGLContext gl; + GladGLContext gl = {0}; (void) gladLoaderLoadGL(); (void) gladLoaderLoadGLContext(&gl); return 0; diff --git a/test/c/compile/gl/header-only+mx/006/test.c b/test/c/compile/gl/header-only+mx/006/test.c index 298845ec..8182d0b3 100644 --- a/test/c/compile/gl/header-only+mx/006/test.c +++ b/test/c/compile/gl/header-only+mx/006/test.c @@ -10,7 +10,7 @@ #include int main(void) { - GladGLContext gl; + GladGLContext gl = {0}; (void) gladLoaderLoadGL(); (void) gladLoaderLoadGLContext(&gl); return 0; diff --git a/test/c/compile/gl/header-only+mx/007/test.c b/test/c/compile/gl/header-only+mx/007/test.c index ea121d7c..25298c9b 100644 --- a/test/c/compile/gl/header-only+mx/007/test.c +++ b/test/c/compile/gl/header-only+mx/007/test.c @@ -23,7 +23,7 @@ VOID_FUNCPTR loader(const char *name) { } int main(void) { - GladGLContext gl; + GladGLContext gl = {0}; gladLoadGLContextUserPtr(&gl, loader_userptr, NULL); gladLoadGLContext(&gl, loader); diff --git a/test/c/compile/gl/mx+mx-global/001/test.c b/test/c/compile/gl/mx+mx-global/001/test.c index 5429cbd9..3f95ffc5 100644 --- a/test/c/compile/gl/mx+mx-global/001/test.c +++ b/test/c/compile/gl/mx+mx-global/001/test.c @@ -9,7 +9,7 @@ #include int main(void) { - GladGLContext gl; + GladGLContext gl = {0}; (void) gladLoaderLoadGL(); (void) gladLoaderLoadGLContext(&gl); return 0; diff --git a/test/c/compile/gl/mx+mx-global/002/test.c b/test/c/compile/gl/mx+mx-global/002/test.c index 9f7b3b4c..3eeeab6a 100644 --- a/test/c/compile/gl/mx+mx-global/002/test.c +++ b/test/c/compile/gl/mx+mx-global/002/test.c @@ -9,7 +9,7 @@ #include int main(void) { - GladGLContext gl; + GladGLContext gl = {0}; (void) gladLoaderLoadGL(); (void) gladLoaderLoadGLContext(&gl); return 0; diff --git a/test/c/compile/gl/mx+mx-global/003/test.c b/test/c/compile/gl/mx+mx-global/003/test.c index ed0a1971..e447678a 100644 --- a/test/c/compile/gl/mx+mx-global/003/test.c +++ b/test/c/compile/gl/mx+mx-global/003/test.c @@ -9,7 +9,7 @@ #include int main(void) { - GladGLContext gl; + GladGLContext gl = {0}; (void) gladLoaderLoadGL(); (void) gladLoaderLoadGLContext(&gl); return 0; diff --git a/test/c/compile/gl/mx+mx-global/004/test.c b/test/c/compile/gl/mx+mx-global/004/test.c index 89d34a37..d496d23a 100644 --- a/test/c/compile/gl/mx+mx-global/004/test.c +++ b/test/c/compile/gl/mx+mx-global/004/test.c @@ -9,7 +9,7 @@ #include int main(void) { - GladGLContext gl; + GladGLContext gl = {0}; (void) gladLoaderLoadGL(); (void) gladLoaderLoadGLContext(&gl); return 0; diff --git a/test/c/compile/gl/mx+mx-global/005/test.c b/test/c/compile/gl/mx+mx-global/005/test.c index ad221001..87a68037 100644 --- a/test/c/compile/gl/mx+mx-global/005/test.c +++ b/test/c/compile/gl/mx+mx-global/005/test.c @@ -9,7 +9,7 @@ #include int main(void) { - GladGLContext gl; + GladGLContext gl = {0}; (void) gladLoaderLoadGL(); (void) gladLoaderLoadGLContext(&gl); return 0; diff --git a/test/c/compile/gl/mx+mx-global/006/test.c b/test/c/compile/gl/mx+mx-global/006/test.c index 50317714..aedef2f1 100644 --- a/test/c/compile/gl/mx+mx-global/006/test.c +++ b/test/c/compile/gl/mx+mx-global/006/test.c @@ -9,7 +9,7 @@ #include int main(void) { - GladGLContext gl; + GladGLContext gl = {0}; (void) gladLoaderLoadGL(); (void) gladLoaderLoadGLContext(&gl); return 0; diff --git a/test/c/compile/gl/mx+mx-global/007/test.c b/test/c/compile/gl/mx+mx-global/007/test.c index 5e38e3c3..a4d18e32 100644 --- a/test/c/compile/gl/mx+mx-global/007/test.c +++ b/test/c/compile/gl/mx+mx-global/007/test.c @@ -23,7 +23,7 @@ VOID_FUNCPTR loader(const char *name) { } int main(void) { - GladGLContext gl; + GladGLContext gl = {0}; gladLoadGLContextUserPtr(&gl, loader_userptr, NULL); gladLoadGLContext(&gl, loader); diff --git a/test/c/compile/vulkan/header-only+mx/001/test.c b/test/c/compile/vulkan/header-only+mx/001/test.c index 8fc1b2ee..483655ce 100644 --- a/test/c/compile/vulkan/header-only+mx/001/test.c +++ b/test/c/compile/vulkan/header-only+mx/001/test.c @@ -14,7 +14,7 @@ VOID_FUNCPTR loader_userptr(void *userptr, const char *name) { (void) name; (voi VOID_FUNCPTR loader(const char *name) { (void) name; return NULL; } int main(void) { - GladVulkanContext context; + GladVulkanContext context = {0}; (void) gladLoadVulkanUserPtr(NULL, loader_userptr, NULL); (void) gladLoadVulkanContextUserPtr(&context, NULL, loader_userptr, NULL); (void) gladLoadVulkan(NULL, loader); diff --git a/test/c/compile/vulkan/header-only+mx/002/test.c b/test/c/compile/vulkan/header-only+mx/002/test.c index 33b4288a..368bf85c 100644 --- a/test/c/compile/vulkan/header-only+mx/002/test.c +++ b/test/c/compile/vulkan/header-only+mx/002/test.c @@ -14,7 +14,7 @@ VOID_FUNCPTR loader_userptr(void *userptr, const char *name) { (void) name; (voi VOID_FUNCPTR loader(const char *name) { (void) name; return NULL; } int main(void) { - GladVulkanContext context; + GladVulkanContext context = {0}; (void) gladLoadVulkanUserPtr(NULL, loader_userptr, NULL); (void) gladLoadVulkanContextUserPtr(&context, NULL, loader_userptr, NULL); (void) gladLoadVulkan(NULL, loader); diff --git a/test/c/compile/vulkan/mx+mx-global/001/test.c b/test/c/compile/vulkan/mx+mx-global/001/test.c index 4c9fb857..ecbac275 100644 --- a/test/c/compile/vulkan/mx+mx-global/001/test.c +++ b/test/c/compile/vulkan/mx+mx-global/001/test.c @@ -13,7 +13,7 @@ VOID_FUNCPTR loader_userptr(void *userptr, const char *name) { (void) name; (voi VOID_FUNCPTR loader(const char *name) { (void) name; return NULL; } int main(void) { - GladVulkanContext context; + GladVulkanContext context = {0}; (void) gladLoadVulkanUserPtr(NULL, loader_userptr, NULL); (void) gladLoadVulkanContextUserPtr(&context, NULL, loader_userptr, NULL); (void) gladLoadVulkan(NULL, loader); diff --git a/test/c/compile/vulkan/mx+mx-global/002/test.c b/test/c/compile/vulkan/mx+mx-global/002/test.c index 96574ad5..220b6af8 100644 --- a/test/c/compile/vulkan/mx+mx-global/002/test.c +++ b/test/c/compile/vulkan/mx+mx-global/002/test.c @@ -13,7 +13,7 @@ VOID_FUNCPTR loader_userptr(void *userptr, const char *name) { (void) name; (voi VOID_FUNCPTR loader(const char *name) { (void) name; return NULL; } int main(void) { - GladVulkanContext context; + GladVulkanContext context = {0}; (void) gladLoadVulkanUserPtr(NULL, loader_userptr, NULL); (void) gladLoadVulkanContextUserPtr(&context, NULL, loader_userptr, NULL); (void) gladLoadVulkan(NULL, loader); diff --git a/test/c/run/gl/mx/001/test.c b/test/c/run/gl/mx/001/test.c index b76fe990..8ca0677b 100644 --- a/test/c/run/gl/mx/001/test.c +++ b/test/c/run/gl/mx/001/test.c @@ -26,7 +26,7 @@ GLFWwindow* create_window(void) { } void run(GLFWwindow *window) { - GladGLContext context; + GladGLContext context = {0}; glfwMakeContextCurrent(window); diff --git a/test/c/run/gl/mx/002/test.c b/test/c/run/gl/mx/002/test.c index 0248984c..57b6a3d2 100644 --- a/test/c/run/gl/mx/002/test.c +++ b/test/c/run/gl/mx/002/test.c @@ -26,7 +26,7 @@ GLFWwindow* create_window(void) { } void run(GLFWwindow *window) { - GladGLContext context; + GladGLContext context = {0}; glfwMakeContextCurrent(window); diff --git a/test/c/run/gl/mx/003/test.c b/test/c/run/gl/mx/003/test.c index 1b95be0e..374f0339 100644 --- a/test/c/run/gl/mx/003/test.c +++ b/test/c/run/gl/mx/003/test.c @@ -28,7 +28,7 @@ GLFWwindow* create_window(void) { } void run(GLFWwindow *window) { - GladGLContext context; + GladGLContext context = {0}; context.userptr = (void*) &context; glfwMakeContextCurrent(window); diff --git a/test/c/run/gl/mx/004/test.c b/test/c/run/gl/mx/004/test.c index 957dda72..602543ca 100644 --- a/test/c/run/gl/mx/004/test.c +++ b/test/c/run/gl/mx/004/test.c @@ -28,7 +28,7 @@ GLFWwindow* create_window(void) { } void run(GLFWwindow *window) { - GladGLContext context; + GladGLContext context = {0}; context.userptr = (void*) &context; glfwMakeContextCurrent(window);