Adding platform independant error boxes

wesleyhill wrote on Saturday, August 06, 2005:

Generally programs that make use of GLFW handle visual interaction with the user in their own way and so the addition of platform GUI support to GLFW makes no sense. This being said, I think there’s a lot of projects that would appreciate the addition of a platform-independant error box to be used when the program has failed in some catastrophic manner and the user needs to be informed. Such situations might be:

* Failure to allocate some needed memory,
* glfwInit() fails
* glfwOpenWindow() fails

or in general, any kind of unrecoverable error which means the program has to shut down and is unable to inform the user with it’s usual GUI.

I propose a new GLFW function called void glfwErrorBox( const char *message) which can only be called if glfwInit() fails, or if glfwTerminate() has been called. It doesn’t make sense to display an error box under other circumstances.

The function would look a bit like this:

GLFWAPI void GLFWAPIENTRY glfwErrorBox( const char *message)
{
if( _glfwInitialized )
return; // must glfwTerminate() first

\_glfwPlatformErrorBox\( message \);

}

_glfwPlatformErrorBox would perform, under:

- Windows: MessageBox( NULL, message, “Error”, MB_SYSTEMMODAL | MB_ICONERROR );
- OS X: StandardAlert( kAlertStopAlert, message, null, null, kAlertStdAlertOKButton );
- X11: yikes, can’t find any nice MessageBox equivalent, surely there’s something.
- Dos: puts( message );
- AmigaOS: absolutely no idea.

I think that this arrangement keeps with the GLFW ideal of a non-bloated library that provides platform-independent implementations of commonly needed functions for an OpenGL application.

I welcome any discussion on the subject.

Wesley Hill

elmindreda wrote on Sunday, August 14, 2005:

Sounds like an excellent idea.

I don’t know of any real equivalent on X11, except the poor hack of using xmessage(1).

nobody wrote on Friday, January 20, 2006:

I’m sure it wouldn’t be hard to write an equvilent. Simply because the command wouldn’t be just one line doesn’t mean it couldn’t be done.

elmindreda wrote on Wednesday, August 16, 2006:

I’m now looking into implementing this with Xt in the X11/GLX port. It’s on my list, and something I’d very much like to have myself.