summary refs log tree commit diff
path: root/src/error.rs
diff options
context:
space:
mode:
authorIrene Knapp <ireneista@irenes.space>2026-07-17 18:43:05 -0700
committerIrene Knapp <ireneista@irenes.space>2026-07-18 01:14:49 -0700
commitf70917c8aae0d184ed7ce5e63e6347fdc21921e3 (patch)
treebdc7f0b8c45c8cba5a07786590053212185406c2 /src/error.rs
parentf7e6dec079dcbbc26a9e047cf2b0acf23c091836 (diff)
load a texture image
also refactor buffer management a little

this doesn't yet draw the texture

Change-Id: Id2efa761223a588bf599041ac525c3b988f0113b
Force-Push: yes
Diffstat (limited to 'src/error.rs')
-rw-r--r--src/error.rs25
1 files changed, 25 insertions, 0 deletions
diff --git a/src/error.rs b/src/error.rs
index f034683..729ff23 100644
--- a/src/error.rs
+++ b/src/error.rs
@@ -90,6 +90,31 @@ impl From<vulkanalia::bytecode::BytecodeError> for Error {
   }
 }
 
+impl From<std::io::Error> for Error {
+  fn from(e: std::io::Error) -> Self {
+    Error {
+      message: format!("System I/O error: {}", e),
+    }
+  }
+}
+
+impl From<png::DecodingError> for Error {
+  fn from(e: png::DecodingError) -> Self {
+    match e {
+      png::DecodingError::IoError(e) => Self::from(e),
+      png::DecodingError::Format(_) => Error {
+        message: "Texture image is not a valid PNG.".to_string(),
+      },
+      png::DecodingError::Parameter(e) => Error {
+        message: format!("PNG library misusage: {}", e),
+      },
+      png::DecodingError::LimitsExceeded => Error {
+        message: "PNG needed too much memory to decode.".to_string(),
+      }
+    }
+  }
+}
+
 pub fn ignore_errors(mut body: impl FnMut() -> Result<()>) -> () {
   if let Err(e) = body() {
     eprintln!("Error: {}", e);