From fecdb52d1b2cef53fc6131cbd828c40c22f12334 Mon Sep 17 00:00:00 2001 From: ducksx3 Date: Sat, 21 Oct 2023 02:41:21 +0200 Subject: [PATCH] Add support for importing models via launcher arguments --- src/main.rs | 14 +++++++++++++- 1 file changed, 13 insertions(+), 1 deletion(-) diff --git a/src/main.rs b/src/main.rs index a0f67c0..c44239c 100644 --- a/src/main.rs +++ b/src/main.rs @@ -1,7 +1,8 @@ use glfw::{Action, Context, Key, Modifiers}; use glad_gl::gl; use anyhow; - +use std::env; +use std::path::PathBuf; use threedobs::{shader, ui::ui, utils}; fn main() -> anyhow::Result<(), Box> { @@ -183,6 +184,17 @@ fn main() -> anyhow::Result<(), Box> { let scene_fb = create_scene_framebuffer(); + // Import models from launch arguments + let args: Vec = env::args().collect(); + if args.len() > 1 { + let paths: Vec = args + .iter() + .skip(1) + .map(|arg| PathBuf::from(arg)) + .collect(); + utils::import_models_from_paths(&paths, &mut state); + } + // main loop while !window.should_close() { let current_frame = glfw.get_time() as f32;