title: (Define a macro to) facilitate OpenGL command debugging?
body: <p>Sometimes it takes a long time of inserting conditional prints and checks to <code>glGetError()</code> to narrow down using a form of binary search where the first function call is that an error is first reported by OpenGL. </p>
  
  <p>I think it would be cool if there is a way to build a macro which I can wrap around all GL calls which may fail which will conditionally call <code>glGetError</code> immediately after. When compiling for a special target I can have it check <code>glGetError</code> with a very high granularity, while compiling for typical release or debug this wouldn't get enabled (I'd check it only once a frame). </p>
  
  <p>Does this make sense to do? Searching for this a bit I find a few people recommending calling <code>glGetError</code> after every non-draw gl-call which is basically the same thing I'm describing. </p>
  
  <p>So in this case is there anything clever that I can do (context: I am using GLEW) to simplify the process of instrumenting my gl calls this way? It would be a significant amount of work at this point to convert my code to wrap a macro around each OpenGL function call. What would be great is if I can do something clever and get all of this going without manually determining which are the sections of code to instrument (though that also has potential advantages... but not really. I <em>really</em> don't care about performance by the time I'm debugging the source of an error).</p>