mach: allow choosing Wayland/X11 at runtime via env var
Quoting myself:
BTW, for tests this doesn't help - but in a real application (like Mach apps) GLFW now lets us request a specific platform via
glfw.Inithints.glfw.Init(.{.platform = .wayland})should force Wayland usage (default is.any) - we should add a standard environment variable to select this in any Mach application, similar to how we haveGPU_BACKEND=openglas an option.
We should add a standard env var, maybe PLATFORM=wayland, PLATFORM=x11 to allow choosing.
Related to https://github.com/hexops/mach/pull/374
IMO mach should namespace its environment variables with a MACH_ prefix to avoid conflicts with other programs. It wouldn’t surprise me if some other software also reads $PLATFORM, it’s pretty generic.
Shouldn't this also be usable if you just want to use glfw without mach? I think PLATFORM or GLFW_PLATFORM should be the env var
I agree MACH_PLATFORM should be the env var name, and GPU_BACKEND renamed to MACH_GPU_BACKEND.
@PiergiorgioZagaria If you use GLFW, you would pass the option to GLFW via glfw.Init(.{.platform = .wayland}) yourself. If you like, you can use an environment variable of your own. But this code will not live in the GLFW package, it would be in the Mach app abstraction.
Ok, then I will revert the last commit I pushed to the PR
Fixed in https://github.com/hexops/machengine.org/commit/63f9bbeb1e07915e1057b476c621156f182207ed