From 10913533a59ee3c790274467af0541a9893efcb6 Mon Sep 17 00:00:00 2001 From: Niklas Haas Date: Sun, 21 Mar 2021 19:02:00 +0100 Subject: [PATCH] demos: build both glfw and sdl Apparently GLFW has a habit of not working on Wayland, because they hard-code the platform at compile time. Might as well just provide all four variants, who really cares about a few extra binaries? The proper solution would be to make loading the windowing system dynamic at runtime, but that probably requires handling command line arguments and I can't really be bothered. Also suppress a warning in the sdl code by rewriting it slightly. --- demos/meson.build | 17 +++++++---------- demos/window_sdl.c | 5 +---- 2 files changed, 8 insertions(+), 14 deletions(-) diff --git a/demos/meson.build b/demos/meson.build index 592daacc..c7fd461a 100644 --- a/demos/meson.build +++ b/demos/meson.build @@ -24,12 +24,10 @@ nuklear = declare_dependency( apis = {} -# Enable all supported combinations of API and windowing system, preferring -# GLFW and falling back to SDL if the former is not supported +# Enable all supported combinations of API and windowing system if glfw.found() - if vulkan.found() - apis += {'vk': declare_dependency( + apis += {'glfw-vk': declare_dependency( sources: 'window_glfw.c', compile_args: '-DUSE_VK', dependencies: [libplacebo, vulkan, glfw], @@ -37,17 +35,17 @@ if glfw.found() endif if opengl.found() - apis += {'gl': declare_dependency( + apis += {'glfw-gl': declare_dependency( sources: 'window_glfw.c', compile_args: '-DUSE_GL', dependencies: [libplacebo, glfw], )} endif +endif -elif sdl.found() - +if sdl.found() if vulkan.found() - apis += {'vk': declare_dependency( + apis += {'sdl-vk': declare_dependency( sources: 'window_sdl.c', compile_args: '-DUSE_VK', dependencies: [libplacebo, vulkan, sdl], @@ -55,13 +53,12 @@ elif sdl.found() endif if opengl.found() - apis += {'gl': declare_dependency( + apis += {'sdl-gl': declare_dependency( sources: 'window_sdl.c', compile_args: '-DUSE_GL', dependencies: [libplacebo, sdl], )} endif - endif if apis.keys().length() == 0 diff --git a/demos/window_sdl.c b/demos/window_sdl.c index 6a467e63..4156762c 100644 --- a/demos/window_sdl.c +++ b/demos/window_sdl.c @@ -73,12 +73,9 @@ struct window *window_create(struct pl_context *ctx, const char *title, } const char **exts = malloc(num * sizeof(const char *)); + SDL_Vulkan_GetInstanceExtensions(p->win, &num, exts); iparams.extensions = exts; iparams.num_extensions = num; - assert(exts); - - bool ok = SDL_Vulkan_GetInstanceExtensions(p->win, &num, exts); - assert(ok); p->vk_inst = pl_vk_inst_create(ctx, &iparams); free(exts);