]> git.sesse.net Git - casparcg/blobdiff - common/gl/gl_check.cpp
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches...
[casparcg] / common / gl / gl_check.cpp
index 3d694ff06c30413b8db4b9e0b77f1191751db3be..859a7eaaca4ba896c5cd93e6aa3b218318d7b15d 100644 (file)
@@ -28,7 +28,7 @@
 \r
 #include "gl_check.h"\r
 \r
-#include <Glee.h>\r
+#include <GL/glew.h>\r
 \r
 #include "../exception/exceptions.h"\r
 #include "../log/log.h"\r
 \r
 namespace caspar { namespace gl {      \r
 \r
-void SMFL_GLCheckError(const std::string& expr, const std::string& File, unsigned int Line)\r
+void SMFL_GLCheckError(const std::string& expr, const std::string& file, unsigned int line)\r
 {\r
        // Get the last error\r
        GLenum ErrorCode = glGetError();\r
 \r
        if (ErrorCode != GL_NO_ERROR)\r
        {\r
-               std::string Error = "unknown error";\r
-               std::string Desc  = "no description";\r
-\r
                // Decode the error code\r
                switch (ErrorCode)\r
                {\r
                        case GL_INVALID_ENUM :\r
-                       {\r
-                               Error = "GL_INVALID_ENUM";\r
-                               Desc  = "an unacceptable value has been specified for an enumerated argument";\r
-                               break;\r
-                       }\r
+                               BOOST_THROW_EXCEPTION(ogl_invalid_enum()\r
+                                       << msg_info("an unacceptable value has been specified for an enumerated argument")\r
+                                       << errorstr("GL_INVALID_ENUM")\r
+                                       << line_info(line)\r
+                                       << source_info(file));\r
 \r
                        case GL_INVALID_VALUE :\r
-                       {\r
-                               Error = "GL_INVALID_VALUE";\r
-                               Desc  = "a numeric argument is out of range";\r
-                               break;\r
-                       }\r
+                               BOOST_THROW_EXCEPTION(ogl_invalid_value()\r
+                                       << msg_info("a numeric argument is out of range")\r
+                                       << errorstr("GL_INVALID_VALUE")\r
+                                       << line_info(line)\r
+                                       << source_info(file));\r
 \r
                        case GL_INVALID_OPERATION :\r
-                       {\r
-                               Error = "GL_INVALID_OPERATION";\r
-                               Desc  = "the specified operation is not allowed in the current state";\r
-                               break;\r
-                       }\r
+                               BOOST_THROW_EXCEPTION(ogl_invalid_operation()\r
+                                       << msg_info("the specified operation is not allowed in the current state")\r
+                                       << errorstr("GL_INVALID_OPERATION")\r
+                                       << line_info(line)\r
+                                       << source_info(file));\r
 \r
                        case GL_STACK_OVERFLOW :\r
-                       {\r
-                               Error = "GL_STACK_OVERFLOW";\r
-                               Desc  = "this command would cause a stack overflow";\r
-                               break;\r
-                       }\r
+                               BOOST_THROW_EXCEPTION(ogl_stack_overflow()\r
+                                       << msg_info("this command would cause a stack overflow")\r
+                                       << errorstr("GL_STACK_OVERFLOW")\r
+                                       << line_info(line)\r
+                                       << source_info(file));\r
 \r
                        case GL_STACK_UNDERFLOW :\r
-                       {\r
-                               Error = "GL_STACK_UNDERFLOW";\r
-                               Desc  = "this command would cause a stack underflow";\r
-                               break;\r
-                       }\r
+                               BOOST_THROW_EXCEPTION(ogl_stack_underflow()\r
+                                       << msg_info("this command would cause a stack underflow")\r
+                                       << errorstr("GL_STACK_UNDERFLOW")\r
+                                       << line_info(line)\r
+                                       << source_info(file));\r
 \r
                        case GL_OUT_OF_MEMORY :\r
-                       {\r
-                               Error = "GL_OUT_OF_MEMORY";\r
-                               Desc  = "there is not enough memory left to execute the command";\r
-                               break;\r
-                       }\r
+                               BOOST_THROW_EXCEPTION(ogl_out_of_memory()\r
+                                       << msg_info("there is not enough memory left to execute the command")\r
+                                       << errorstr("GL_OUT_OF_MEMORY")\r
+                                       << line_info(line)\r
+                                       << source_info(file));\r
 \r
                        case GL_INVALID_FRAMEBUFFER_OPERATION_EXT :\r
-                       {\r
-                               Error = "GL_INVALID_FRAMEBUFFER_OPERATION_EXT";\r
-                               Desc  = "the object bound to FRAMEBUFFER_BINDING_EXT is not \"framebuffer complete\"";\r
-                               break;\r
-                       }\r
+                               BOOST_THROW_EXCEPTION(ogl_stack_underflow()\r
+                                       << msg_info("the object bound to FRAMEBUFFER_BINDING_EXT is not \"framebuffer complete\"")\r
+                                       << errorstr("GL_INVALID_FRAMEBUFFER_OPERATION_EXT")\r
+                                       << line_info(line)\r
+                                       << source_info(file));\r
                }\r
-\r
-               // Log the error\r
-               std::stringstream str;\r
-               str << "An internal OpenGL call failed in "\r
-                                 << File.substr(File.find_last_of("\\/") + 1).c_str() << " (" << Line << ") : "\r
-                                 << Error.c_str() << ", " << Desc.c_str()\r
-                                 << ", " << expr.c_str()\r
-                                 << std::endl;\r
-               BOOST_THROW_EXCEPTION(caspar_exception() <<\r
-                       msg_info(str.str()));\r
        }\r
 }\r
 \r
-#ifdef _DEBUG\r
-       \r
-#define CASPAR_GL_EXPR_STR(expr) #expr\r
-\r
-#define GL(expr) \\r
-       do \\r
-       { \\r
-               (expr);  \\r
-               caspar::gl::SMFL_GLCheckError(CASPAR_GL_EXPR_STR(expr), __FILE__, __LINE__);\\r
-       }while(0);\r
-#else\r
-#define GL(expr) expr\r
-#endif\r
-\r
 }}
\ No newline at end of file