From 74db5a2b60781683c9c6e7a4f7b0e298c24c3afb Mon Sep 17 00:00:00 2001 From: lmp Date: Wed, 29 Jan 2025 10:21:55 +0100 Subject: [PATCH] sdl, docs: support pkgconf `sdl2-compat` via `-d sdl_compat` --- README.md | 4 ++++ c/sdl.c.v | 7 ++++++- 2 files changed, 10 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 54132489..615f88c5 100644 --- a/README.md +++ b/README.md @@ -59,6 +59,10 @@ SDL2 is backwards compatible - so anything written against `v2.0.8` can be compi against newer versions of the SDL2 library. Also note that SDL2 **is not** compatible with SDL `v1.x`. +SDL2 is however compatible with SDL3 through the [`sdl2-compat`](https://github.com/libsdl-org/sdl2-compat) layer. +Which makes it possible to use the SDL2 API through the SDL3 libraries. +You can tell `sdl` to use this compatibility layer on systems that support `pkgconfig` by +passing the compile time flag `-d sdl_compat` when building your `sdl`/SDL2 based V application. ## Notes on garbage collection and memory issues diff --git a/c/sdl.c.v b/c/sdl.c.v index 8ba2289d..a8ea3516 100644 --- a/c/sdl.c.v +++ b/c/sdl.c.v @@ -13,7 +13,12 @@ $if !windows { // This is especially useful when building/linking against a // custom compiled version of the libs on *nix. $if !sdl_no_compile_flags ? { - #pkgconfig --cflags --libs sdl2 + $if sdl_compat ? { + // Use SDL2 through SDL3 via the compatibility layer + #pkgconfig --cflags --libs sdl2_compat + } $else { + #pkgconfig --cflags --libs sdl2 + } } } } $else {