UFO: Alien Invasion
Loading...
Searching...
No Matches
r_error.h
Go to the documentation of this file.
1
5
6/*
7Copyright (C) 2002-2025 UFO: Alien Invasion.
8
9This program is free software; you can redistribute it and/or
10modify it under the terms of the GNU General Public License
11as published by the Free Software Foundation; either version 2
12of the License, or (at your option) any later version.
13
14This program is distributed in the hope that it will be useful,
15but WITHOUT ANY WARRANTY; without even the implied warranty of
16MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
17
18See the GNU General Public License for more details.
19
20You should have received a copy of the GNU General Public License
21along with this program; if not, write to the Free Software
22Foundation, 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
33static 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
65static int R_CheckErrorDebug (const char* file, int line, const char* function)
66{
67 int ret = 0;
68 if (r_checkerror && r_checkerror->integer) {
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}
void Com_Printf(const char *const fmt,...)
Definition common.cpp:428
GLenum glGetError(void)
Definition gldummy.cpp:8
#define GL_ERROR_TRANSLATE(e)
Definition r_error.h:31
static int R_CheckErrorDebug(const char *file, int line, const char *function)
Checks for opengl errors.
Definition r_error.h:65
static const char * R_TranslateError(GLenum error)
Definition r_error.h:33
QGL_EXTERN const GLuint *QGL_EXTERN GLuint *QGL_EXTERN GLenum
Definition r_gl.h:127
#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT
#define GL_FRAMEBUFFER_UNSUPPORTED_EXT
#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT
#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT
#define GL_FRAMEBUFFER_COMPLETE_EXT
#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT
#define GL_FRAMEBUFFER_EXT
#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT
cvar_t * r_checkerror
Definition r_main.cpp:84