Open Ar1gin opened 2 hours ago
It's impossible to choose any backend other than GLFW if building with zig.
PLATFORM_DESKTOP is set together with the platform backend you chose (PLATFORM_DESKTOP_SDL in my case) https://github.com/raysan5/raylib/blob/9e2591e612bcf651ed8dca0d4ba242b64c694f25/build.zig#L44-L53
PLATFORM_DESKTOP
PLATFORM_DESKTOP_SDL
PLATFORM_DESKTOP defaults to PLATFORM_DESKTOP_GLFW. Then, platforms/rcore_desktop_glfw.c gets included without any regard to the backend choice. https://github.com/raysan5/raylib/blob/9e2591e612bcf651ed8dca0d4ba242b64c694f25/src/rcore.c#L511-L519
PLATFORM_DESKTOP_GLFW
platforms/rcore_desktop_glfw.c
I got it to work by doing following changes to build.zig:
build.zig
raylib.defineCMacro("PLATFORM_DESKTOP", null);
setDesktopPlatform()
raylib.linkSystemLibrary("SDL2");
compileRaylib()
-Dplatform=sdl
Not opening a PR as I am unsure how to properly fix the problem.
Also, I may be missing something, I just need raylib to work with touchscreens (which are only supported by SDL backend) in my little zig project.
My work around for linux and changing the backend (I use Angle), is to make changes to the make file (platform, gl version, and CC and AR) and run Make with Zig that way.
Just an option.
Issue description
It's impossible to choose any backend other than GLFW if building with zig.
PLATFORM_DESKTOP
is set together with the platform backend you chose (PLATFORM_DESKTOP_SDL
in my case) https://github.com/raysan5/raylib/blob/9e2591e612bcf651ed8dca0d4ba242b64c694f25/build.zig#L44-L53PLATFORM_DESKTOP
defaults toPLATFORM_DESKTOP_GLFW
. Then,platforms/rcore_desktop_glfw.c
gets included without any regard to the backend choice. https://github.com/raysan5/raylib/blob/9e2591e612bcf651ed8dca0d4ba242b64c694f25/src/rcore.c#L511-L519Possible fix
I got it to work by doing following changes to
build.zig
:raylib.defineCMacro("PLATFORM_DESKTOP", null);
fromsetDesktopPlatform()
(why was it there in the first place?)raylib.linkSystemLibrary("SDL2");
tocompileRaylib()
(SDL2 is not linked even with-Dplatform=sdl
!)Not opening a PR as I am unsure how to properly fix the problem.
Also, I may be missing something, I just need raylib to work with touchscreens (which are only supported by SDL backend) in my little zig project.