Based on Lars's approach, you can automatically track errors based on some preprocessing magic and creating stub functions.
I wrote a small Python script that processes the OpenGL header (I used Mac OS X alone in the example, but it should also work with iOS).
The Python script generates two header files for inclusion in your project wherever you call OpenGL, like this (you can name the header you want):
#include "gl_debug_overwrites.h"
The header contains macros and function declarations after this scheme:
#define glGenLists _gl_debug_error_glGenLists GLuint _gl_debug_error_glGenLists(GLsizei range);
The script also creates the source file in the same stream, which you must save separately, compile and link to your project.
Then all gl* functions will be transferred to another function with the _gl_debug_error_ prefix, which then checks for errors like this:
GLuint _gl_debug_error_glGenLists(GLsizei range) { GLuint var = glGenLists(range); CHECK_GL_ERROR(); return var; }
source share