Skip to content

Commit

Permalink
Added try/catch guards in main function to display errors on Windows
Browse files Browse the repository at this point in the history
  • Loading branch information
bathal1 authored and dvicini committed Jun 23, 2021
1 parent 77ffb28 commit 4cc305e
Showing 1 changed file with 22 additions and 13 deletions.
35 changes: 22 additions & 13 deletions src/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -213,24 +213,33 @@ int main(int argc, char **argv) {
cerr << "Flag --no-gui was set. Please remove it to display the EXR file." << endl;
return -1;
}
Bitmap bitmap(exrName);
ImageBlock block(Vector2i((int) bitmap.cols(), (int) bitmap.rows()), nullptr);
block.fromBitmap(bitmap);
nanogui::init();
NoriScreen *screen = new NoriScreen(block);
nanogui::mainloop(50.f);
delete screen;
nanogui::shutdown();
try {
Bitmap bitmap(exrName);
ImageBlock block(Vector2i((int) bitmap.cols(), (int) bitmap.rows()), nullptr);
block.fromBitmap(bitmap);
nanogui::init();
NoriScreen *screen = new NoriScreen(block);
nanogui::mainloop(50.f);
delete screen;
nanogui::shutdown();
} catch (const std::exception &e) {
cerr << e.what() << endl;
return -1;
}
}
else { // sceneName != ""
if (threadCount < 0) {
threadCount = tbb::task_scheduler_init::automatic;
}

std::unique_ptr<NoriObject> root(loadFromXML(sceneName));
/* When the XML root object is a scene, start rendering it .. */
if (root->getClassType() == NoriObject::EScene)
render(static_cast<Scene *>(root.get()), sceneName);
try {
std::unique_ptr<NoriObject> root(loadFromXML(sceneName));
/* When the XML root object is a scene, start rendering it .. */
if (root->getClassType() == NoriObject::EScene)
render(static_cast<Scene *>(root.get()), sceneName);
} catch (const std::exception &e) {
cerr << e.what() << endl;
return -1;
}
}

return 0;
Expand Down

0 comments on commit 4cc305e

Please sign in to comment.