If you don't have a valid GL context (GL window for example), the GL might simply return GL_INVALID_OPERATION
(0x502 = 1282).
void check_error(const char* st)
{
GLenum err(glGetError());
while (err != GL_NO_ERROR)
{
cerr << "OpenGL error: " << err << " "<<st<<endl;
err = glGetError();
}
cerr << "?\n";
}