hx3d  1
2D/3D Simple Game Framework
error.cpp
1 /*
2  OpenGL Error
3  Copyright (C) 2015 Denis BOURGE
4 
5  This library is free software; you can redistribute it and/or
6  modify it under the terms of the GNU Lesser General Public
7  License as published by the Free Software Foundation; either
8  version 2.1 of the License, or (at your option) any later version.
9 
10  This library is distributed in the hope that it will be useful,
11  but WITHOUT ANY WARRANTY; without even the implied warranty of
12  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
13  Lesser General Public License for more details.
14 
15  You should have received a copy of the GNU Lesser General Public
16  License along with this library; if not, write to the Free Software
17  Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301
18  USA
19 */
20 
21 #include "hx3d/graphics/error.hpp"
22 
23 #include "hx3d/graphics/gl.hpp"
24 #include "hx3d/utils/log.hpp"
25 
26 namespace hx3d {
27 
28  void checkGLError(const char* file, int line) {
29  GLenum err = GL_NO_ERROR;
30  while ((err = glGetError()) != GL_NO_ERROR) {
31  std::string msg;
32  switch (err) {
33  case GL_INVALID_ENUM:
34  msg = "Invalid enum.";
35  break;
36  case GL_INVALID_VALUE:
37  msg = "Invalid value.";
38  break;
39  case GL_INVALID_OPERATION:
40  msg = "Invalid operation.";
41  break;
42  case GL_INVALID_FRAMEBUFFER_OPERATION:
43  msg = "Invalid framebuffer operation.";
44  break;
45  case GL_OUT_OF_MEMORY:
46  msg = "Out of memory";
47  break;
48  default:
49  msg = "Unknown";
50  }
51 
52  Log.Error("GL Error: %s / File: %s / Line: %d", msg.c_str(), file, line);
53  }
54  }
55 
56 } /* hx3d */
hx3d framework namespace
Definition: audio.hpp:26
void Error(const std::string fmt,...)
Write an error message.
Definition: log.cpp:72
static hx3d::LogImpl Log
Current log implementation.
Definition: log.hpp:91
void checkGLError(const char *file, int line)
Display the last unchecked OpenGL errors.
Definition: error.cpp:28