Skip to content

Commit

Permalink
sdl, docs: support pkgconf sdl2-compat via -d sdl_compat (#935)
Browse files Browse the repository at this point in the history
  • Loading branch information
larpon authored Jan 29, 2025
1 parent 1590762 commit 30f81aa
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 4 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
7 changes: 6 additions & 1 deletion c/sdl.c.v
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand Down

0 comments on commit 30f81aa

Please sign in to comment.