Skip to content

Commit

Permalink
demos: build both glfw and sdl
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
haasn committed Mar 21, 2021
1 parent 8e535ed commit 1091353
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 14 deletions.
17 changes: 7 additions & 10 deletions demos/meson.build
Original file line number Diff line number Diff line change
Expand Up @@ -24,44 +24,41 @@ 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],
)}
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],
)}
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
Expand Down
5 changes: 1 addition & 4 deletions demos/window_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down

0 comments on commit 1091353

Please sign in to comment.