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
49public:
50
51#if defined _WIN32
52 static OString GetDigest(const OUString& rVertexShaderName, const OUString& rFragmentShaderName, std::string_view preamble );
53#endif
54
55 static GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName, const OUString& rGeometryShaderName, std::string_view preamble, std::string_view rDigest );
56 static GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName, std::string_view preamble, std::string_view rDigest );
57 static GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName, const OUString& rGeometryShaderName);
58 static GLint LoadShaders(const OUString& rVertexShaderName, const OUString& rFragmentShaderName);
59
65 static BitmapEx ConvertBufferToBitmapEx(const sal_uInt8* const pBuffer, tools::Long nWidth, tools::Long nHeight);
69 static GLenum OptimalBufferFormat();
70 static void renderToFile(tools::Long nWidth, tools::Long nHeight, const OUString& rFileName);
71
72 static const char* GLErrorString(GLenum errorCode);
73
86 static void createFramebuffer(tools::Long nWidth, tools::Long nHeight, GLuint& nFramebufferId,
87 GLuint& nRenderbufferDepthId, GLuint& nRenderbufferColorId);
88
90 static float getGLVersion();
91
92 static void checkGLError(const char* aFile, size_t nLine);
93
98#if defined __GNUC__
99 __attribute__ ((format (printf, 2, 3)))
100#endif
101 static void debugMsgPrint(const int nType, const char *pFormat, ...);
102 static void debugMsgStream(std::ostringstream const &pStream);
103 static void debugMsgStreamWarn(std::ostringstream const &pStream);
104
108 static bool isDeviceDenylisted();
109
113 static bool supportsOpenGL();
114};
115
116#ifdef SAL_LOG_WARN
117#define CHECK_GL_ERROR() OpenGLHelper::checkGLError(__FILE__, __LINE__)
118#else
119#define CHECK_GL_ERROR() do { } while (false)
120#endif
121
122#endif
123
124/* vim:set shiftwidth=4 softtabstop=4 expandtab: */
#define VCL_DLLPUBLIC
Definition: dllapi.h:29
long Long
OpenGLHelper()=delete
unsigned char sal_uInt8
unsigned _Unwind_Word __attribute__((__mode__(__word__)))