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 char* func, const char* 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 ::boost::exception_detail::throw_exception_(
54 << msg_info("an unacceptable value has been specified for an enumerated argument")
55 << error_info("GL_INVALID_ENUM")
56 << call_stack_info(caspar::get_call_stack())
57 << context_info(get_context()),
58 func, log::remove_source_prefix(file), line);
60 case GL_INVALID_VALUE :
61 ::boost::exception_detail::throw_exception_(
63 << msg_info("a numeric argument is out of range")
64 << error_info("GL_INVALID_VALUE")
65 << call_stack_info(caspar::get_call_stack())
66 << context_info(get_context()),
67 func, log::remove_source_prefix(file), line);
69 case GL_INVALID_OPERATION :
70 ::boost::exception_detail::throw_exception_(
71 ogl_invalid_operation()
72 << msg_info("the specified operation is not allowed in the current state")
73 << error_info("GL_INVALID_OPERATION")
74 << call_stack_info(caspar::get_call_stack())
75 << context_info(get_context()),
76 func, log::remove_source_prefix(file), line);
78 case GL_STACK_OVERFLOW :
79 ::boost::exception_detail::throw_exception_(
81 << msg_info("this command would cause a stack overflow")
82 << error_info("GL_STACK_OVERFLOW")
83 << call_stack_info(caspar::get_call_stack())
84 << context_info(get_context()),
85 func, log::remove_source_prefix(file), line);
87 case GL_STACK_UNDERFLOW :
88 ::boost::exception_detail::throw_exception_(
90 << msg_info("this command would cause a stack underflow")
91 << error_info("GL_STACK_UNDERFLOW")
92 << call_stack_info(caspar::get_call_stack())
93 << context_info(get_context()),
94 func, log::remove_source_prefix(file), line);
96 case GL_OUT_OF_MEMORY :
97 ::boost::exception_detail::throw_exception_(
99 << msg_info("there is not enough memory left to execute the command")
100 << error_info("GL_OUT_OF_MEMORY")
101 << call_stack_info(caspar::get_call_stack())
102 << context_info(get_context()),
103 func, log::remove_source_prefix(file), line);
105 case GL_INVALID_FRAMEBUFFER_OPERATION_EXT :
106 ::boost::exception_detail::throw_exception_(
107 ogl_invalid_framebuffer_operation_ext()
108 << msg_info("the object bound to FRAMEBUFFER_BINDING_EXT is not \"framebuffer complete\"")
109 << error_info("GL_INVALID_FRAMEBUFFER_OPERATION_EXT")
110 << call_stack_info(caspar::get_call_stack())
111 << context_info(get_context()),
112 func, log::remove_source_prefix(file), line);