]> git.sesse.net Git - casparcg/blobdiff - common/gl/gl_check.h
git-svn-id: https://casparcg.svn.sourceforge.net/svnroot/casparcg/server/branches...
[casparcg] / common / gl / gl_check.h
index 4437af60f816df8267e383015e39a5ba140efa68..926ac993956bb35516f029d305c6130882024e9d 100644 (file)
 \r
 #pragma once\r
 \r
-#include <Glee.h>\r
-\r
 #include "../exception/exceptions.h"\r
-#include "../log/log.h"\r
-\r
-#include <boost/lexical_cast.hpp>\r
 \r
 namespace caspar { namespace gl {\r
 \r
-struct gl_error : virtual caspar_exception{};\r
-               \r
-inline 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
-\r
-                       case GL_INVALID_VALUE :\r
-                       {\r
-                               Error = "GL_INVALID_VALUE";\r
-                               Desc  = "a numeric argument is out of range";\r
-                               break;\r
-                       }\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
-\r
-                       case GL_STACK_OVERFLOW :\r
-                       {\r
-                               Error = "GL_STACK_OVERFLOW";\r
-                               Desc  = "this command would cause a stack overflow";\r
-                               break;\r
-                       }\r
+struct ogl_exception                                                   : virtual caspar_exception{};\r
+struct ogl_invalid_enum                                                        : virtual ogl_exception{};\r
+struct ogl_invalid_value                                               : virtual ogl_exception{};\r
+struct ogl_invalid_operation                                   : virtual ogl_exception{};\r
+struct ogl_stack_overflow                                              : virtual ogl_exception{};\r
+struct ogl_stack_underflow                                             : virtual ogl_exception{};                      \r
+struct ogl_out_of_memory                                               : virtual ogl_exception{};\r
+struct ogl_invalid_framebuffer_operation_ext   : virtual ogl_exception{};\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
+void SMFL_GLCheckError(const std::string& expr, const std::string& File, unsigned int Line);\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
-\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
-               }\r
-\r
-               // Log the error\r
-               CASPAR_LOG(error) << "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
-       }\r
-}\r
-\r
-#ifdef _DEBUG\r
+//#ifdef _DEBUG\r
        \r
 #define CASPAR_GL_EXPR_STR(expr) #expr\r
 \r
 #define GL(expr) \\r
-       do \\r
+       if(false){}else \\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
+\r
+#define GL2(expr) \\r
+       [&]() -> decltype(expr)\\r
+       {\\r
+               auto ret = (expr); \\r
+               caspar::gl::SMFL_GLCheckError(CASPAR_GL_EXPR_STR(expr), __FILE__, __LINE__);\\r
+               return ret;\\r
+       }()\r
+//#else\r
+//#define GL(expr) expr\r
+//#endif\r
 \r
 }}
\ No newline at end of file