YARP
Yet Another Robot Platform
GLDebug.cpp
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2006-2020 Istituto Italiano di Tecnologia (IIT)
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 
19 #include "GLDebug.h"
20 #include "OVRHeadsetLogComponent.h"
21 
22 #include <yarp/os/LogStream.h>
23 #include <GL/glew.h>
24 
25 void yarp::dev::checkGlError(const char* file, int line, const char* func)
26 {
27  GLenum error = glGetError();
28  if (error != GL_NO_ERROR) {
29  yarp::os::LogStream ls = yarp::os::Log(file, line, func).error();
30  switch (error) {
31  case GL_INVALID_ENUM:
32  ls << "OpenGL Error GL_INVALID_ENUM: GLenum argument out of range";
33  break;
34  case GL_INVALID_VALUE:
35  ls << "OpenGL Error GL_INVALID_VALUE: Numeric argument out of range";
36  break;
37  case GL_INVALID_OPERATION:
38  ls << "OpenGL Error GL_INVALID_OPERATION: Operation illegal in current state";
39  break;
40  case GL_STACK_OVERFLOW:
41  ls << "OpenGL Error GL_STACK_OVERFLOW: Command would cause a stack overflow";
42  break;
43  case GL_OUT_OF_MEMORY:
44  ls << "OpenGL Error GL_OUT_OF_MEMORY: Not enough memory left to execute command";
45  break;
46  default:
47  ls << "OpenGL Error " << error;
48  break;
49  }
50  }
51  if (!(error == 0)) { yarp::os::Log(file, line, func, nullptr, OVRHEADSET()).fatal("OpenGL Error at %s:%d (%s)", file, line, func); }
52 }
LogStream.h
OVRHeadsetLogComponent.h
OVRHEADSET
const yarp::os::LogComponent & OVRHEADSET()
Definition: OVRHeadsetLogComponent.cpp:11
yarp::os::Log::fatal
void fatal(const char *msg,...) const
Definition: Log.cpp:1047
yarp::os::Log::error
void error(const char *msg,...) const
Definition: Log.cpp:1028
yarp::os::LogStream
Definition: LogStream.h:37
GLDebug.h
yarp::os::Log
Definition: Log.h:53
yarp::dev::checkGlError
void checkGlError(const char *file, int line, const char *func)
Definition: GLDebug.cpp:25