diff --git a/abstract_egl_backend.cpp b/abstract_egl_backend.cpp index e019d5c7d5..ec01840886 100644 --- a/abstract_egl_backend.cpp +++ b/abstract_egl_backend.cpp @@ -107,6 +107,12 @@ bool AbstractEglBackend::initEglAPI() return true; } +typedef void (*eglFuncPtr)(); +static eglFuncPtr getProcAddress(const char* name) +{ + return eglGetProcAddress(name); +} + void AbstractEglBackend::initKWinGL() { initEGL(); @@ -116,7 +122,7 @@ void AbstractEglBackend::initKWinGL() if (options->glPreferBufferSwap() == Options::AutoSwapStrategy) options->setGlPreferBufferSwap('e'); // for unknown drivers - should not happen glPlatform->printResults(); - initGL(EglPlatformInterface); + initGL(&getProcAddress); } void AbstractEglBackend::initBufferAge() diff --git a/libkwineffects/CMakeLists.txt b/libkwineffects/CMakeLists.txt index a0e1ccf043..306e380a0e 100644 --- a/libkwineffects/CMakeLists.txt +++ b/libkwineffects/CMakeLists.txt @@ -105,11 +105,6 @@ kwin4_add_glutils_backend(kwinglutils ${epoxy_INCLUDE_DIR} ${epoxy_LIBRARY}) set_target_properties(kwinglutils PROPERTIES OUTPUT_NAME ${KWIN_NAME}glutils) target_link_libraries(kwinglutils PUBLIC ${epoxy_LIBRARY}) -# -ldl used by OpenGL code -find_library(DL_LIBRARY dl) -if (DL_LIBRARY) - target_link_libraries(kwinglutils PRIVATE ${DL_LIBRARY}) -endif() install( FILES kwinglobals.h diff --git a/libkwineffects/kwinglutils.cpp b/libkwineffects/kwinglutils.cpp index 2ddbd2bdc2..8e8c2198fb 100644 --- a/libkwineffects/kwinglutils.cpp +++ b/libkwineffects/kwinglutils.cpp @@ -84,7 +84,7 @@ void initEGL() eglResolveFunctions(); } -void initGL(OpenGLPlatformInterface platformInterface) +void initGL(std::function resolveFunction) { // Get list of supported OpenGL extensions if (hasGLVersion(3, 0)) { @@ -99,7 +99,7 @@ void initGL(OpenGLPlatformInterface platformInterface) glExtensions = QByteArray((const char*)glGetString(GL_EXTENSIONS)).split(' '); // handle OpenGL extensions functions - glResolveFunctions(platformInterface); + glResolveFunctions(resolveFunction); GLTexturePrivate::initStatic(); GLRenderTarget::initStatic(); diff --git a/libkwineffects/kwinglutils.h b/libkwineffects/kwinglutils.h index 9e17620335..dada31ce61 100644 --- a/libkwineffects/kwinglutils.h +++ b/libkwineffects/kwinglutils.h @@ -51,7 +51,8 @@ class GLVertexBufferPrivate; // Initializes OpenGL stuff. This includes resolving function pointers as // well as checking for GL version and extensions // Note that GL context has to be created by the time this function is called -void KWINGLUTILS_EXPORT initGL(OpenGLPlatformInterface platformInterface); +typedef void (*resolveFuncPtr)(); +void KWINGLUTILS_EXPORT initGL(std::function resolveFunction); // Initializes EGL function pointers void KWINGLUTILS_EXPORT initEGL(); // Cleans up all resources hold by the GL Context diff --git a/libkwineffects/kwinglutils_funcs.cpp b/libkwineffects/kwinglutils_funcs.cpp index c8783fa0fd..1c786f64cc 100644 --- a/libkwineffects/kwinglutils_funcs.cpp +++ b/libkwineffects/kwinglutils_funcs.cpp @@ -21,26 +21,11 @@ along with this program. If not, see . #include "kwinglutils.h" #include "kwinglplatform.h" -#include -#if HAVE_EPOXY_GLX -#include -#endif - // Resolves given function, using getProcAddress -#define GL_RESOLVE( function ) \ - if (platformInterface == GlxPlatformInterface) \ - function = (function ## _func)getProcAddress( #function ); \ - else if (platformInterface == EglPlatformInterface) \ - function = (function ## _func)eglGetProcAddress( #function ); -// Same as above but tries to use function "symbolName" // Useful when functionality is defined in an extension with a different name #define GL_RESOLVE_WITH_EXT( function, symbolName ) \ - if (platformInterface == GlxPlatformInterface) { \ - function = (function ## _func)getProcAddress( #symbolName ); \ - } else if (platformInterface == EglPlatformInterface) { \ - function = (function ## _func)eglGetProcAddress( #symbolName ); \ - } + function = (function ## _func)resolveFunction( #symbolName ); namespace KWin { @@ -55,24 +40,11 @@ glGetGraphicsResetStatus_func glGetGraphicsResetStatus; glReadnPixels_func glReadnPixels; glGetnUniformfv_func glGetnUniformfv; -typedef void (*glXFuncPtr)(); - -static glXFuncPtr getProcAddress(const char* name) -{ - glXFuncPtr ret = nullptr; -#if HAVE_EPOXY_GLX - ret = glXGetProcAddress((const GLubyte*) name); -#endif - if (ret == nullptr) - ret = (glXFuncPtr) dlsym(RTLD_DEFAULT, name); - return ret; -} - void eglResolveFunctions() { } -void glResolveFunctions(OpenGLPlatformInterface platformInterface) +void glResolveFunctions(std::function resolveFunction) { const bool haveArbRobustness = hasGLExtension(QByteArrayLiteral("GL_ARB_robustness")); const bool haveExtRobustness = hasGLExtension(QByteArrayLiteral("GL_EXT_robustness")); @@ -103,9 +75,9 @@ void glResolveFunctions(OpenGLPlatformInterface platformInterface) GL_RESOLVE_WITH_EXT(glGetnUniformfv, glGetnUniformfvARB); } else if (robustContext && haveExtRobustness) { // See http://www.khronos.org/registry/gles/extensions/EXT/EXT_robustness.txt - glGetGraphicsResetStatus = (glGetGraphicsResetStatus_func) eglGetProcAddress("glGetGraphicsResetStatusEXT"); - glReadnPixels = (glReadnPixels_func) eglGetProcAddress("glReadnPixelsEXT"); - glGetnUniformfv = (glGetnUniformfv_func) eglGetProcAddress("glGetnUniformfvEXT"); + glGetGraphicsResetStatus = (glGetGraphicsResetStatus_func) resolveFunction("glGetGraphicsResetStatusEXT"); + glReadnPixels = (glReadnPixels_func) resolveFunction("glReadnPixelsEXT"); + glGetnUniformfv = (glGetnUniformfv_func) resolveFunction("glGetnUniformfvEXT"); } else { glGetGraphicsResetStatus = KWin::GetGraphicsResetStatus; glReadnPixels = KWin::ReadnPixels; diff --git a/libkwineffects/kwinglutils_funcs.h b/libkwineffects/kwinglutils_funcs.h index b9787d3d43..43eee76c9e 100644 --- a/libkwineffects/kwinglutils_funcs.h +++ b/libkwineffects/kwinglutils_funcs.h @@ -30,6 +30,7 @@ along with this program. If not, see . #include #include +#include // qopengl.h declares GLdouble as a typedef of float when Qt is built // with GLES support. This conflicts with the epoxy/gl_generated.h @@ -49,7 +50,8 @@ namespace KWin void KWINGLUTILS_EXPORT eglResolveFunctions(); -void KWINGLUTILS_EXPORT glResolveFunctions(OpenGLPlatformInterface platformInterface); +typedef void (*resolveFuncPtr)(); +void KWINGLUTILS_EXPORT glResolveFunctions(std::function resolveFunction); // GL_ARB_robustness / GL_EXT_robustness using glGetGraphicsResetStatus_func = GLenum (*)(); diff --git a/plugins/platforms/x11/standalone/glxbackend.cpp b/plugins/platforms/x11/standalone/glxbackend.cpp index 43bdedcdc8..d2dbada885 100644 --- a/plugins/platforms/x11/standalone/glxbackend.cpp +++ b/plugins/platforms/x11/standalone/glxbackend.cpp @@ -199,7 +199,7 @@ void GlxBackend::init() if (options->glPreferBufferSwap() == Options::AutoSwapStrategy) options->setGlPreferBufferSwap('e'); // for unknown drivers - should not happen glPlatform->printResults(); - initGL(GlxPlatformInterface); + initGL(&getProcAddress); // Check whether certain features are supported m_haveMESACopySubBuffer = hasExtension(QByteArrayLiteral("GLX_MESA_copy_sub_buffer"));