UFO: Alien Invasion
 All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
r_error.h
Go to the documentation of this file.
1 
6 /*
7 Copyright (C) 2002-2020 UFO: Alien Invasion.
8 
9 This program is free software; you can redistribute it and/or
10 modify it under the terms of the GNU General Public License
11 as published by the Free Software Foundation; either version 2
12 of the License, or (at your option) any later version.
13 
14 This program is distributed in the hope that it will be useful,
15 but WITHOUT ANY WARRANTY; without even the implied warranty of
16 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17 
18 See the GNU General Public License for more details.
19 
20 You should have received a copy of the GNU General Public License
21 along with this program; if not, write to the Free Software
22 Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
23 
24 */
25 
26 #pragma once
27 
28 #include "../../shared/cxx.h"
29 
30 #define R_CheckError() R_CheckErrorDebug(__FILE__, __LINE__, __PRETTY_FUNCTION__)
31 #define GL_ERROR_TRANSLATE(e) case e: return #e;
32 
33 static inline const char* R_TranslateError (GLenum error)
34 {
35  switch (error) {
36  /* openGL errors */
37  GL_ERROR_TRANSLATE(GL_INVALID_ENUM)
38  GL_ERROR_TRANSLATE(GL_INVALID_VALUE)
39  GL_ERROR_TRANSLATE(GL_INVALID_OPERATION)
40  GL_ERROR_TRANSLATE(GL_OUT_OF_MEMORY)
41  GL_ERROR_TRANSLATE(GL_STACK_OVERFLOW)
42  GL_ERROR_TRANSLATE(GL_STACK_UNDERFLOW)
44  /* framebuffer-extension specific errors */
50 #ifndef GL_VERSION_ES_CM_1_0
51 #ifdef GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT
52  GL_ERROR_TRANSLATE(GL_FRAMEBUFFER_INCOMPLETE_DUPLICATE_ATTACHMENT_EXT)
53 #endif
54  GL_ERROR_TRANSLATE(GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT)
55  GL_ERROR_TRANSLATE(GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT)
56 #endif
57  default:
58  return "UNKNOWN";
59  }
60 }
61 
65 static int R_CheckErrorDebug (const char* file, int line, const char* function)
66 {
67  int ret = 0;
69  /* check gl errors (can return multiple errors) */
70  for (;;) {
71  GLenum error = glGetError();
72  if (error != GL_NO_ERROR) {
73  Com_Printf("OpenGL err: %s (%d): %s %s (0x%X)\n", file, line,
74  function, R_TranslateError(error), error);
75  ret++;
76  }
77  else
78  break;
79  }
80  /* check framebuffer errors (can *NOT* return multiple errors)*/
81  if (qglCheckFramebufferStatusEXT) {
82  GLenum error = qglCheckFramebufferStatusEXT(GL_FRAMEBUFFER_EXT);
83  if (error != GL_FRAMEBUFFER_COMPLETE_EXT) {
84  Com_Printf("OpenGL FBO err: %s (%d): %s %s (0x%X)\n", file, line,
85  function, R_TranslateError(error), error);
86  ret++;
87  }
88  }
89  } else {
90  glGetError();
91  }
92 
93  return ret;
94 }
#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT
#define GL_ERROR_TRANSLATE(e)
Definition: r_error.h:31
static const char * R_TranslateError(GLenum error)
Definition: r_error.h:33
void Com_Printf(const char *const fmt,...)
Definition: common.cpp:386
int integer
Definition: cvar.h:81
GLenum glGetError(void)
Definition: gldummy.cpp:8
const GLuint *typedef GLuint *typedef GLenum
Definition: r_gl.h:190
cvar_t * r_checkerror
Definition: r_main.cpp:84
#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT
#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT
#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT
#define GL_FRAMEBUFFER_EXT
#define GL_FRAMEBUFFER_COMPLETE_EXT
#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT
#define GL_FRAMEBUFFER_UNSUPPORTED_EXT
static int R_CheckErrorDebug(const char *file, int line, const char *function)
Checks for opengl errors.
Definition: r_error.h:65