Easy3D 2.5.3
opengl_error.h
1/********************************************************************
2 * Copyright (C) 2015 Liangliang Nan <liangliang.nan@gmail.com>
3 * https://3d.bk.tudelft.nl/liangliang/
4 *
5 * This file is part of Easy3D. If it is useful in your research/work,
6 * I would be grateful if you show your appreciation by citing it:
7 * ------------------------------------------------------------------
8 * Liangliang Nan.
9 * Easy3D: a lightweight, easy-to-use, and efficient C++ library
10 * for processing and rendering 3D data.
11 * Journal of Open Source Software, 6(64), 3255, 2021.
12 * ------------------------------------------------------------------
13 *
14 * Easy3D is free software; you can redistribute it and/or modify
15 * it under the terms of the GNU General Public License Version 3
16 * as published by the Free Software Foundation.
17 *
18 * Easy3D is distributed in the hope that it will be useful,
19 * but WITHOUT ANY WARRANTY; without even the implied warranty of
20 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
21 * GNU General Public License for more details.
22 *
23 * You should have received a copy of the GNU General Public License
24 * along with this program. If not, see <http://www.gnu.org/licenses/>.
25 ********************************************************************/
26
27#ifndef EASY3D_RENDERER_OPENGL_ERROR_H
28#define EASY3D_RENDERER_OPENGL_ERROR_H
29
30#include <string>
31#include <easy3d/util/logging.h>
32
33
34namespace easy3d {
35
36
37#define easy3d_gl_error { \
38 opengl::check_gl_error(__FILE__, __FUNCTION__, __LINE__) ; \
39}
40
41#define easy3d_frame_buffer_error { \
42 opengl::check_frame_buffer_error(__FILE__, __FUNCTION__, __LINE__) ; \
43}
44
45#define easy3d_log_gl_error { \
46 std::string log; \
47 LOG_IF(!opengl::gl_error(log), ERROR) << "GL error: \n" \
48 << "\tfile: " << __FILE__ << "\n" \
49 << "\tline: " << __LINE__ << "\n" \
50 << "\tfunction: " << __FUNCTION__ << "\n" \
51 << "\tinfo: " << log; \
52}
53
54#define easy3d_log_frame_buffer_error { \
55 std::string log; \
56 LOG_IF(!opengl::frame_buffer_error(log), ERROR) << "GL error: \n" \
57 << "\tfile: " << __FILE__ << "\n" \
58 << "\tline: " << __LINE__ << "\n" \
59 << "\tfunction: " << __FUNCTION__ << "\n" \
60 << "\tinfo: " << log; \
61}
62
63
64#ifndef NDEBUG
65#define easy3d_debug_gl_error easy3d_gl_error
66#define easy3d_debug_frame_buffer_error easy3d_frame_buffer_error
67#define easy3d_debug_log_gl_error easy3d_log_gl_error
68#define easy3d_debug_log_frame_buffer_error easy3d_log_frame_buffer_error
69#else
70#define easy3d_debug_gl_error
71#define easy3d_debug_frame_buffer_error
72#define easy3d_debug_log_gl_error
73#define easy3d_debug_log_frame_buffer_error
74#endif
75
76
77 namespace opengl {
78
79 // Prints the last GL error to the logger.
80 // returns false if an error occurred.
81 bool check_gl_error(const std::string& file, const std::string& function, int line);
82 bool check_frame_buffer_error(const std::string& file, const std::string& function, int line);
83
84 // Check if there was an error. The error message will be stored in "log" if provided.
85 // returns false if an error occurred.
86 bool gl_error(std::string& log);
87 bool frame_buffer_error(std::string& log);
88
89 void setup_gl_debug_callback();
90
91 }
92
93}
94
95
96#endif // EASY3D_RENDERER_OPENGL_ERROR_H
97
98
Definition: collider.cpp:182