mach icon indicating copy to clipboard operation
mach copied to clipboard

mach: allow choosing Wayland/X11 at runtime via env var

Open emidoots opened this issue 3 years ago • 4 comments

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.Init hints. 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 have GPU_BACKEND=opengl as 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

emidoots avatar Jun 28 '22 18:06 emidoots

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.

ifreund avatar Jun 28 '22 22:06 ifreund

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

PiergiorgioZagaria avatar Jun 29 '22 18:06 PiergiorgioZagaria

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.

emidoots avatar Jun 29 '22 18:06 emidoots

Ok, then I will revert the last commit I pushed to the PR

PiergiorgioZagaria avatar Jun 29 '22 19:06 PiergiorgioZagaria

Fixed in https://github.com/hexops/machengine.org/commit/63f9bbeb1e07915e1057b476c621156f182207ed

emidoots avatar Jul 31 '23 01:07 emidoots