]> git.sesse.net Git - casparcg/blobdiff - common/gl/gl_check.h
[channel_producer] #590 Added NO_AUTO_DEINTERLACE parameter to channel route AMCP...
[casparcg] / common / gl / gl_check.h
index 00d78c0f6ac8a128828f8fe734984e27cbb51c1d..f6ceb852571c2fe5c923e68b2b0765500895bc12 100644 (file)
-////////////////////////////////////////////////////////////\r
-//\r
-// SFML - Simple and Fast Multimedia Library\r
-// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)\r
-//\r
-// This software is provided 'as-is', without any express or implied warranty.\r
-// In no event will the authors be held liable for any damages arising from the use of this software.\r
-//\r
-// Permission is granted to anyone to use this software for any purpose,\r
-// including commercial applications, and to alter it and redistribute it freely,\r
-// subject to the following restrictions:\r
-//\r
-// 1. The origin of this software must not be misrepresented;\r
-//    you must not claim that you wrote the original software.\r
-//    If you use this software in a product, an acknowledgment\r
-//    in the product documentation would be appreciated but is not required.\r
-//\r
-// 2. Altered source versions must be plainly marked as such,\r
-//    and must not be misrepresented as being the original software.\r
-//\r
-// 3. This notice may not be removed or altered from any source distribution.\r
-//\r
-////////////////////////////////////////////////////////////\r
-\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 common { namespace gl {\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
-\r
-            case GL_STACK_UNDERFLOW :\r
-            {\r
-                Error = "GL_STACK_UNDERFLOW";\r
-                Desc  = "this command would cause a stack underflow";\r
-                break;\r
-            }\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
-       \r
-#define CASPAR_GL_EXPR_STR(expr) #expr\r
-\r
-#define GL(expr) \\r
-       do \\r
-       { \\r
-               (expr);  \\r
-               caspar::common::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
+///////////////////////////
+//
+// SFML - Simple and Fast Multimedia Library
+// Copyright (C) 2007-2009 Laurent Gomila (laurent.gom@gmail.com)
+//
+// This software is provided 'as-is', without any express or implied warranty.
+// In no event will the authors be held liable for any damages arising from the use of this software.
+//
+// Permission is granted to anyone to use this software for any purpose,
+// including commercial applications, and to alter it and redistribute it freely,
+// subject to the following restrictions:
+//
+// 1. The origin of this software must not be misrepresented;
+//    you must not claim that you wrote the original software.
+//    If you use this software in a product, an acknowledgment
+//    in the product documentation would be appreciated but is not required.
+//
+// 2. Altered source versions must be plainly marked as such,
+//    and must not be misrepresented as being the original software.
+//
+// 3. This notice may not be removed or altered from any source distribution.
+//
+///////////////////////////
+
+#pragma once
+
+#include "../except.h"
+
+namespace caspar { namespace gl {
+
+struct ogl_exception                                                   : virtual caspar_exception{};
+struct ogl_invalid_enum                                                        : virtual ogl_exception{};
+struct ogl_invalid_value                                               : virtual ogl_exception{};
+struct ogl_invalid_operation                                   : virtual ogl_exception{};
+struct ogl_stack_overflow                                              : virtual ogl_exception{};
+struct ogl_stack_underflow                                             : virtual ogl_exception{};
+struct ogl_out_of_memory                                               : virtual ogl_exception{};
+struct ogl_invalid_framebuffer_operation_ext   : virtual ogl_exception{};
+
+void SMFL_GLCheckError(const std::string& expr, const char* func, const char* file, unsigned int line);
+
+//#ifdef _DEBUG
+
+#define CASPAR_GL_EXPR_STR(expr) #expr
+
+#define GL(expr) \
+       if(false){}else \
+       { \
+               (expr);  \
+               caspar::gl::SMFL_GLCheckError(CASPAR_GL_EXPR_STR(expr), __FUNCTION__, __FILE__, __LINE__);\
+       }
+
+// TODO: decltype version does not play well with gcc
+#define GL2(expr) \
+       [&]()\
+       {\
+               auto ret = (expr);\
+               caspar::gl::SMFL_GLCheckError(CASPAR_GL_EXPR_STR(expr), __FUNCTION__, __FILE__, __LINE__);\
+               return ret;\
+       }()
+/*#define GL2(expr) \
+       [&]() -> decltype(expr) \
+       { \
+               auto ret = (expr); \
+               caspar::gl::SMFL_GLCheckError(CASPAR_GL_EXPR_STR(expr), __FILE__, __LINE__); \
+               return ret; \
+       }()*/
+//#define GL2(expr) [&]() -> decltype(expr) { auto ret = (expr); caspar::gl::SMFL_GLCheckError(CASPAR_GL_EXPR_STR(expr), __FILE__, __LINE__); return ret; }()
+//#else
+//#define GL(expr) expr
+//#endif
+
+}}