diff --git a/examples/Example.h b/examples/Example.h index 342a16e1..4031daf2 100644 --- a/examples/Example.h +++ b/examples/Example.h @@ -59,7 +59,7 @@ using namespace std; namespace tvgexam { -bool verify(tvg::Result result); +bool verify(tvg::Result result, string failMsg = ""); struct Example { @@ -140,10 +140,7 @@ struct Window Window(tvg::CanvasEngine engine, Example* example, uint32_t width, uint32_t height) { //Initialize ThorVG Engine (4: threads count, engine: raster method) - if (!verify(tvg::Initializer::init(4, engine))) { - cout << "Failed to init ThorVG engine!" << endl; - return; - } + if (!verify(tvg::Initializer::init(4, engine), "Failed to init ThorVG engine!")) return; //Initialize the SDL SDL_Init(SDL_INIT_VIDEO); @@ -466,31 +463,31 @@ float progress(uint32_t elapsed, float durationInSec, bool rewind = false) } -bool verify(tvg::Result result) +bool verify(tvg::Result result, string failMsg) { switch (result) { case tvg::Result::FailedAllocation: { - cout << "FailedAllocation!" << endl; + cout << "FailedAllocation! " << failMsg << endl; return false; } case tvg::Result::InsufficientCondition: { - cout << "InsufficientCondition!" << endl; + cout << "InsufficientCondition! " << failMsg << endl; return false; } case tvg::Result::InvalidArguments: { - cout << "InvalidArguments!" << endl; + cout << "InvalidArguments! " << failMsg << endl; return false; } case tvg::Result::MemoryCorruption: { - cout << "MemoryCorruption!" << endl; + cout << "MemoryCorruption! " << failMsg << endl; return false; } case tvg::Result::NonSupport: { - cout << "NonSupport!" << endl; + cout << "NonSupport! " << failMsg << endl; return false; } case tvg::Result::Unknown: { - cout << "Unknown!" << endl; + cout << "Unknown! " << failMsg << endl; return false; } default: break; diff --git a/examples/PictureTvg.cpp b/examples/PictureTvg.cpp index 4519f238..6234213d 100644 --- a/examples/PictureTvg.cpp +++ b/examples/PictureTvg.cpp @@ -34,7 +34,9 @@ struct UserExample : tvgexam::Example //load the tvg file auto picture = tvg::Picture::gen(); - if (!tvgexam::verify(picture->load(EXAMPLE_DIR"/tvg/test.tvg"))) return false; + if (!tvgexam::verify(picture->load(EXAMPLE_DIR"/tvg/test.tvg"), "You might need to run \"TvgSaver\" example first to generate the \"test.tvg\".")) { + return false; + } float w2, h2; picture->size(&w2, &h2);