LibreOffice Module vcl (master)  1
OpenGLHelper.hxx
Go to the documentation of this file.
1 /* -*- Mode: C++; tab-width: 4; indent-tabs-mode: nil; c-basic-offset: 4 -*- */
2 /*
3  * This file is part of the LibreOffice project.
4  *
5  * This Source Code Form is subject to the terms of the Mozilla Public
6  * License, v. 2.0. If a copy of the MPL was not distributed with this
7  * file, You can obtain one at http://mozilla.org/MPL/2.0/.
8  */
9 
10 #ifndef INCLUDED_VCL_OPENGL_OPENGLHELPER_HXX
11 #define INCLUDED_VCL_OPENGL_OPENGLHELPER_HXX
12 
13 #include <epoxy/gl.h>
14 #include <sal/detail/log.h>
15 #include <vcl/dllapi.h>
16 #include <vcl/bitmapex.hxx>
17 
18 #include <rtl/ustring.hxx>
19 #include <sstream>
20 
22 #define VCL_GL_INFO(stream) \
23  do { \
24  if (SAL_DETAIL_ENABLE_LOG_INFO && OpenGLHelper::isVCLOpenGLEnabled()) \
25  { \
26  ::std::ostringstream detail_stream; \
27  detail_stream << stream; \
28  OpenGLHelper::debugMsgStream(detail_stream); \
29  } \
30  } while (false)
31 
33 #define VCL_GL_WARN(stream) \
34  do { \
35  if (SAL_DETAIL_ENABLE_LOG_INFO && OpenGLHelper::isVCLOpenGLEnabled()) \
36  { \
37  ::std::ostringstream detail_stream; \
38  detail_stream << stream; \
39  OpenGLHelper::debugMsgStreamWarn(detail_stream); \
40  } \
41  } while (false)
42 
43 // All member functions static and VCL_DLLPUBLIC. Basically a glorified namespace.
45 {
46  OpenGLHelper() = delete; // Should not be instantiated
47 
48 public:
49 
50  static OString GetDigest(const OUString& rVertexShaderName, const OUString& rFragmentShaderName, const OString& preamble );
51 
52  static GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName, const OUString& rGeometryShaderName, const OString& preamble, const OString& rDigest );
53  static GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName, const OString& preamble, const OString& rDigest );
54  static GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName, const OUString& rGeometryShaderName);
55  static GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName);
56 
62  static BitmapEx ConvertBufferToBitmapEx(const sal_uInt8* const pBuffer, long nWidth, long nHeight);
66  static GLenum OptimalBufferFormat();
67  static void renderToFile(long nWidth, long nHeight, const OUString& rFileName);
68 
69  static const char* GLErrorString(GLenum errorCode);
70 
83  static void createFramebuffer(long nWidth, long nHeight, GLuint& nFramebufferId,
84  GLuint& nRenderbufferDepthId, GLuint& nRenderbufferColorId);
85 
87  static float getGLVersion();
88 
89  static void checkGLError(const char* aFile, size_t nLine);
90 
95 #if defined __GNUC__
96  __attribute__ ((format (printf, 2, 3)))
97 #endif
98  static void debugMsgPrint(const int nType, const char *pFormat, ...);
99  static void debugMsgStream(std::ostringstream const &pStream);
100  static void debugMsgStreamWarn(std::ostringstream const &pStream);
101 
105  static bool isDeviceBlacklisted();
106 
110  static bool supportsVCLOpenGL();
111 
115  static bool isVCLOpenGLEnabled();
116 };
117 
118 #ifdef SAL_LOG_WARN
119 #define CHECK_GL_ERROR() OpenGLHelper::checkGLError(__FILE__, __LINE__)
120 #else
121 #define CHECK_GL_ERROR() do { } while (false)
122 #endif
123 
124 #endif
125 
126 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__)))
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
QPRO_FUNC_TYPE const nType
unsigned char sal_uInt8