@@ -23,7 +23,8 @@ static struct gloam_gl_load_userptr gloam_gl_load_state;
2323
2424/* GL desktop adapter — matches GloamLoadFunc (__cdecl), dispatches through
2525 the correctly-typed platform proc-addr pointer stored in the userptr. */
26- static GloamAPIProc gloam_gl_get_proc(const char *name) {
26+ static GloamAPIProc gloam_gl_get_proc(const char *name)
27+ {
2728 GloamAPIProc result = NULL;
2829 struct gloam_gl_load_userptr *u = &gloam_gl_load_state;
2930 if (!u->handle) return NULL;
@@ -41,15 +42,17 @@ static GloamAPIProc gloam_gl_get_proc(const char *name) {
4142
4243/* GLES adapter: all symbols (including extensions) are exported directly from
4344 the GLES library so plain dlsym is sufficient — no platform indirection. */
44- static GloamAPIProc gloam_gles_get_proc(const char *name) {
45+ static GloamAPIProc gloam_gles_get_proc(const char *name)
46+ {
4547 struct gloam_gl_load_userptr *u = &gloam_gl_load_state;
4648 if (!u->handle) return NULL;
4749 return (GloamAPIProc)gloam_dlsym(u->handle, name);
4850}
4951
5052{% - for api in fs .apis %}
5153
52- int gloamLoaderLoad{{ api | api_display }}Context({{ u.ctx_arg() }}) {
54+ int gloamLoaderLoad{{ api | api_display }}Context({{ u.ctx_arg() }})
55+ {
5356 int did_open = 0, version;
5457{% if api in ["gles1" , "gles2" ] %}
5558 static const char * const kLibNames[] = {
@@ -107,27 +110,32 @@ int gloamLoaderLoad{{ api | api_display }}Context({{ u.ctx_arg() }}) {
107110 return version;
108111}
109112
110- int gloamLoaderLoad{{ api | api_display }}(void) {
113+ int gloamLoaderLoad{{ api | api_display }}(void)
114+ {
111115 return gloamLoaderLoad{{ api | api_display }}Context(&gloam_{{ fs.spec_name }}_context);
112116}
113117
114- void gloamLoaderUnload{{ api | api_display }}Context({{ u.ctx_arg() }}) {
118+ void gloamLoaderUnload{{ api | api_display }}Context({{ u.ctx_arg() }})
119+ {
115120 if (context->gloam_loader_handle) {
116121 gloam_dlclose(context->gloam_loader_handle);
117122 context->gloam_loader_handle = NULL;
118123 }
119124 gloamLoaderReset{{ api | api_display }}Context(context);
120125}
121126
122- void gloamLoaderUnload{{ api | api_display }}(void) {
127+ void gloamLoaderUnload{{ api | api_display }}(void)
128+ {
123129 gloamLoaderUnload{{ api | api_display }}Context(&gloam_{{ fs.spec_name }}_context);
124130}
125131
126- void gloamLoaderReset{{ api | api_display }}Context({{ u.ctx_arg() }}) {
132+ void gloamLoaderReset{{ api | api_display }}Context({{ u.ctx_arg() }})
133+ {
127134 memset(context, 0, sizeof(*context));
128135}
129136
130- void gloamLoaderReset{{ api | api_display }}(void) {
137+ void gloamLoaderReset{{ api | api_display }}(void)
138+ {
131139 gloamLoaderReset{{ api | api_display }}Context(&gloam_{{ fs.spec_name }}_context);
132140}
133141{% - endfor %}
@@ -153,7 +161,8 @@ struct gloam_egl_load_userptr {
153161};
154162static struct gloam_egl_load_userptr gloam_egl_load_state;
155163
156- static GloamAPIProc gloam_egl_get_proc(const char *name) {
164+ static GloamAPIProc gloam_egl_get_proc(const char *name)
165+ {
157166 struct gloam_egl_load_userptr *u = &gloam_egl_load_state;
158167 GloamAPIProc result = (GloamAPIProc)gloam_dlsym(u->handle, name);
159168 if (!result && u->get_proc_address)
@@ -162,7 +171,8 @@ static GloamAPIProc gloam_egl_get_proc(const char *name) {
162171}
163172
164173{% for api in fs .apis %}
165- int gloamLoaderLoad{{ api | api_display }}Context({{ u.ctx_arg(', ') }}EGLDisplay display) {
174+ int gloamLoaderLoad{{ api | api_display }}Context({{ u.ctx_arg(', ') }}EGLDisplay display)
175+ {
166176 int did_open = 0, version;
167177 if (!context->gloam_loader_handle) {
168178 context->gloam_loader_handle = gloam_open_library(
@@ -185,27 +195,32 @@ int gloamLoaderLoad{{ api | api_display }}Context({{ u.ctx_arg(', ') }}EGLDispla
185195 return version;
186196}
187197
188- int gloamLoaderLoad{{ api | api_display }}(EGLDisplay display) {
198+ int gloamLoaderLoad{{ api | api_display }}(EGLDisplay display)
199+ {
189200 return gloamLoaderLoad{{ api | api_display }}Context(&gloam_{{ fs.spec_name }}_context, display);
190201}
191202
192- void gloamLoaderUnload{{ api | api_display }}Context({{ u.ctx_arg() }}) {
203+ void gloamLoaderUnload{{ api | api_display }}Context({{ u.ctx_arg() }})
204+ {
193205 if (context->gloam_loader_handle) {
194206 gloam_dlclose(context->gloam_loader_handle);
195207 context->gloam_loader_handle = NULL;
196208 }
197209 gloamLoaderReset{{ api | api_display }}Context(context);
198210}
199211
200- void gloamLoaderUnload{{ api | api_display }}(void) {
212+ void gloamLoaderUnload{{ api | api_display }}(void)
213+ {
201214 gloamLoaderUnload{{ api | api_display }}Context(&gloam_{{ fs.spec_name }}_context);
202215}
203216
204- void gloamLoaderReset{{ api | api_display }}Context({{ u.ctx_arg() }}) {
217+ void gloamLoaderReset{{ api | api_display }}Context({{ u.ctx_arg() }})
218+ {
205219 memset(context, 0, sizeof(*context));
206220}
207221
208- void gloamLoaderReset{{ api | api_display }}(void) {
222+ void gloamLoaderReset{{ api | api_display }}(void)
223+ {
209224 gloamLoaderReset{{ api | api_display }}Context(&gloam_{{ fs.spec_name }}_context);
210225}
211226{% - endfor %}
@@ -227,7 +242,8 @@ struct gloam_glx_load_userptr {
227242};
228243static struct gloam_glx_load_userptr gloam_glx_load_state;
229244
230- static GloamAPIProc gloam_glx_get_proc(const char *name) {
245+ static GloamAPIProc gloam_glx_get_proc(const char *name)
246+ {
231247 struct gloam_glx_load_userptr *u = &gloam_glx_load_state;
232248 GloamAPIProc result = NULL;
233249 if (u->get_proc_address) result = u->get_proc_address(name);
@@ -237,7 +253,8 @@ static GloamAPIProc gloam_glx_get_proc(const char *name) {
237253
238254{% - for api in fs .apis %}
239255
240- int gloamLoaderLoad{{ api | api_display }}Context({{ u.ctx_arg(', ') }}Display *display, int screen) {
256+ int gloamLoaderLoad{{ api | api_display }}Context({{ u.ctx_arg(', ') }}Display *display, int screen)
257+ {
241258 int did_open = 0, version;
242259 if (!context->gloam_loader_handle) {
243260 context->gloam_loader_handle = gloam_open_library(
@@ -261,27 +278,32 @@ int gloamLoaderLoad{{ api | api_display }}Context({{ u.ctx_arg(', ') }}Display *
261278 return version;
262279}
263280
264- int gloamLoaderLoad{{ api | api_display }}(Display *display, int screen) {
281+ int gloamLoaderLoad{{ api | api_display }}(Display *display, int screen)
282+ {
265283 return gloamLoaderLoad{{ api | api_display }}Context(&gloam_{{ fs.spec_name }}_context, display, screen);
266284}
267285
268- void gloamLoaderUnload{{ api | api_display }}Context({{ u.ctx_arg() }}) {
286+ void gloamLoaderUnload{{ api | api_display }}Context({{ u.ctx_arg() }})
287+ {
269288 if (context->gloam_loader_handle) {
270289 gloam_dlclose(context->gloam_loader_handle);
271290 context->gloam_loader_handle = NULL;
272291 }
273292 gloamLoaderReset{{ api | api_display }}Context(context);
274293}
275294
276- void gloamLoaderUnload{{ api | api_display }}(void) {
295+ void gloamLoaderUnload{{ api | api_display }}(void)
296+ {
277297 gloamLoaderUnload{{ api | api_display }}Context(&gloam_{{ fs.spec_name }}_context);
278298}
279299
280- void gloamLoaderReset{{ api | api_display }}Context({{ u.ctx_arg() }}) {
300+ void gloamLoaderReset{{ api | api_display }}Context({{ u.ctx_arg() }})
301+ {
281302 memset(context, 0, sizeof(*context));
282303}
283304
284- void gloamLoaderReset{{ api | api_display }}(void) {
305+ void gloamLoaderReset{{ api | api_display }}(void)
306+ {
285307 gloamLoaderReset{{ api | api_display }}Context(&gloam_{{ fs.spec_name }}_context);
286308}
287309{% - endfor %}
@@ -298,7 +320,8 @@ struct gloam_wgl_load_userptr {
298320};
299321static struct gloam_wgl_load_userptr gloam_wgl_load_state;
300322
301- static GloamAPIProc gloam_wgl_get_proc(const char *name) {
323+ static GloamAPIProc gloam_wgl_get_proc(const char *name)
324+ {
302325 struct gloam_wgl_load_userptr *u = &gloam_wgl_load_state;
303326 GloamAPIProc result = NULL;
304327 if (u->wgl_get_proc) result = u->wgl_get_proc(name);
@@ -307,7 +330,8 @@ static GloamAPIProc gloam_wgl_get_proc(const char *name) {
307330}
308331
309332{% - for api in fs .apis %}
310- int gloamLoaderLoad{{ api | api_display }}Context({{ u.ctx_arg(', ') }}HDC hdc) {
333+ int gloamLoaderLoad{{ api | api_display }}Context({{ u.ctx_arg(', ') }}HDC hdc)
334+ {
311335 int did_open = 0, version;
312336 if (!context->gloam_loader_handle) {
313337 context->gloam_loader_handle = gloam_open_library(
@@ -331,27 +355,32 @@ int gloamLoaderLoad{{ api | api_display }}Context({{ u.ctx_arg(', ') }}HDC hdc)
331355 return version;
332356}
333357
334- int gloamLoaderLoad{{ api | api_display }}(HDC hdc) {
358+ int gloamLoaderLoad{{ api | api_display }}(HDC hdc)
359+ {
335360 return gloamLoaderLoad{{ api | api_display }}Context(&gloam_{{ fs.spec_name }}_context, hdc);
336361}
337362
338- void gloamLoaderUnload{{ api | api_display }}Context({{ u.ctx_arg() }}) {
363+ void gloamLoaderUnload{{ api | api_display }}Context({{ u.ctx_arg() }})
364+ {
339365 if (context->gloam_loader_handle) {
340366 gloam_dlclose(context->gloam_loader_handle);
341367 context->gloam_loader_handle = NULL;
342368 }
343369 gloamLoaderReset{{ api | api_display }}Context(context);
344370}
345371
346- void gloamLoaderUnload{{ api | api_display }}(void) {
372+ void gloamLoaderUnload{{ api | api_display }}(void)
373+ {
347374 gloamLoaderUnload{{ api | api_display }}Context(&gloam_{{ fs.spec_name }}_context);
348375}
349376
350- void gloamLoaderReset{{ api | api_display }}Context({{ u.ctx_arg() }}) {
377+ void gloamLoaderReset{{ api | api_display }}Context({{ u.ctx_arg() }})
378+ {
351379 memset(context, 0, sizeof(*context));
352380}
353381
354- void gloamLoaderReset{{ api | api_display }}(void) {
382+ void gloamLoaderReset{{ api | api_display }}(void)
383+ {
355384 gloamLoaderReset{{ api | api_display }}Context(&gloam_{{ fs.spec_name }}_context);
356385}
357386{% - endfor %}
@@ -364,8 +393,8 @@ void gloamLoaderReset{{ api | api_display }}(void) {
364393 * already set, stores vkGetInstanceProcAddr in the context, then delegates to
365394 * gloamVulkanDiscoverContext. Follows the same additive multi-call contract
366395 * as the underlying discover function. */
367- int gloamLoaderLoadVulkanContext({{ u.ctx_arg(', ') }}VkInstance instance,
368- VkPhysicalDevice physical_device, VkDevice device) {
396+ int gloamLoaderLoadVulkanContext({{ u.ctx_arg(', ') }}VkInstance instance, VkPhysicalDevice physical_device, VkDevice device)
397+ {
369398 int did_open = 0;
370399 int version;
371400 void *handle;
@@ -400,31 +429,35 @@ int gloamLoaderLoadVulkanContext({{ u.ctx_arg(', ') }}VkInstance instance,
400429 return version;
401430}
402431
403- int gloamLoaderLoadVulkan(VkInstance instance, VkPhysicalDevice physical_device,
404- VkDevice device) {
432+ int gloamLoaderLoadVulkan(VkInstance instance, VkPhysicalDevice physical_device, VkDevice device)
433+ {
405434 return gloamLoaderLoadVulkanContext(&gloam_vk_context, instance,
406435 physical_device, device);
407436}
408437
409438/* Close the library handle (if set) then zero all context state. */
410- void gloamLoaderUnloadVulkanContext({{ u.ctx_arg() }}) {
439+ void gloamLoaderUnloadVulkanContext({{ u.ctx_arg() }})
440+ {
411441 if (context->gloam_loader_handle) {
412442 gloam_dlclose(context->gloam_loader_handle);
413443 context->gloam_loader_handle = NULL;
414444 }
415445 gloamLoaderResetVulkanContext(context);
416446}
417447
418- void gloamLoaderUnloadVulkan(void) {
448+ void gloamLoaderUnloadVulkan(void)
449+ {
419450 gloamLoaderUnloadVulkanContext(&gloam_vk_context);
420451}
421452
422453/* Zero all context state without touching the library handle. */
423- void gloamLoaderResetVulkanContext({{ u.ctx_arg() }}) {
454+ void gloamLoaderResetVulkanContext({{ u.ctx_arg() }})
455+ {
424456 memset(context, 0, sizeof(*context));
425457}
426458
427- void gloamLoaderResetVulkan(void) {
459+ void gloamLoaderResetVulkan(void)
460+ {
428461 gloamLoaderResetVulkanContext(&gloam_vk_context);
429462}
430463{% endif %}
0 commit comments