r_error.h

Go to the documentation of this file.
00001 
00006 /*
00007 Copyright (C) 2002-2010 UFO: Alien Invasion.
00008 
00009 This program is free software; you can redistribute it and/or
00010 modify it under the terms of the GNU General Public License
00011 as published by the Free Software Foundation; either version 2
00012 of the License, or (at your option) any later version.
00013 
00014 This program is distributed in the hope that it will be useful,
00015 but WITHOUT ANY WARRANTY; without even the implied warranty of
00016 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00017 
00018 See the GNU General Public License for more details.
00019 
00020 You should have received a copy of the GNU General Public License
00021 along with this program; if not, write to the Free Software
00022 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00023 
00024 */
00025 
00026 
00027 #define R_CheckError() R_CheckErrorDebug(__FILE__, __LINE__, __PRETTY_FUNCTION__)
00028 #define GL_ERROR_TRANSLATE(e) case e: return #e;
00029 
00030 static inline const char* R_TranslateError (GLenum error)
00031 {
00032     switch (error) {
00033     /* openGL errors */
00034     GL_ERROR_TRANSLATE(GL_INVALID_ENUM)
00035     GL_ERROR_TRANSLATE(GL_INVALID_VALUE)
00036     GL_ERROR_TRANSLATE(GL_INVALID_OPERATION)
00037     GL_ERROR_TRANSLATE(GL_OUT_OF_MEMORY)
00038     GL_ERROR_TRANSLATE(GL_STACK_OVERFLOW)
00039     GL_ERROR_TRANSLATE(GL_STACK_UNDERFLOW)
00040     GL_ERROR_TRANSLATE(GL_INVALID_FRAMEBUFFER_OPERATION_EXT)
00041     /* framebuffer-extension specific errors */
00042     GL_ERROR_TRANSLATE(GL_FRAMEBUFFER_UNSUPPORTED_EXT)
00043     GL_ERROR_TRANSLATE(GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT)
00044     GL_ERROR_TRANSLATE(GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT)
00045     GL_ERROR_TRANSLATE(GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT)
00046     GL_ERROR_TRANSLATE(GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT)
00047     GL_ERROR_TRANSLATE(GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT)
00048     GL_ERROR_TRANSLATE(GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT)
00049     GL_ERROR_TRANSLATE(GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT)
00050     default:
00051         return "UNKNOWN";
00052     }
00053 }
00054 
00058 static int R_CheckErrorDebug (const char *file, int line, const char *function)
00059 {
00060     int ret = 0;
00061     if (r_checkerror && r_checkerror->integer) {
00062         /* check gl errors (can return multiple errors) */
00063         for (;;) {
00064             GLenum error = glGetError();
00065             if (error != GL_NO_ERROR) {
00066                 Com_Printf("OpenGL err: %s (%d): %s %s (0x%X)\n", file, line,
00067                         function, R_TranslateError(error), error);
00068                 ret++;
00069             }
00070             else
00071                 break;
00072         }
00073         /* check framebuffer errors (can *NOT* return multiple errors)*/
00074         if (qglCheckFramebufferStatusEXT) {
00075             GLenum error = qglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
00076             if (error != GL_FRAMEBUFFER_COMPLETE_EXT) {
00077                 Com_Printf("OpenGL FBO err: %s (%d): %s %s (0x%X)\n", file, line,
00078                         function, R_TranslateError(error), error);
00079                 ret++;
00080             }
00081         }
00082     } else {
00083         glGetError();
00084     }
00085 
00086     return ret;
00087 }
00088 

Generated by  doxygen 1.6.2