leocad/common/lc_glextensions.cpp

66 lines
1.8 KiB
C++
Raw Normal View History

2016-10-05 23:28:52 +02:00
#include "lc_global.h"
#include "lc_glextensions.h"
2021-01-08 20:25:24 +01:00
#include <QOpenGLFunctions_3_2_Core>
2016-10-05 23:28:52 +02:00
bool gSupportsShaderObjects;
bool gSupportsVertexBufferObject;
2020-12-27 22:05:55 +01:00
bool gSupportsFramebufferObject;
bool gSupportsBlendFuncSeparate;
2016-10-05 23:28:52 +02:00
bool gSupportsAnisotropic;
GLfloat gMaxAnisotropy;
#if !defined(QT_NO_DEBUG) && defined(GL_ARB_debug_output)
2024-04-28 02:19:34 +02:00
#ifndef APIENTRY
#define APIENTRY
#endif
2016-10-05 23:28:52 +02:00
static void APIENTRY lcGLDebugCallback(GLenum Source, GLenum Type, GLuint Id, GLenum Severity, GLsizei Length, const GLchar* Message, GLvoid* UserParam)
{
Q_UNUSED(Source);
Q_UNUSED(Type);
Q_UNUSED(Id);
Q_UNUSED(Severity);
Q_UNUSED(Length);
Q_UNUSED(UserParam);
qDebug() << Message;
}
#endif
2020-12-27 22:05:55 +01:00
void lcInitializeGLExtensions(const QOpenGLContext* Context)
{
const QOpenGLFunctions* Functions = Context->functions();
#if !defined(QT_NO_DEBUG) && defined(GL_ARB_debug_output)
if (Context->hasExtension("GL_KHR_debug"))
{
PFNGLDEBUGMESSAGECALLBACKARBPROC DebugMessageCallback = (PFNGLDEBUGMESSAGECALLBACKARBPROC)Context->getProcAddress("glDebugMessageCallback");
#ifndef GL_DEBUG_OUTPUT
#define GL_DEBUG_OUTPUT 0x92E0
#endif
if (DebugMessageCallback)
{
DebugMessageCallback((GLDEBUGPROCARB)&lcGLDebugCallback, nullptr);
glEnable(GL_DEBUG_OUTPUT);
glEnable(GL_DEBUG_OUTPUT_SYNCHRONOUS_ARB);
}
}
#endif
if (Context->hasExtension("GL_EXT_texture_filter_anisotropic"))
{
glGetFloatv(GL_MAX_TEXTURE_MAX_ANISOTROPY_EXT, &gMaxAnisotropy);
gSupportsAnisotropic = true;
}
gSupportsVertexBufferObject = Functions->hasOpenGLFeature(QOpenGLFunctions::Buffers);
gSupportsFramebufferObject = Functions->hasOpenGLFeature(QOpenGLFunctions::Framebuffers);
gSupportsBlendFuncSeparate = Functions->hasOpenGLFeature(QOpenGLFunctions::BlendFuncSeparate);
gSupportsShaderObjects = Functions->hasOpenGLFeature(QOpenGLFunctions::Shaders);
}