Ticket #4344: 4344_opengl.patch

File 4344_opengl.patch, 1.9 KB (added by Vladislav Belov, 8 years ago)

Adds the ogl_GetErrorName function

  • source/lib/ogl.cpp

     
    373373
    374374//----------------------------------------------------------------------------
    375375
    376 static void dump_gl_error(GLenum err)
     376const char* ogl_GetErrorName(GLenum err)
    377377{
    378     debug_printf("OGL| ");
    379 #define E(e) case e: debug_printf("%s\n", #e); break;
     378#define E(e) case e: return #e;
    380379    switch (err)
    381380    {
    382381    E(GL_INVALID_ENUM)
     
    388387#endif
    389388    E(GL_OUT_OF_MEMORY)
    390389    E(GL_INVALID_FRAMEBUFFER_OPERATION)
    391     default: debug_printf("Unknown GL error: %04x\n", err); break;
     390    default: return "Unknown GL error";
    392391    }
    393392#undef E
    394393}
    395394
     395static void dump_gl_error(GLenum err)
     396{
     397    debug_printf("OGL| %s (%04x)\n", ogl_GetErrorName(err), err);
     398}
     399
    396400void ogl_WarnIfErrorLoc(const char *file, int line)
    397401{
    398402    // glGetError may return multiple errors, so we poll it in a loop.
  • source/lib/ogl.h

     
    160160#endif
    161161
    162162/**
     163* get a name of the error.
     164*
     165* useful for debug.
     166*
     167* @return read-only C string of unspecified length containing
     168* the error's name.
     169**/
     170extern const char* ogl_GetErrorName(GLenum err);
     171
     172/**
    163173 * ignore and reset the specified OpenGL error.
    164174 *
    165175 * this is useful for suppressing annoying error messages, e.g.
  • source/renderer/Renderer.cpp

     
    16241624        int err = glGetError();
    16251625        if (err)
    16261626        {
    1627             ONCE(LOGERROR("CRenderer::EndFrame: GL errors %i occurred", err));
     1627            ONCE(LOGERROR("CRenderer::EndFrame: GL errors %s (0x%04x) occurred", ogl_GetErrorName(err), err));
    16281628        }
    16291629    }
    16301630}