KHR_debug can also get implemented for older GL versions and gets growing support from AMD, Intel, NVidia and Mesa!īut, there are two problems: First, even if the extension is supported, unless your code runs in an OpenGL debug context you are not guaranteed to get any debug messages out of it! If for any reasons you can not control how the OpenGL context was created you might have to live without this functionality even if your drivers support KHR_debug. This means that on all OpenGL 4.3 or later systems we will always have this functionality and can finally ditch glGetError. This will also most likely be the final form of the new debug functionality as KHR_debug is in fact part of OpenGL 4.3. The latest iteration of this extension is KHR_debug which is also available for OpenGL ES. Now instead of polluting your code with glGetError calls, you can just define a callback function, register it in one line of code and force GL to call it synchronously, put a breakpoint inside of your callback and you will instantly see which GL call triggered an error at which position of your code and you can even inspect the state of your variables during that moment… The idea lived on in ARB_debug_output which added a way to ensure the callback being called synchronously and got support from multiple vendors.
In 2010 AMD had some great ideas of how to provide a better way of debugging: AMD_debug_output. This of course slows down the application and the code becomes a pain to read and write. To ensure you get the problematic GL call every time right you had to call glGetError after every GL call.
This had two problems: on the one hand this will force GL to actually finish all calls triggered previously (and normally OpenGL runs asynchronously from the main application) and on the other hand you only got the last error that happened: if there were multiple GL calls since your last check you had no clue which of them did something wrong! To get informed of the problem, the application had to query an error number for OpenGL to get the last type of error that happened (using glGetError). In most cases an OpenGL error will just result in the offending call being ignored (unless the problem was too little memory, in which case anything could happen). Debugging OpenGL has always been a bit painful.