summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--src/graphicsmanager.cpp47
-rw-r--r--src/render/mglfunctions.h22
-rw-r--r--src/render/mglxinit.cpp14
3 files changed, 47 insertions, 36 deletions
diff --git a/src/graphicsmanager.cpp b/src/graphicsmanager.cpp
index ae7e911de..258c0f9f5 100644
--- a/src/graphicsmanager.cpp
+++ b/src/graphicsmanager.cpp
@@ -911,16 +911,15 @@ void GraphicsManager::initOpenGLFunctions()
else if (supportExtension("GL_EXT_framebuffer_object"))
{ // old frame buffer extension
logger->log1("found GL_EXT_framebuffer_object");
- assignFunction2(glGenRenderbuffers, "glGenRenderbuffersEXT");
- assignFunction2(glBindRenderbuffer, "glBindRenderbufferEXT");
- assignFunction2(glRenderbufferStorage, "glRenderbufferStorageEXT");
- assignFunction2(glGenFramebuffers, "glGenFramebuffersEXT");
- assignFunction2(glBindFramebuffer, "glBindFramebufferEXT");
- assignFunction2(glFramebufferTexture2D, "glFramebufferTexture2DEXT");
- assignFunction2(glFramebufferRenderbuffer,
- "glFramebufferRenderbufferEXT");
- assignFunction2(glDeleteFramebuffers, "glDeleteFramebuffersEXT");
- assignFunction2(glDeleteRenderbuffers, "glDeleteRenderbuffersEXT");
+ assignFunctionEXT(glGenRenderbuffers);
+ assignFunctionEXT(glBindRenderbuffer);
+ assignFunctionEXT(glRenderbufferStorage);
+ assignFunctionEXT(glGenFramebuffers);
+ assignFunctionEXT(glBindFramebuffer);
+ assignFunctionEXT(glFramebufferTexture2D);
+ assignFunctionEXT(glFramebufferRenderbuffer);
+ assignFunctionEXT(glDeleteFramebuffers);
+ assignFunctionEXT(glDeleteRenderbuffers);
}
else
{ // no frame buffer support
@@ -943,8 +942,8 @@ void GraphicsManager::initOpenGLFunctions()
else if (supportExtension("GL_ARB_debug_output"))
{
logger->log1("found GL_ARB_debug_output");
- assignFunction2(glDebugMessageControl, "glDebugMessageControlARB");
- assignFunction2(glDebugMessageCallback, "glDebugMessageCallbackARB");
+ assignFunctionARB(glDebugMessageControl);
+ assignFunctionARB(glDebugMessageCallback);
mSupportDebug = 1;
}
else
@@ -965,14 +964,10 @@ void GraphicsManager::initOpenGLFunctions()
if (supportExtension("GL_EXT_debug_label"))
{
logger->log1("found GL_EXT_debug_label");
- assignFunction2(glLabelObject, "glLabelObjectEXT");
- if (!mglLabelObject)
- assignFunction2(glLabelObject, "glLabelObject");
+ assignFunctionEXT(glLabelObject);
if (!mglLabelObject)
assignFunction2(glLabelObject, "glObjectLabel");
- assignFunction2(glGetObjectLabel, "glGetObjectLabelEXT");
- if (!mglGetObjectLabel)
- assignFunction2(glGetObjectLabel, "glGetObjectLabel");
+ assignFunctionEXT(glGetObjectLabel);
}
else
{
@@ -990,15 +985,9 @@ void GraphicsManager::initOpenGLFunctions()
if (supportExtension("GL_EXT_debug_marker"))
{
logger->log1("found GL_EXT_debug_marker");
- assignFunction2(glInsertEventMarker, "glInsertEventMarkerEXT");
- if (!mglInsertEventMarker)
- assignFunction2(glInsertEventMarker, "glInsertEventMarker");
- assignFunction2(glPushGroupMarker, "glPushGroupMarkerEXT");
- if (!mglPushGroupMarker)
- assignFunction2(glPushGroupMarker, "glPushGroupMarker");
- assignFunction2(glPopGroupMarker, "glPopGroupMarkerEXT");
- if (!mglPopGroupMarker)
- assignFunction2(glPopGroupMarker, "glPopGroupMarker");
+ assignFunctionEXT(glInsertEventMarker);
+ assignFunctionEXT(glPushGroupMarker);
+ assignFunctionEXT(glPopGroupMarker);
}
else
{
@@ -1012,7 +1001,7 @@ void GraphicsManager::initOpenGLFunctions()
assignFunction(glEndQuery);
assignFunction(glDeleteQueries);
assignFunction(glGetQueryObjectiv);
- assignFunction2(glGetQueryObjectui64v, "glGetQueryObjectui64vEXT");
+ assignFunctionEXT(glGetQueryObjectui64v);
}
else
{
@@ -1142,7 +1131,7 @@ void GraphicsManager::initOpenGLFunctions()
}
#ifdef WIN32
- assignFunction2(wglGetExtensionsString, "wglGetExtensionsStringARB");
+ assignFunctionARB(wglGetExtensionsString);
#endif
}
diff --git a/src/render/mglfunctions.h b/src/render/mglfunctions.h
index 569f4aac4..23e3bea6d 100644
--- a/src/render/mglfunctions.h
+++ b/src/render/mglfunctions.h
@@ -45,6 +45,28 @@
logger->log("assigned function: " #func); \
}
+#define assignFunction3(func, ext) \
+ { \
+ m##func = reinterpret_cast<func##_t>(getFunction(#func#ext)); \
+ if (m##func == nullptr) \
+ { \
+ logger->log("function not found: " #func#ext); \
+ m##func = reinterpret_cast<func##_t>(getFunction(#func)); \
+ if (m##func == nullptr) \
+ logger->log("function not found: " #func); \
+ else \
+ logger->log("assigned function: " #func); \
+ } \
+ else \
+ { \
+ logger->log("assigned function: " #func#ext); \
+ } \
+ }
+
+#define assignFunctionARB(func) assignFunction3(func, ARB)
+
+#define assignFunctionEXT(func) assignFunction3(func, EXT)
+
#define assignFunction2(func, name) \
{ \
m##func = reinterpret_cast<func##_t>(getFunction(name)); \
diff --git a/src/render/mglxinit.cpp b/src/render/mglxinit.cpp
index e6763d45e..23c592d8d 100644
--- a/src/render/mglxinit.cpp
+++ b/src/render/mglxinit.cpp
@@ -30,13 +30,13 @@
void Glx::initFunctions()
{
- assignFunction2(glXCreateContext, "glXCreateContext");
- assignFunction2(glXGetCurrentContext, "glXGetCurrentContext");
- assignFunction2(glXCreateContextAttribs, "glXCreateContextAttribsARB");
- assignFunction2(glXChooseFBConfig, "glXChooseFBConfig");
- assignFunction2(glXDestroyContext, "glXDestroyContext");
- assignFunction2(glXMakeCurrent, "glXMakeCurrent");
- assignFunction2(glXSwapBuffers, "glXSwapBuffers");
+ assignFunction(glXCreateContext);
+ assignFunction(glXGetCurrentContext);
+ assignFunctionARB(glXCreateContextAttribs);
+ assignFunction(glXChooseFBConfig);
+ assignFunction(glXDestroyContext);
+ assignFunction(glXMakeCurrent);
+ assignFunction(glXSwapBuffers);
}
#endif