Reputation: 1467
I want to display an error message when my C++ cross-platform (Windows, Linux, Mac) OpenGL application fails to initialize to let the user know what went wrong.
My ideas so far:
How would you solve this?
Upvotes: 1
Views: 1331
Reputation: 69682
The GUI solution is actually a good one but the problem is indeed that you would need another dependency, unless...
...you just code one function for each platform, which would report the error using the GUI code for each platform.
You will only implement one of these error function report for your primary platform, then through porting, write the other versions. If you already work directly with all the platforms, then do it once for all platforms and go with it.
As it's just to report a message, it shouldn't be hard, long or even problematic.
Just follow the K.I.S.S. principle.
(note: the message can be displayed on the next startup instead of when the problem occurs, which would certainly be more safe)
That being said, in the future you might want more complex error reporting system. In this case, it is worth investing into developing your error report code as a separate project which would have it's own dependencies and would just be triggered by any problem from the main project (whatever the way it communicates). In this case, it's ok to have another dependency like Qt (though it's kind of heavyweight...) or wxWidgets (kind of too) or GTK (my experience with it is not positive but it's ok for simple things). One GUI framework that is designed to be lightweight and simple is FLTK, so it might be simple and lightweight enough to sit beside your application.
Upvotes: 1
Reputation: 693
wxWidgets (or similar cross platform framework). Or, manually what you suggested under 3.
Upvotes: 1