ScummVM API documentation
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Macros Modules Pages
debug.h
1 /* ScummVM - Graphic Adventure Engine
2  *
3  * ScummVM is the legal property of its developers, whose names
4  * are too numerous to list here. Please refer to the COPYRIGHT
5  * file distributed with this source distribution.
6  *
7  * This program is free software: you can redistribute it and/or modify
8  * it under the terms of the GNU General Public License as published by
9  * the Free Software Foundation, either version 3 of the License, or
10  * (at your option) any later version.
11  *
12  * This program is distributed in the hope that it will be useful,
13  * but WITHOUT ANY WARRANTY; without even the implied warranty of
14  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15  * GNU General Public License for more details.
16  *
17  * You should have received a copy of the GNU General Public License
18  * along with this program. If not, see <http://www.gnu.org/licenses/>.
19  *
20  */
21 
22 #ifndef BACKENDS_GRAPHICS_OPENGL_DEBUG_H
23 #define BACKENDS_GRAPHICS_OPENGL_DEBUG_H
24 
25 #include "graphics/opengl/context.h"
26 
27 #ifndef __EMSCRIPTEN__
28 #define OPENGL_DEBUG
29 #endif
30 
31 namespace OpenGL {
32 void clearGLError();
33 bool checkGLError(const char *expr, const char *file, int line);
34 } // End of namespace OpenGL
35 
36 #define GL_WRAP_CHECK(err, call, name) do { OpenGL::clearGLError(); (call); err = OpenGL::checkGLError(#name, __FILE__, __LINE__); } while (false)
37 #ifdef OPENGL_DEBUG
38 #define GL_WRAP_DEBUG(call, name) do { OpenGL::clearGLError(); (call); OpenGL::checkGLError(#name, __FILE__, __LINE__); } while (false)
39 #else
40 #define GL_WRAP_DEBUG(call, name) do { (call); } while (false)
41 #endif
42 
43 // This macro will set boolean err to true if there was an error and display them in the console
44 #define GL_CALL_CHECK(err, x) GL_WRAP_CHECK(err, x, x)
45 // This macro will check for errors and display them in the console only when OPENGL_DEBUG is enabled
46 #define GL_CALL(x) GL_WRAP_DEBUG(x, x)
47 // This macro will execute the call only when the context is valid and will check errors only when OPENGL_DEBUG is enabled
48 #define GL_CALL_SAFE(func, params) \
49  do { \
50  if (OpenGLContext.type != kContextNone) { \
51  GL_CALL(func params); \
52  } \
53  } while (0)
54 // This macro will assign result of x to var and check for errors when OPENGL_DEBUG is enabled
55 #define GL_ASSIGN(var, x) GL_WRAP_DEBUG(var = x, x)
56 
57 #endif
Definition: renderbuffer.h:27