RobLoach / node-raylib

Node.js bindings for Raylib
https://robloach.github.io/node-raylib/
Other
242 stars 20 forks source link

Return null when failing to load images, sounds and textures #80

Closed RobLoach closed 3 years ago

RobLoach commented 3 years ago

Fixes #79

RobLoach commented 3 years ago

@eviltreehouse Thanks for queuing this! I think this one is good to go. With this, you can check....

const raw = fs.readFileSync('wabbits_alpha.png');
const imgBunny = r.LoadImageFromMemory('png', raw, raw.length);
if (! imgBunny) {
  console.error('failed to load image!');
  process.exit(1);
}
eviltreehouse commented 3 years ago

@RobLoach hah sorry to de-rail you on this tangent but I dig the more intuitive interface -- much less seg-fault prone ;)