Easy3D 2.6.1
Loading...
Searching...
No Matches
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 <iostream>
32#include <easy3d/util/logging.h>
33
34
35namespace easy3d {
36
38#define easy3d_gl_error { \
39 opengl::check_gl_error(__FILE__, __FUNCTION__, __LINE__) ; \
40}
41
43#define easy3d_frame_buffer_error { \
44 opengl::check_frame_buffer_error(__FILE__, __FUNCTION__, __LINE__) ; \
45}
46
48#define easy3d_log_gl_error { \
49 std::string msg; \
50 LOG_IF(!opengl::gl_error(msg), ERROR) << "GL error: \n" \
51 << "\tfile: " << __FILE__ << "\n" \
52 << "\tline: " << __LINE__ << "\n" \
53 << "\tfunction: " << __FUNCTION__ << "\n" \
54 << "\tinfo: " << msg; \
55}
56
58#define easy3d_log_frame_buffer_error { \
59 std::string msg; \
60 LOG_IF(!opengl::frame_buffer_error(msg), ERROR) << "GL error: \n" \
61 << "\tfile: " << __FILE__ << "\n" \
62 << "\tline: " << __LINE__ << "\n" \
63 << "\tfunction: " << __FUNCTION__ << "\n" \
64 << "\tinfo: " << msg; \
65}
66
67
68#ifndef NDEBUG
69#define easy3d_debug_gl_error easy3d_gl_error
70#define easy3d_debug_frame_buffer_error easy3d_frame_buffer_error
71#define easy3d_debug_log_gl_error easy3d_log_gl_error
72#define easy3d_debug_log_frame_buffer_error easy3d_log_frame_buffer_error
73#else
74#define easy3d_debug_gl_error
75#define easy3d_debug_frame_buffer_error
76#define easy3d_debug_log_gl_error
77#define easy3d_debug_log_frame_buffer_error
78#endif
79
80
81 namespace opengl {
82
92 bool check_gl_error(const std::string& file, const std::string& function, int line, std::ostream& os = std::cerr);
93
103 bool check_frame_buffer_error(const std::string& file, const std::string& function, int line, std::ostream& os = std::cerr);
104
111 bool gl_error(std::string& msg);
118 bool frame_buffer_error(std::string& msg);
119
125
126 }
127
128}
129
130
131#endif // EASY3D_RENDERER_OPENGL_ERROR_H
132
133
OpenGL-related functionalities for reading pixel/depth data from the framebuffer.
Definition opengl_error.cpp:35
bool gl_error(std::string &msg)
Checks if there was an OpenGL error. If there was an error, the error message will be stored in "msg"...
bool check_frame_buffer_error(const std::string &file, const std::string &function, int line, std::ostream &os=std::cerr)
Checks the last framebuffer error.
bool check_gl_error(const std::string &file, const std::string &function, int line, std::ostream &os=std::cerr)
Checks the last OpenGL error.
bool frame_buffer_error(std::string &msg)
Checks if there was a framebuffer error. If there was an error, the error message will be stored in "...
void setup_gl_debug_callback()
Set up a debug callback for OpenGL.
Definition collider.cpp:182