diff --git a/src/parser/mtl.rs b/src/parser/mtl.rs index 61b69db..68a50d0 100644 --- a/src/parser/mtl.rs +++ b/src/parser/mtl.rs @@ -71,7 +71,7 @@ impl LineParser for MtlParser { full_path.push(split[4].to_owned()); Ok(Element::Texture(first.to_owned(), full_path.to_str().unwrap().to_owned(), size)) } else { - Err(ParserError::UnexpectedKeyword(path.to_owned(), line_number, split[2].to_owned())) + Err(ParserError::UnexpectedKeyword(path.to_owned(), line_number, split[1].to_owned())) } }, diff --git a/src/renderer.rs b/src/renderer.rs index 19ace14..66f13c0 100644 --- a/src/renderer.rs +++ b/src/renderer.rs @@ -136,7 +136,11 @@ impl Renderer { /// Creates a SrgbTexture from a path to an image. pub fn make_texture(&self, path: &str) -> SrgbTexture2d { - let image = image::open(path).unwrap().to_rgba(); + let image = match image::open(path) { + Ok(r) => r.to_rgba(), + Err(e) => panic!("Error while opening file {}: {}", path, e), + }; + self.make_texture_from_buffer(image) }