@@ -20,9 +20,11 @@ static GLADapiproc glad_egl_get_proc(void *vuserptr, const char* name) {
20
20
return result ;
21
21
}
22
22
23
- static void * _egl_handle = NULL ;
23
+ {% if not options .mx %}
24
+ static void * {{ template_utils .handle () }} = NULL ;
25
+ {% endif %}
24
26
25
- static void * glad_egl_dlopen_handle (void ) {
27
+ static void * glad_egl_dlopen_handle ({{ template_utils . context_arg ( def = ' void' ) }} ) {
26
28
#if GLAD_PLATFORM_APPLE
27
29
static const char * NAMES [] = {"libEGL.dylib" };
28
30
#elif GLAD_PLATFORM_WIN32
@@ -31,11 +33,11 @@ static void* glad_egl_dlopen_handle(void) {
31
33
static const char * NAMES [] = {"libEGL.so.1" , "libEGL.so" };
32
34
#endif
33
35
34
- if (_egl_handle == NULL ) {
35
- _egl_handle = glad_get_dlopen_handle (NAMES , sizeof (NAMES ) / sizeof (NAMES [0 ]));
36
+ if ({{ template_utils . handle () }} = = NULL) {
37
+ {{ template_utils . handle () }} = glad_get_dlopen_handle (NAMES , sizeof (NAMES ) / sizeof (NAMES [0 ]));
36
38
}
37
39
38
- return _egl_handle ;
40
+ return {{ template_utils . handle () }} ;
39
41
}
40
42
41
43
static struct _glad_egl_userptr glad_egl_build_userptr (void * handle ) {
@@ -46,30 +48,34 @@ static struct _glad_egl_userptr glad_egl_build_userptr(void *handle) {
46
48
}
47
49
48
50
{% if not options .on_demand %}
49
- int gladLoaderLoadEGL ( EGLDisplay display ) {
51
+ int gladLoaderLoadEGL {{ 'Context' if options . mx }}({{ template_utils . context_arg ( ',' ) }} EGLDisplay display ) {
50
52
int version = 0 ;
51
- void * handle = NULL ;
53
+ void * handle ;
52
54
int did_load = 0 ;
53
55
struct _glad_egl_userptr userptr ;
54
56
55
- did_load = _egl_handle == NULL ;
56
- handle = glad_egl_dlopen_handle ();
57
- if (handle != NULL ) {
57
+ did_load = {{ template_utils . handle () }} == NULL ;
58
+ handle = glad_egl_dlopen_handle ({{ 'context' if options . mx }} );
59
+ if (handle ) {
58
60
userptr = glad_egl_build_userptr (handle );
59
61
60
- if (userptr .get_proc_address_ptr != NULL ) {
61
- version = gladLoadEGLUserPtr (display , glad_egl_get_proc , & userptr );
62
- }
62
+ version = gladLoadEGL {{ 'Context' if options .mx }}UserPtr ({{ 'context, ' if options .mx }}display , glad_egl_get_proc , & userptr );
63
63
64
- if (! version && did_load ) {
65
- gladLoaderUnloadEGL ( );
64
+ if (did_load ) {
65
+ gladLoaderUnloadEGL {{ 'Context' if options . mx }}({{ 'context' if options . mx }} );
66
66
}
67
67
}
68
68
69
69
return version ;
70
70
}
71
71
{% endif %}
72
72
73
+ {% if options .mx_global %}
74
+ int gladLoaderLoadEGL (EGLDisplay display ) {
75
+ return gladLoaderLoadEGLContext (gladGet {{ feature_set .name |api }}Context (), display );
76
+ }
77
+ {% endif %}
78
+
73
79
{% if options .on_demand %}
74
80
{% call template_utils .zero_initialized () %}static struct _glad_egl_userptr glad_egl_internal_loader_global_userptr {% endcall %}
75
81
static GLADapiproc glad_egl_internal_loader_get_proc (const char * name ) {
@@ -81,19 +87,38 @@ static GLADapiproc glad_egl_internal_loader_get_proc(const char *name) {
81
87
}
82
88
{% endif %}
83
89
84
- void gladLoaderUnloadEGL () {
85
- if (_egl_handle != NULL ) {
86
- glad_close_dlopen_handle (_egl_handle );
87
- _egl_handle = NULL ;
90
+ {% if options .mx_global %}
91
+ void gladLoaderResetEGL (void ) {
92
+ gladLoaderResetEGLContext (gladGetEGLContext ());
93
+ }
94
+ {% endif %}
95
+
96
+ void gladLoaderUnloadEGL {{ 'Context' if options .mx }}({{ template_utils .context_arg (def = 'void' ) }}) {
97
+ if ({{ template_utils .handle () }} != NULL ) {
98
+ glad_close_dlopen_handle ({{ template_utils .handle () }});
99
+ {{ template_utils .handle () }} = NULL ;
88
100
{% if options .on_demand %}
89
101
glad_egl_internal_loader_global_userptr .handle = NULL ;
90
102
{% endif %}
91
103
}
92
104
105
+ {% if not options .mx %}
93
106
gladLoaderResetEGL ();
107
+ { % else %}
108
+ gladLoaderResetEGLContext (context );
109
+ {% endif %}
94
110
}
95
111
96
- void gladLoaderResetEGL () {
112
+ {%if options .mx_global %}
113
+ void gladLoaderUnloadEGL (void ) {
114
+ gladLoaderUnloadEGLContext (gladGet {{ feature_set .name |api }}Context ());
115
+ }
116
+ {% endif %}
117
+
118
+ void gladLoaderResetEGL {{ 'Context' if options .mx }}({{ template_utils .context_arg (def = 'void' ) }}) {
119
+ {% if options .mx %}
120
+ memset (context , 0 , sizeof (GladEGLContext ));
121
+ { % else %}
97
122
{% if not options .on_demand %}
98
123
{% for feature in feature_set .features %}
99
124
GLAD_ {{ feature .name }} = 0 ;
@@ -114,6 +139,7 @@ void gladLoaderResetEGL() {
114
139
{{ command .name |ctx }} = NULL ;
115
140
{% endfor %}
116
141
{% endfor %}
142
+ {% endif %}
117
143
}
118
144
119
145
#endif /* GLAD_EGL */
0 commit comments