1 #include "lc_global.h"
2 #include "lc_glextensions.h"
3 #include <QOpenGLFunctions_3_2_Core>
4
5 bool gSupportsShaderObjects;
6 bool gSupportsVertexBufferObject;
7 bool gSupportsFramebufferObject;
8 bool gSupportsBlendFuncSeparate;
9 bool gSupportsAnisotropic;
10 GLfloat gMaxAnisotropy;
11
12 #if !defined(QT_NO_DEBUG) && defined(GL_ARB_debug_output)
13
lcGLDebugCallback(GLenum Source,GLenum Type,GLuint Id,GLenum Severity,GLsizei Length,const GLchar * Message,GLvoid * UserParam)14 static void APIENTRY lcGLDebugCallback(GLenum Source, GLenum Type, GLuint Id, GLenum Severity, GLsizei Length, const GLchar* Message, GLvoid* UserParam)
15 {
16 Q_UNUSED(Source);
17 Q_UNUSED(Type);
18 Q_UNUSED(Id);
19 Q_UNUSED(Severity);
20 Q_UNUSED(Length);
21 Q_UNUSED(UserParam);
22
23 qDebug() << Message;
24 }
25
26 #endif
27
lcInitializeGLExtensions(const QOpenGLContext * Context)28 void lcInitializeGLExtensions(const QOpenGLContext* Context)
29 {
30 const QOpenGLFunctions* Functions = Context->functions();
31
32 #if !defined(QT_NO_DEBUG) && defined(GL_ARB_debug_output)
33 if (Context->hasExtension("GL_KHR_debug"))
34 {
35 PFNGLDEBUGMESSAGECALLBACKARBPROC DebugMessageCallback = (PFNGLDEBUGMESSAGECALLBACKARBPROC)Context->getProcAddress("glDebugMessageCallback");
36
37 #ifndef GL_DEBUG_OUTPUT
38 #define GL_DEBUG_OUTPUT 0x92E0
39 #endif
40
41 if (DebugMessageCallback)
42 {
43 DebugMessageCallback((GLDEBUGPROCARB)&lcGLDebugCallback, nullptr);
44 glEnable(GL_DEBUG_OUTPUT);
45 glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
46 }
47 }
48 #endif
49
50 if (Context->hasExtension("GL_EXT_texture_filter_anisotropic"))
51 {
52 glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &gMaxAnisotropy);
53
54 gSupportsAnisotropic = true;
55 }
56
57 gSupportsVertexBufferObject = Functions->hasOpenGLFeature(QOpenGLFunctions::Buffers);
58 gSupportsFramebufferObject = Functions->hasOpenGLFeature(QOpenGLFunctions::Framebuffers);
59 gSupportsBlendFuncSeparate = Functions->hasOpenGLFeature(QOpenGLFunctions::BlendFuncSeparate);
60 gSupportsShaderObjects = Functions->hasOpenGLFeature(QOpenGLFunctions::Shaders);
61 }
62