The moment glGetError is called, it returns either an error flag or no error at all. We can query these error flags using a function named glGetError that checks the error flag(s) set and returns an error value if OpenGL got misused: The moment you incorrectly use OpenGL (like configuring a buffer without first binding any) it will take notice and generate one or more user error flags behind the scenes.
Debugging in OpenGL is not too difficult to do and getting a grasp of its techniques definitely pays out in the long run. In this chapter we'll look into several techniques and tricks of debugging your OpenGL program. We have no console to output text to, no breakpoints to set on GLSL code, and no way of easily checking the state of GPU execution. Debugging these kinds of visual errors is different than what you're used to when debugging errors on the CPU. Graphics programming can be a lot of fun, but it can also be a large source of frustration whenever something isn't rendering just right, or perhaps not even rendering at all! Seeing as most of what we do involves manipulating pixels, it can be difficult to figure out the cause of error whenever something doesn't work the way it's supposed to.