Line data Source code
1 :
2 : /* Copyright (c) 2011-2014, Stefan Eilemann <eile@eyescale.ch>
3 : *
4 : * This library is free software; you can redistribute it and/or modify it under
5 : * the terms of the GNU Lesser General Public License version 2.1 as published
6 : * by the Free Software Foundation.
7 : *
8 : * This library is distributed in the hope that it will be useful, but WITHOUT
9 : * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
10 : * FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for more
11 : * details.
12 : *
13 : * You should have received a copy of the GNU Lesser General Public License
14 : * along with this library; if not, write to the Free Software Foundation, Inc.,
15 : * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
16 : */
17 :
18 : #include "gl.h"
19 :
20 : #include <eq/client/glException.h>
21 : #include <lunchbox/debug.h>
22 :
23 : namespace eq
24 : {
25 0 : void debugGLError( const std::string& when, const GLenum error,
26 : const char* file, const int line )
27 : {
28 0 : LBWARN << lunchbox::disableFlush << "Got " << glError( error ) << ' '
29 0 : << when << " in " << file << ':' << line << std::endl
30 0 : << lunchbox::backtrace << lunchbox::enableFlush << std::endl;
31 0 : throw GLException( error );
32 : }
33 :
34 0 : std::string glError( const GLenum error )
35 : {
36 0 : switch( error )
37 : {
38 : case GL_INVALID_ENUM:
39 0 : return std::string( "GL_INVALID_ENUM" );
40 : case GL_INVALID_VALUE:
41 0 : return std::string( "GL_INVALID_VALUE" );
42 : case GL_INVALID_OPERATION:
43 0 : return std::string( "GL_INVALID_OPERATION" );
44 : case GL_STACK_OVERFLOW:
45 0 : return std::string( "GL_STACK_OVERFLOW" );
46 : case GL_STACK_UNDERFLOW:
47 0 : return std::string( "GL_STACK_UNDERFLOW" );
48 : case GL_OUT_OF_MEMORY:
49 0 : return std::string( "GL_OUT_OF_MEMORY" );
50 : case GL_INVALID_FRAMEBUFFER_OPERATION:
51 0 : return std::string( "GL_INVALID_FRAMEBUFFER_OPERATION" );
52 : default:
53 0 : break;
54 : }
55 :
56 0 : std::ostringstream os;
57 0 : os << "GL error 0x" << std::hex << error << std::dec;
58 0 : return os.str();
59 : }
60 :
61 36 : }
|