Errors when adding error handling to GLEW

Viewed 30

Using the code below:

static void ClearError()
{
    while (!glGetError());
}

static bool CheckError(const char* function, const char* file, int line)
{
    while (GLenum error = glGetError())
    {
        std::cout << "[OpenGL Error]: " << error << " (Function = " <<
            function << ", File = " << file << ", Line = " << line << std::endl;
        return false;
    }
    return true;
}

#define gl_error_call(x) ClearError();\
x;\
if (!CheckError(#x, __FILE__, __LINE__)) __debugbreak()

I have modified glew.h so every function has error handling.

For example I have changed

#define glGenBuffers GLEW_GET_FUN(__glewGenBuffers)                       

to:

#define glGenBuffers gl_error_call(GLEW_GET_FUN(__glewGenBuffers)

However whenever I call a OpenGL function, I get a error for every function called

For example when calling glGenBuffers i get:

C2064: term does not evaluate to a function taking 2 arguments

Instead of modifying glew.h, i have tried calling gl_error_call before every function, and it works fine.

For example:

gl_error_call(glGenBuffers(1, &buffer));

Does anyone know how to fix this?

0 Answers
Related