1 ///////////////////////////
3 // SFML - Simple and Fast Multimedia Library
4 // Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
6 // This software is provided 'as-is', without any express or implied warranty.
7 // In no event will the authors be held liable for any damages arising from the use of this software.
9 // Permission is granted to anyone to use this software for any purpose,
10 // including commercial applications, and to alter it and redistribute it freely,
11 // subject to the following restrictions:
13 // 1. The origin of this software must not be misrepresented;
14 // you must not claim that you wrote the original software.
15 // If you use this software in a product, an acknowledgment
16 // in the product documentation would be appreciated but is not required.
18 // 2. Altered source versions must be plainly marked as such,
19 // and must not be misrepresented as being the original software.
21 // 3. This notice may not be removed or altered from any source distribution.
23 ///////////////////////////
25 #include "../stdafx.h"
33 namespace caspar { namespace gl {
35 void SMFL_GLCheckError(const std::string&, const std::string& file, unsigned int line)
38 GLenum LastErrorCode = GL_NO_ERROR;
40 for(GLenum ErrorCode = glGetError(); ErrorCode != GL_NO_ERROR; ErrorCode = glGetError())
42 CASPAR_LOG(error) << "OpenGL Error: " << ErrorCode << L" " << glewGetErrorString(ErrorCode);
43 LastErrorCode = ErrorCode;
46 if (LastErrorCode != GL_NO_ERROR)
48 // Decode the error code
49 switch (LastErrorCode)
51 case GL_INVALID_ENUM :
52 CASPAR_THROW_EXCEPTION(ogl_invalid_enum()
53 << msg_info("an unacceptable value has been specified for an enumerated argument")
54 << error_info("GL_INVALID_ENUM")
56 << source_info(file));
58 case GL_INVALID_VALUE :
59 CASPAR_THROW_EXCEPTION(ogl_invalid_value()
60 << msg_info("a numeric argument is out of range")
61 << error_info("GL_INVALID_VALUE")
63 << source_info(file));
65 case GL_INVALID_OPERATION :
66 CASPAR_THROW_EXCEPTION(ogl_invalid_operation()
67 << msg_info("the specified operation is not allowed in the current state")
68 << error_info("GL_INVALID_OPERATION")
70 << source_info(file));
72 case GL_STACK_OVERFLOW :
73 CASPAR_THROW_EXCEPTION(ogl_stack_overflow()
74 << msg_info("this command would cause a stack overflow")
75 << error_info("GL_STACK_OVERFLOW")
77 << source_info(file));
79 case GL_STACK_UNDERFLOW :
80 CASPAR_THROW_EXCEPTION(ogl_stack_underflow()
81 << msg_info("this command would cause a stack underflow")
82 << error_info("GL_STACK_UNDERFLOW")
84 << source_info(file));
86 case GL_OUT_OF_MEMORY :
87 CASPAR_THROW_EXCEPTION(ogl_out_of_memory()
88 << msg_info("there is not enough memory left to execute the command")
89 << error_info("GL_OUT_OF_MEMORY")
91 << source_info(file));
93 case GL_INVALID_FRAMEBUFFER_OPERATION_EXT :
94 CASPAR_THROW_EXCEPTION(ogl_stack_underflow()
95 << msg_info("the object bound to FRAMEBUFFER_BINDING_EXT is not \"framebuffer complete\"")
96 << error_info("GL_INVALID_FRAMEBUFFER_OPERATION_EXT")
98 << source_info(file));