10 #ifndef hifi_GLHelpers_h
11 #define hifi_GLHelpers_h
14 #include <QJsonObject>
16 #include "GLLogging.h"
19 #define DEFAULT_GL_DEPTH_BUFFER_BITS 16
22 #define DEFAULT_GL_STENCIL_BUFFER_BITS 8
25 class QOpenGLDebugMessage;
29 size_t evalGLFormatSwapchainPixelSize(
const QSurfaceFormat& format);
31 const QSurfaceFormat& getDefaultOpenGLSurfaceFormat();
32 int glVersionToInteger(QString glVersion);
34 bool isRenderThread();
36 #define GL_MAKE_VERSION(major, minor) ((major << 8) | minor)
37 #define GL_GET_MINOR_VERSION(glversion) (glversion & 0x00FF)
38 #define GL_GET_MAJOR_VERSION(glversion) ((glversion & 0xFF00) >> 8)
43 std::string shadingLanguageVersion;
46 std::vector<std::string> extensions;
49 operator bool()
const {
return !version.empty(); }
51 static const ContextInfo& get(
bool init =
false);
54 #define LOG_GL_CONTEXT_INFO(category, contextInfo) \
55 qCDebug(category) << "GL Version: " << contextInfo.version.c_str(); \
56 qCDebug(category) << "GL Shader Language Version: " << contextInfo.shadingLanguageVersion.c_str(); \
57 qCDebug(category) << "GL Vendor: " << contextInfo.vendor.c_str(); \
58 qCDebug(category) << "GL Renderer: " << contextInfo.renderer.c_str();
62 void globalRelease(
bool finish =
true);
64 bool debugContextEnabled();
66 bool khrDebugEnabled();
68 bool extDebugMarkerEnabled();
70 void withSavedContext(
const std::function<
void()>& f);
72 bool checkGLError(
const char* name);
74 bool checkGLErrorDebug(
const char* name);
77 void setDisableGl45(
bool disable);
79 uint16_t getTargetVersion();
81 uint16_t getAvailableVersion();
83 uint16_t getRequiredVersion();
86 #define CHECK_GL_ERROR() ::gl::checkGLErrorDebug(__FUNCTION__)