not-fl3 / miniquad

Cross platform rendering in Rust
Apache License 2.0
1.54k stars 173 forks source link

Support error handling in miniquad API #54

Open nokola opened 4 years ago

nokola commented 4 years ago

Today miniquad will panic if invalid shader code is specified in Shader::new()

It may be useful for callers to gracefully show error message instead of panic!() especially for tools that get arbitrary shader text (e.g. from the user, like https://shadertoy.com)

I propose to add Result<..> to Shader::new() to support error handling

nokola commented 4 years ago

Also note: I'm opening all these issues since I'm going through the nvg-miniquad port and adding tracking issues for whatever the difference is between the nvg expected APIs and miniquad, if the new APIs will improve miniquad.

not-fl3 commented 4 years ago

I agree, Shader::new() should return Result with error message.

nokola commented 4 years ago

Edit: renamed title to be more generic since I found panic-s in several places:

Shader::new()
get_uniform_location()
apply_bindings()
Pipeline::with_params()

Would be nice to have error propagation in general for miniquad. Perhaps that means EventHandler updates to have the functions there return Result as well.