You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I don't find it convenient to move into the directory of the examples to get them to work, as the paths to the resources are relative to that directory.
So, I propose to add an optional ROOT environment variable to each example, such as:
+let root = Bos.OS.Env.var "ROOT"+
let setup () =
let open Raylib in
init_window width height "raylib [textures] example - bunnymark";
- let tex_bunny = load_texture "resources/wabbit_alpha.png" in+ let tex_bunny =+ let path =+ match root with+ | Some root -> Fmt.str "%s/resources/wabbit_alpha.png" root+ | None -> "resources/wabbit_alpha.png"+ in+ load_texture path+ in
We can also put this code in some helper library to avoid duplications.
I share your sentiment, but I'm not convinced that typing ROOT=... is much more convenient than cd ....
What about this: When lauching with dune exec, the executables have their Sys.executable_name set to an absolute path. With that, we could get the resoure path like
letrespathres=ifFilename.is_relative Sys.executable_name then res
elseFilename.(concat (dirname Sys.executable_name) res)
in
It's not the most robust solution in the world but works for the examples, and saves typing out the directory all-together.
I don't find it convenient to move into the directory of the examples to get them to work, as the paths to the resources are relative to that directory.
So, I propose to add an optional
ROOT
environment variable to each example, such as:We can also put this code in some helper library to avoid duplications.
So that we can run them with:
ROOT=examples/textures dune exec -- examples/textures/textures_bunnymark_ocaml_types.exe
What do you think?
The text was updated successfully, but these errors were encountered: