Add support for importing models via launcher arguments

This commit is contained in:
ducksx3
2023-10-21 04:03:23 +03:00
committed by Illusion
parent 8b5143d6cb
commit fecdb52d1b
+13 -1
View File
@@ -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<dyn std::error::Error>> {
@@ -183,6 +184,17 @@ fn main() -> anyhow::Result<(), Box<dyn std::error::Error>> {
let scene_fb = create_scene_framebuffer();
// Import models from launch arguments
let args: Vec<String> = env::args().collect();
if args.len() > 1 {
let paths: Vec<PathBuf> = 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;