raysan5 / raylib

A simple and easy-to-use library to enjoy videogames programming
http://www.raylib.com
zlib License
22.45k stars 2.25k forks source link

[build] Cannot change platform backend when building raylib with Zig for Linux #4457

Open Ar1gin opened 2 hours ago

Ar1gin commented 2 hours ago

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-L53

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

Possible fix

I got it to work by doing following changes to build.zig:

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.

wwderw commented 1 hour ago

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.