Getting debug messages
Prior to recent versions of OpenGL, the traditional way to get debug information was to call glGetError
. Unfortunately, that is an exceedingly tedious method to debug a program. The glGetError
function returns an error code if an error has occurred at some point before the function was called.
This means that if we're chasing down a bug, we essentially need to call glGetError
after every function call to an OpenGL function, or do a binary search-like process where we call it before and after a block of code, and then move the two calls closer to each other until we determine the source of the error. What a pain!
Thankfully, as of OpenGL 4.3, we now have support for a more modern method for debugging. Now, we can register a debug callback function that will be executed whenever an error occurs, or other informational message is generated. Not only that, but we can send our own custom messages to be handled by the same callback, and we can filter the messages using a...