OpenGL debug messages

We've had several reports recently of game-stopping OpenGL errors. This is usually caused by the game trying to use some functionality that is not supported by the graphics card or graphics driver, but the error message produced doesn't really help to pin down what the problem is.

Back in October 2012, @Luomu wrote a patch to use the GL_KHR_debug extension to get much more detailed error messages, but it was never merged (I don't think it was ever put into a pull request). This PR re-applies Luomu's patch on top of current master, and extends it slightly so that it can be enabled or disabled via an option in config.ini.

It requires GLEW 1.9.0 or greater (I think... that's the version listed in GLEW's changelog as adding support for GL_KHR_debug). If that causes problems for people then we can put the code behind an #ifdef.

This could really do with some testing by someone who currently hits a GL error, or by deliberately adding some incorrect GL code to trigger an error message.