Open ghost opened 3 years ago
Yep the library panics on non-ktx files by checking the header. Currently
this is a debug_assert but we could add a try_new
fn that returns a
Result for that.
On Sun, 1 Aug 2021, 15:49 fctorial, @.***> wrote:
Currently the function ktx::Ktx::new panics if an invalid file is provided:
fn main() { unsafe { ktx::Ktx::new(std::fs::read("/home/fctorial/.zshrc").unwrap()); } }
What should I do if I'm trying to load an unknown ktx file, for example, a file that I'm receiving over the network. Is there another function that returns an std::error::Error if the provided file is invalid? Does the library currently perform sanity checks on the input file (pixel_height == 0 && pixel_depth != 0 is invalid)?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/alexheretic/ktx/issues/12, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARZHV6YBHDOXO75I52ZWU3T2VNHFANCNFSM5BLGUE5A .
What about other kind of errors? i.e. Files that have the correct ktx structure but some of the fields contradict each other. If the new function finishes without error, is it guaranteed that the ktx file adhers to the ktx spec?
I'm less convinced that extra validation should be done on new
. Maybe if
we had some examples of invalid ktx textures to test with?
But perhaps we can get started with the try_new
method checking for the
correct ktx header and improve when it looks worthwhile.
On Sun, 1 Aug 2021 at 17:45, fctorial @.***> wrote:
What about other kind of errors? i.e. Files that have the correct ktx structure but some of the fields contradict each other. If the new function finishes without error, is it guaranteed that the ktx file adhers to the ktx spec?
— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/alexheretic/ktx/issues/12#issuecomment-890552024, or unsubscribe https://github.com/notifications/unsubscribe-auth/AARZHVYQH4BAJQAAMS7DKTLT2V24LANCNFSM5BLGUE5A .
Currently the function
ktx::Ktx::new
panics if an invalid file is provided:What should I do if I'm trying to load an unknown ktx file, for example, a file that I'm receiving over the network. Is there another function that returns an
std::error::Error
if the provided file is invalid? Does the library currently perform sanity checks on the input file (pixel_height == 0 && pixel_depth != 0
is invalid,numArrayLayers
must be zero for 3d images, cubemaps must be 2d)?