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 #include <string_view>
21 
23 #define VCL_GL_INFO(stream) \
24  do { \
25  if (SAL_DETAIL_ENABLE_LOG_INFO) \
26  { \
27  ::std::ostringstream detail_stream; \
28  detail_stream << stream; \
29  OpenGLHelper::debugMsgStream(detail_stream); \
30  } \
31  } while (false)
32 
34 #define VCL_GL_WARN(stream) \
35  do { \
36  if (SAL_DETAIL_ENABLE_LOG_INFO) \
37  { \
38  ::std::ostringstream detail_stream; \
39  detail_stream << stream; \
40  OpenGLHelper::debugMsgStreamWarn(detail_stream); \
41  } \
42  } while (false)
43 
44 // All member functions static and VCL_DLLPUBLIC. Basically a glorified namespace.
46 {
47  OpenGLHelper() = delete; // Should not be instantiated
48 
49 public:
50 
51  static OString GetDigest(const OUString& rVertexShaderName, const OUString& rFragmentShaderName, std::string_view preamble );
52 
53  static GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName, const OUString& rGeometryShaderName, std::string_view preamble, std::string_view rDigest );
54  static GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName, std::string_view preamble, std::string_view rDigest );
55  static GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName, const OUString& rGeometryShaderName);
56  static GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName);
57 
63  static BitmapEx ConvertBufferToBitmapEx(const sal_uInt8* const pBuffer, tools::Long nWidth, tools::Long nHeight);
67  static GLenum OptimalBufferFormat();
68  static void renderToFile(tools::Long nWidth, tools::Long nHeight, const OUString& rFileName);
69 
70  static const char* GLErrorString(GLenum errorCode);
71 
84  static void createFramebuffer(tools::Long nWidth, tools::Long nHeight, GLuint& nFramebufferId,
85  GLuint& nRenderbufferDepthId, GLuint& nRenderbufferColorId);
86 
88  static float getGLVersion();
89 
90  static void checkGLError(const char* aFile, size_t nLine);
91 
96 #if defined __GNUC__
97  __attribute__ ((format (printf, 2, 3)))
98 #endif
99  static void debugMsgPrint(const int nType, const char *pFormat, ...);
100  static void debugMsgStream(std::ostringstream const &pStream);
101  static void debugMsgStreamWarn(std::ostringstream const &pStream);
102 
106  static bool isDeviceDenylisted();
107 
111  static bool supportsOpenGL();
112 };
113 
114 #ifdef SAL_LOG_WARN
115 #define CHECK_GL_ERROR() OpenGLHelper::checkGLError(__FILE__, __LINE__)
116 #else
117 #define CHECK_GL_ERROR() do { } while (false)
118 #endif
119 
120 #endif
121 
122 /* vim:set shiftwidth=4 softtabstop=4 expandtab: */
unsigned _Unwind_Ptr __attribute__((__mode__(__pointer__)))
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
long Long
unsigned char sal_uInt8
QPRO_FUNC_TYPE nType