r_error.h
Go to the documentation of this file.00001
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022
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
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
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
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
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