diff --git a/CMakeLists.txt b/CMakeLists.txt index e8c4019f27..e28632f712 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -236,16 +236,8 @@ if( KWIN_BUILD_XRENDER_COMPOSITING ) set( KWIN_HAVE_XRENDER_COMPOSITING 1 ) endif() -if(KWIN_BUILD_OPENGL) - include_directories(${OPENGL_INCLUDE_DIR}) -endif() - set(KWIN_HAVE_EGL ${EGL_FOUND}) -if(KWIN_BUILD_OPENGLES) - include_directories(${OPENGLES_INCLUDE_DIR}) -endif() - if (XKB_FOUND) include_directories(${XKB_INCLUDE_DIR}) endif() @@ -488,8 +480,6 @@ set(kwin_WAYLAND_EGL_LIBS Wayland::Egl ) -set(kwin_OPENGL_LIBS ) - find_library(XF86VM_LIBRARY Xxf86vm) if (XF86VM_LIBRARY) set(kwin_XLIB_LIBS ${kwin_XLIB_LIBS} ${XF86VM_LIBRARY}) @@ -501,17 +491,12 @@ if(KWIN_BUILD_ACTIVITIES) set(kwin_KDE_LIBS ${kwin_KDE_LIBS} KF5::Activities) endif() -if(KWIN_HAVE_EGL) - set(kwin_OPENGL_LIBS ${kwin_OPENGL_LIBS} EGL::EGL) -endif() - set(kwinLibs ${kwin_OWN_LIBS} ${kwin_QT_LIBS} ${kwin_KDE_LIBS} ${kwin_XLIB_LIBS} ${kwin_XCB_LIBS} - ${kwin_OPENGL_LIBS} ) if(Wayland_Client_FOUND AND XKB_FOUND) @@ -528,14 +513,14 @@ set_target_properties(kwin PROPERTIES OUTPUT_NAME ${KWIN_INTERNAL_NAME_X11}) generate_export_header(kdeinit_kwin EXPORT_FILE_NAME kwin_export.h) if(KWIN_BUILD_OPENGL) - target_link_libraries(kdeinit_kwin kwinglutils ${OPENGL_gl_LIBRARY}) + target_link_libraries(kdeinit_kwin kwinglutils ${epoxy_LIBRARY}) # -ldl used by OpenGL code find_library(DL_LIBRARY dl) if (DL_LIBRARY) target_link_libraries(kdeinit_kwin ${DL_LIBRARY}) endif() elseif(KWIN_BUILD_OPENGLES) - target_link_libraries(kdeinit_kwin ${kwinLibs} kwinglesutils ${OPENGLES_LIBRARIES}) + target_link_libraries(kdeinit_kwin ${kwinLibs} kwinglesutils ${epoxy_LIBRARY}) set_target_properties(kdeinit_kwin PROPERTIES COMPILE_FLAGS "-DKWIN_HAVE_OPENGLES") endif() diff --git a/eglonxbackend.cpp b/eglonxbackend.cpp index d7b5481682..76b4230855 100644 --- a/eglonxbackend.cpp +++ b/eglonxbackend.cpp @@ -95,7 +95,7 @@ void EglOnXBackend::init() } // check for EGL_NV_post_sub_buffer and whether it can be used on the surface - if (eglPostSubBufferNV) { + if (hasGLExtension(QStringLiteral("EGL_NV_post_sub_buffer"))) { if (eglQuerySurface(dpy, surface, EGL_POST_SUB_BUFFER_SUPPORTED_NV, &surfaceHasSubPost) == EGL_FALSE) { EGLint error = eglGetError(); if (error != EGL_SUCCESS && error != EGL_BAD_ATTRIBUTE) { diff --git a/glxbackend.cpp b/glxbackend.cpp index e78d1b1530..7141b3c882 100644 --- a/glxbackend.cpp +++ b/glxbackend.cpp @@ -112,7 +112,12 @@ void GlxBackend::init() initGL(GlxPlatformInterface); // Check whether certain features are supported - haveSwapInterval = glXSwapIntervalMESA || glXSwapIntervalEXT || glXSwapIntervalSGI; + m_haveMESACopySubBuffer = hasGLExtension(QStringLiteral("GLX_MESA_copy_sub_buffer")); + m_haveMESASwapControl = hasGLExtension(QStringLiteral("GLX_MESA_swap_control")); + m_haveEXTSwapControl = hasGLExtension(QStringLiteral("GLX_EXT_swap_control")); + m_haveSGISwapControl = hasGLExtension(QStringLiteral("GLX_SGI_swap_control")); + + haveSwapInterval = m_haveMESASwapControl || m_haveEXTSwapControl || m_haveSGISwapControl; setSupportsBufferAge(false); @@ -139,9 +144,9 @@ void GlxBackend::init() gs_tripleBufferUndetected = false; } gs_tripleBufferNeedsDetection = gs_tripleBufferUndetected; - } else if (glXGetVideoSync) { + } else if (hasGLExtension(QStringLiteral("GLX_SGI_video_sync"))) { unsigned int sync; - if (glXGetVideoSync(&sync) == 0 && glXWaitVideoSync(1, 0, &sync) == 0) { + if (glXGetVideoSyncSGI(&sync) == 0 && glXWaitVideoSyncSGI(1, 0, &sync) == 0) { setSyncsToVBlank(true); setBlocksForRetrace(true); haveWaitSync = true; @@ -170,7 +175,7 @@ bool GlxBackend::initRenderingContext() const bool direct = true; // Use glXCreateContextAttribsARB() when it's available - if (glXCreateContextAttribsARB) { + if (hasGLExtension(QStringLiteral("GLX_ARB_create_context"))) { const int attribs_31_core_robustness[] = { GLX_CONTEXT_MAJOR_VERSION_ARB, 3, GLX_CONTEXT_MINOR_VERSION_ARB, 1, @@ -414,11 +419,11 @@ bool GlxBackend::initDrawableConfigs() void GlxBackend::setSwapInterval(int interval) { - if (glXSwapIntervalEXT) + if (m_haveEXTSwapControl) glXSwapIntervalEXT(display(), glxWindow, interval); - else if (glXSwapIntervalMESA) + else if (m_haveMESASwapControl) glXSwapIntervalMESA(interval); - else if (glXSwapIntervalSGI) + else if (m_haveSGISwapControl) glXSwapIntervalSGI(interval); } @@ -434,7 +439,7 @@ void GlxBackend::waitSync() glXGetVideoSync(&sync); glXWaitVideoSync(2, (sync + 1) % 2, &sync); #else - glXWaitVideoSync(1, 0, &sync); + glXWaitVideoSyncSGI(1, 0, &sync); #endif } } @@ -480,11 +485,11 @@ void GlxBackend::present() if (supportsBufferAge()) { glXQueryDrawable(display(), glxWindow, GLX_BACK_BUFFER_AGE_EXT, (GLuint *) &m_bufferAge); } - } else if (glXCopySubBuffer) { + } else if (m_haveMESACopySubBuffer) { foreach (const QRect & r, lastDamage().rects()) { // convert to OpenGL coordinates int y = displayHeight() - r.y() - r.height(); - glXCopySubBuffer(display(), glxWindow, r.x(), y, r.width(), r.height()); + glXCopySubBufferMESA(display(), glxWindow, r.x(), y, r.width(), r.height()); } } else { // Copy Pixels (horribly slow on Mesa) glDrawBuffer(GL_FRONT); diff --git a/glxbackend.h b/glxbackend.h index d9f81ec426..a2821dcfce 100644 --- a/glxbackend.h +++ b/glxbackend.h @@ -73,6 +73,10 @@ private: GLXWindow glxWindow; GLXContext ctx; int m_bufferAge; + bool m_haveMESACopySubBuffer; + bool m_haveMESASwapControl; + bool m_haveEXTSwapControl; + bool m_haveSGISwapControl; bool haveSwapInterval, haveWaitSync; friend class GlxTexture; }; diff --git a/libkwineffects/CMakeLists.txt b/libkwineffects/CMakeLists.txt index 16b19aca5e..e66ad61502 100644 --- a/libkwineffects/CMakeLists.txt +++ b/libkwineffects/CMakeLists.txt @@ -88,9 +88,6 @@ macro( KWIN4_ADD_GLUTILS_BACKEND name glinclude ) add_library(${name} SHARED ${kwin_GLUTILSLIB_SRCS}) generate_export_header(${name} BASE_NAME kwinglutils EXPORT_FILE_NAME kwinglutils_export.h) target_link_libraries(${name} PUBLIC Qt5::DBus Qt5::X11Extras XCB::XCB KF5::Service KF5::WindowSystem) - if(KWIN_HAVE_EGL) - target_link_libraries(${name} PRIVATE EGL::EGL) - endif() set_target_properties(${name} PROPERTIES VERSION ${KWINEFFECTS_VERSION_STRING} SOVERSION ${KWINEFFECTS_SOVERSION} @@ -101,15 +98,15 @@ macro( KWIN4_ADD_GLUTILS_BACKEND name glinclude ) endmacro() if(KWIN_BUILD_OPENGLES) - kwin4_add_glutils_backend(kwinglesutils ${OPENGLES_INCLUDE_DIR} ${OPENGLES_LIBRARIES}) + kwin4_add_glutils_backend(kwinglesutils ${epoxy_INCLUDE_DIR} ${epoxy_LIBRARY}) set_target_properties(kwinglesutils PROPERTIES COMPILE_FLAGS -DKWIN_HAVE_OPENGLES) set_target_properties(kwinglesutils PROPERTIES OUTPUT_NAME ${KWIN_NAME}glesutils) endif() if(KWIN_BUILD_OPENGL) - kwin4_add_glutils_backend(kwinglutils ${OPENGL_INCLUDE_DIR} ${OPENGL_gl_LIBRARY}) + 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 ${OPENGL_gl_LIBRARY}) + target_link_libraries(kwinglutils PUBLIC ${epoxy_LIBRARY}) # -ldl used by OpenGL code find_library(DL_LIBRARY dl) if (DL_LIBRARY) diff --git a/libkwineffects/kwinglcolorcorrection.cpp b/libkwineffects/kwinglcolorcorrection.cpp index 53dcff6c0f..50ecfcf27e 100644 --- a/libkwineffects/kwinglcolorcorrection.cpp +++ b/libkwineffects/kwinglcolorcorrection.cpp @@ -239,6 +239,7 @@ ColorCorrectionPrivate::ColorCorrectionPrivate(ColorCorrection *parent) , m_enabled(false) , m_hasError(false) , m_duringEnablingPhase(false) + , m_haveTexture3D(true) , m_ccTextureUnit(-1) , m_dummyCCTexture(0) , m_lastOutput(-1) @@ -258,6 +259,10 @@ ColorCorrectionPrivate::ColorCorrectionPrivate(ColorCorrection *parent) connect(m_csi, SIGNAL(updateSucceeded()), this, SLOT(colorServerUpdateSucceededSlot())); connect(m_csi, SIGNAL(updateFailed()), this, SLOT(colorServerUpdateFailedSlot())); + +#ifdef KWIN_HAVE_OPENGLES + m_haveTexture3D = hasGLVersion(3, 0) || hasGLExtension(QStringLiteral("GL_OES_texture_3D")); +#endif } ColorCorrectionPrivate::~ColorCorrectionPrivate() @@ -285,7 +290,7 @@ bool ColorCorrection::setEnabled(bool enabled) #ifdef KWIN_HAVE_OPENGLES const GLPlatform *gl = GLPlatform::instance(); - if (enabled && gl->isGLES() && glTexImage3D == 0) { + if (enabled && gl->isGLES() && !m_haveTexture3D) { qCritical() << "color correction is not supported on OpenGL ES without OES_texture_3D"; d->m_hasError = true; return false; diff --git a/libkwineffects/kwinglcolorcorrection_p.h b/libkwineffects/kwinglcolorcorrection_p.h index 4bc6a84587..0273ca5474 100644 --- a/libkwineffects/kwinglcolorcorrection_p.h +++ b/libkwineffects/kwinglcolorcorrection_p.h @@ -93,6 +93,7 @@ public: bool m_enabled; bool m_hasError; bool m_duringEnablingPhase; + bool m_haveTexture3D; int m_ccTextureUnit; ColorServerInterface *m_csi; diff --git a/libkwineffects/kwinglplatform.cpp b/libkwineffects/kwinglplatform.cpp index 9a391a03e3..e8cbc9873b 100644 --- a/libkwineffects/kwinglplatform.cpp +++ b/libkwineffects/kwinglplatform.cpp @@ -534,15 +534,6 @@ void GLPlatform::detect(OpenGLPlatformInterface platformInterface) #ifndef KWIN_HAVE_OPENGLES if (m_glVersion >= kVersionNumber(3, 0)) { - PFNGLGETSTRINGIPROC glGetStringi; - -#ifdef KWIN_HAVE_EGL - if (platformInterface == EglPlatformInterface) - glGetStringi = (PFNGLGETSTRINGIPROC) eglGetProcAddress("glGetStringi"); - else -#endif - glGetStringi = (PFNGLGETSTRINGIPROC) glXGetProcAddress((const GLubyte *) "glGetStringi"); - int count; glGetIntegerv(GL_NUM_EXTENSIONS, &count); diff --git a/libkwineffects/kwinglutils.cpp b/libkwineffects/kwinglutils.cpp index 86c0264aff..0c8586e0cd 100644 --- a/libkwineffects/kwinglutils.cpp +++ b/libkwineffects/kwinglutils.cpp @@ -105,15 +105,6 @@ void initGL(OpenGLPlatformInterface platformInterface) // Get list of supported OpenGL extensions if (hasGLVersion(3, 0)) { - PFNGLGETSTRINGIPROC glGetStringi; - -#ifdef KWIN_HAVE_EGL - if (platformInterface == EglPlatformInterface) - glGetStringi = (PFNGLGETSTRINGIPROC) eglGetProcAddress("glGetStringi"); - else -#endif - glGetStringi = (PFNGLGETSTRINGIPROC) glXGetProcAddress((const GLubyte *) "glGetStringi"); - int count; glGetIntegerv(GL_NUM_EXTENSIONS, &count); @@ -395,7 +386,7 @@ void GLShader::bindAttributeLocation(const char *name, int index) void GLShader::bindFragDataLocation(const char *name, int index) { #ifndef KWIN_HAVE_OPENGLES - if (glBindFragDataLocation) + if (hasGLVersion(3, 0) || hasGLExtension(QStringLiteral("GL_EXT_gpu_shader4"))) glBindFragDataLocation(mProgram, index, name); #else Q_UNUSED(name) @@ -1878,8 +1869,12 @@ void GLVertexBuffer::initStatic() GLVertexBufferPrivate::hasMapBufferRange = hasGLExtension(QStringLiteral("GL_EXT_map_buffer_range")); GLVertexBufferPrivate::supportsIndexedQuads = false; #else - GLVertexBufferPrivate::hasMapBufferRange = hasGLVersion(3, 0) || hasGLExtension(QStringLiteral("GL_ARB_map_buffer_range")); - GLVertexBufferPrivate::supportsIndexedQuads = glMapBufferRange && glCopyBufferSubData && glDrawElementsBaseVertex; + bool haveBaseVertex = hasGLVersion(3, 2) || hasGLExtension(QStringLiteral("GL_ARB_draw_elements_base_vertex")); + bool haveCopyBuffer = hasGLVersion(3, 1) || hasGLExtension(QStringLiteral("GL_ARB_copy_buffer")); + bool haveMapBufferRange = hasGLVersion(3, 0) || hasGLExtension(QStringLiteral("GL_ARB_map_buffer_range")); + + GLVertexBufferPrivate::hasMapBufferRange = haveMapBufferRange; + GLVertexBufferPrivate::supportsIndexedQuads = haveBaseVertex && haveCopyBuffer && haveMapBufferRange; GLVertexBufferPrivate::s_indexBuffer = nullptr; #endif GLVertexBufferPrivate::streamingBuffer = new GLVertexBuffer(GLVertexBuffer::Stream); diff --git a/libkwineffects/kwinglutils_funcs.cpp b/libkwineffects/kwinglutils_funcs.cpp index 0552a36157..e072953b27 100644 --- a/libkwineffects/kwinglutils_funcs.cpp +++ b/libkwineffects/kwinglutils_funcs.cpp @@ -46,9 +46,6 @@ along with this program. If not, see . function = (function ## _func)getProcAddress( #symbolName ); #endif -#define EGL_RESOLVE( function ) function = (function ## _func)eglGetProcAddress( #function ); - - namespace KWin { @@ -57,160 +54,20 @@ static void ReadnPixels(GLint x, GLint y, GLsizei width, GLsizei height, GLenum GLenum type, GLsizei bufSize, GLvoid *data); static void GetnUniformfv(GLuint program, GLint location, GLsizei bufSize, GLfloat *params); -#ifndef KWIN_HAVE_OPENGLES -// Function pointers -glXGetProcAddress_func glXGetProcAddress; -// GLX 1.3 -glXQueryDrawable_func glXQueryDrawable; -// texture_from_pixmap extension functions -glXReleaseTexImageEXT_func glXReleaseTexImageEXT; -glXBindTexImageEXT_func glXBindTexImageEXT; -// glXCopySubBufferMESA -glXCopySubBuffer_func glXCopySubBuffer; -// video_sync extension functions -glXGetVideoSync_func glXGetVideoSync; -glXWaitVideoSync_func glXWaitVideoSync; +// GL_MESA_swap_control glXSwapIntervalMESA_func glXSwapIntervalMESA; -glXSwapIntervalEXT_func glXSwapIntervalEXT; -glXSwapIntervalSGI_func glXSwapIntervalSGI; -// GLX_ARB_create_context -glXCreateContextAttribsARB_func glXCreateContextAttribsARB; - -// glActiveTexture -glActiveTexture_func glActiveTexture; -// framebuffer_object extension functions -glIsRenderbuffer_func glIsRenderbuffer; -glBindRenderbuffer_func glBindRenderbuffer; -glDeleteRenderbuffers_func glDeleteRenderbuffers; -glGenRenderbuffers_func glGenRenderbuffers; -glRenderbufferStorage_func glRenderbufferStorage; -glGetRenderbufferParameteriv_func glGetRenderbufferParameteriv; -glIsFramebuffer_func glIsFramebuffer; -glBindFramebuffer_func glBindFramebuffer; -glDeleteFramebuffers_func glDeleteFramebuffers; -glGenFramebuffers_func glGenFramebuffers; -glCheckFramebufferStatus_func glCheckFramebufferStatus; -glFramebufferTexture1D_func glFramebufferTexture1D; -glFramebufferTexture2D_func glFramebufferTexture2D; -glFramebufferTexture3D_func glFramebufferTexture3D; -glFramebufferRenderbuffer_func glFramebufferRenderbuffer; -glGetFramebufferAttachmentParameteriv_func glGetFramebufferAttachmentParameteriv; -glGenerateMipmap_func glGenerateMipmap; -glBlitFramebuffer_func glBlitFramebuffer; -// Shader functions -glCreateShader_func glCreateShader; -glShaderSource_func glShaderSource; -glCompileShader_func glCompileShader; -glDeleteShader_func glDeleteShader; -glCreateProgram_func glCreateProgram; -glAttachShader_func glAttachShader; -glLinkProgram_func glLinkProgram; -glUseProgram_func glUseProgram; -glDeleteProgram_func glDeleteProgram; -glGetShaderInfoLog_func glGetShaderInfoLog; -glGetProgramInfoLog_func glGetProgramInfoLog; -glGetProgramiv_func glGetProgramiv; -glGetShaderiv_func glGetShaderiv; -glUniform1f_func glUniform1f; -glUniform2f_func glUniform2f; -glUniform3f_func glUniform3f; -glUniform4f_func glUniform4f; -glUniform1i_func glUniform1i; -glUniform1fv_func glUniform1fv; -glUniform2fv_func glUniform2fv; -glUniform3fv_func glUniform3fv; -glUniform4fv_func glUniform4fv; -glGetUniformfv_func glGetUniformfv; -glUniformMatrix4fv_func glUniformMatrix4fv; -glValidateProgram_func glValidateProgram; -glGetUniformLocation_func glGetUniformLocation; -glVertexAttrib1f_func glVertexAttrib1f; -glGetAttribLocation_func glGetAttribLocation; -glBindAttribLocation_func glBindAttribLocation; -glGenProgramsARB_func glGenProgramsARB; -glBindProgramARB_func glBindProgramARB; -glProgramStringARB_func glProgramStringARB; -glProgramLocalParameter4fARB_func glProgramLocalParameter4fARB; -glDeleteProgramsARB_func glDeleteProgramsARB; -glGetProgramivARB_func glGetProgramivARB; -// vertex buffer objects -glGenBuffers_func glGenBuffers; -glDeleteBuffers_func glDeleteBuffers; -glBindBuffer_func glBindBuffer; -glBufferData_func glBufferData; -glBufferSubData_func glBufferSubData; -glGetBufferSubData_func glGetBufferSubData; -glEnableVertexAttribArray_func glEnableVertexAttribArray; -glDisableVertexAttribArray_func glDisableVertexAttribArray; -glVertexAttribPointer_func glVertexAttribPointer; -glMapBuffer_func glMapBuffer; -glUnmapBuffer_func glUnmapBuffer; - -// GL_ARB_map_buffer_range -glMapBufferRange_func glMapBufferRange; -glFlushMappedBufferRange_func glFlushMappedBufferRange; - -// GL_ARB_vertex_array_object -glBindVertexArray_func glBindVertexArray; -glDeleteVertexArrays_func glDeleteVertexArrays; -glGenVertexArrays_func glGenVertexArrays; -glIsVertexArray_func glIsVertexArray; - - -// GL_EXT_gpu_shader4 -glVertexAttribI1i_func glVertexAttribI1i; -glVertexAttribI2i_func glVertexAttribI2i; -glVertexAttribI3i_func glVertexAttribI3i; -glVertexAttribI4i_func glVertexAttribI4i; -glVertexAttribI1ui_func glVertexAttribI1ui; -glVertexAttribI2ui_func glVertexAttribI2ui; -glVertexAttribI3ui_func glVertexAttribI3ui; -glVertexAttribI4ui_func glVertexAttribI4ui; -glVertexAttribI1iv_func glVertexAttribI1iv; -glVertexAttribI2iv_func glVertexAttribI2iv; -glVertexAttribI3iv_func glVertexAttribI3iv; -glVertexAttribI4iv_func glVertexAttribI4iv; -glVertexAttribI1uiv_func glVertexAttribI1uiv; -glVertexAttribI2uiv_func glVertexAttribI2uiv; -glVertexAttribI3uiv_func glVertexAttribI3uiv; -glVertexAttribI4uiv_func glVertexAttribI4uiv; -glVertexAttribI4bv_func glVertexAttribI4bv; -glVertexAttribI4sv_func glVertexAttribI4sv; -glVertexAttribI4ubv_func glVertexAttribI4ubv; -glVertexAttribI4usv_func glVertexAttribI4usv; -glVertexAttribIPointer_func glVertexAttribIPointer; -glGetVertexAttribIiv_func glGetVertexAttribIiv; -glGetVertexAttribIuiv_func glGetVertexAttribIuiv; -glGetUniformuiv_func glGetUniformuiv; -glBindFragDataLocation_func glBindFragDataLocation; -glGetFragDataLocation_func glGetFragDataLocation; -glUniform1ui_func glUniform1ui; -glUniform2ui_func glUniform2ui; -glUniform3ui_func glUniform3ui; -glUniform4ui_func glUniform4ui; -glUniform1uiv_func glUniform1uiv; -glUniform2uiv_func glUniform2uiv; -glUniform3uiv_func glUniform3uiv; - -// GL_ARB_robustness +// GL_ARB_robustness / GL_EXT_robustness glGetGraphicsResetStatus_func glGetGraphicsResetStatus; glReadnPixels_func glReadnPixels; glGetnUniformfv_func glGetnUniformfv; -// GL_ARB_draw_elements_base_vertex -glDrawElementsBaseVertex_func glDrawElementsBaseVertex; -glDrawElementsInstancedBaseVertex_func glDrawElementsInstancedBaseVertex; - -// GL_ARB_copy_buffer -glCopyBufferSubData_func glCopyBufferSubData; - +typedef void (*glXFuncPtr)(); +#ifndef KWIN_HAVE_OPENGLES static glXFuncPtr getProcAddress(const char* name) { - glXFuncPtr ret = nullptr; - if (glXGetProcAddress != nullptr) - ret = glXGetProcAddress((const GLubyte*) name); + glXFuncPtr ret = glXGetProcAddress((const GLubyte*) name); if (ret == nullptr) ret = (glXFuncPtr) dlsym(RTLD_DEFAULT, name); return ret; @@ -218,482 +75,22 @@ static glXFuncPtr getProcAddress(const char* name) void glxResolveFunctions() { - // handle OpenGL extensions functions - glXGetProcAddress = (glXGetProcAddress_func) getProcAddress("glXGetProcAddress"); - if (glXGetProcAddress == nullptr) - glXGetProcAddress = (glXGetProcAddress_func) getProcAddress("glXGetProcAddressARB"); - glXQueryDrawable = (glXQueryDrawable_func) getProcAddress("glXQueryDrawable"); - if (hasGLExtension(QStringLiteral("GLX_EXT_texture_from_pixmap"))) { - glXBindTexImageEXT = (glXBindTexImageEXT_func) getProcAddress("glXBindTexImageEXT"); - glXReleaseTexImageEXT = (glXReleaseTexImageEXT_func) getProcAddress("glXReleaseTexImageEXT"); - } else { - glXBindTexImageEXT = nullptr; - glXReleaseTexImageEXT = nullptr; - } - if (hasGLExtension(QStringLiteral("GLX_MESA_copy_sub_buffer"))) - glXCopySubBuffer = (glXCopySubBuffer_func) getProcAddress("glXCopySubBufferMESA"); - else - glXCopySubBuffer = nullptr; - if (hasGLExtension(QStringLiteral("GLX_SGI_video_sync"))) { - glXGetVideoSync = (glXGetVideoSync_func) getProcAddress("glXGetVideoSyncSGI"); - glXWaitVideoSync = (glXWaitVideoSync_func) getProcAddress("glXWaitVideoSyncSGI"); - } else { - glXGetVideoSync = nullptr; - glXWaitVideoSync = nullptr; - } - - if (hasGLExtension(QStringLiteral("GLX_SGI_swap_control"))) - glXSwapIntervalSGI = (glXSwapIntervalSGI_func) getProcAddress("glXSwapIntervalSGI"); - else - glXSwapIntervalSGI = nullptr; - if (hasGLExtension(QStringLiteral("GLX_EXT_swap_control"))) - glXSwapIntervalEXT = (glXSwapIntervalEXT_func) getProcAddress("glXSwapIntervalEXT"); - else - glXSwapIntervalEXT = nullptr; if (hasGLExtension(QStringLiteral("GLX_MESA_swap_control"))) glXSwapIntervalMESA = (glXSwapIntervalMESA_func) getProcAddress("glXSwapIntervalMESA"); else glXSwapIntervalMESA = nullptr; - - if (hasGLExtension(QStringLiteral("GLX_ARB_create_context"))) - glXCreateContextAttribsARB = (glXCreateContextAttribsARB_func) getProcAddress("glXCreateContextAttribsARB"); - else - glXCreateContextAttribsARB = nullptr; } - -#else - -// GL_OES_mapbuffer -glMapBuffer_func glMapBuffer; -glUnmapBuffer_func glUnmapBuffer; -glGetBufferPointerv_func glGetBufferPointerv; - -// GL_OES_texture_3D -glTexImage3DOES_func glTexImage3D; - -// GL_EXT_map_buffer_range -glMapBufferRange_func glMapBufferRange; -glFlushMappedBufferRange_func glFlushMappedBufferRange; - -#endif // KWIN_HAVE_OPENGLES - -#ifdef KWIN_HAVE_EGL - -// EGL -eglCreateImageKHR_func eglCreateImageKHR; -eglDestroyImageKHR_func eglDestroyImageKHR; -eglPostSubBufferNV_func eglPostSubBufferNV; -// GLES -glEGLImageTargetTexture2DOES_func glEGLImageTargetTexture2DOES; - -#ifdef KWIN_HAVE_OPENGLES -// GL_EXT_robustness -glGetGraphicsResetStatus_func glGetGraphicsResetStatus; -glReadnPixels_func glReadnPixels; -glGetnUniformfv_func glGetnUniformfv; #endif +#ifdef KWIN_HAVE_EGL void eglResolveFunctions() { - if (hasGLExtension(QStringLiteral("EGL_KHR_image")) || - (hasGLExtension(QStringLiteral("EGL_KHR_image_base")) && - hasGLExtension(QStringLiteral("EGL_KHR_image_pixmap")))) { - eglCreateImageKHR = (eglCreateImageKHR_func)eglGetProcAddress("eglCreateImageKHR"); - eglDestroyImageKHR = (eglDestroyImageKHR_func)eglGetProcAddress("eglDestroyImageKHR"); - } else { - eglCreateImageKHR = nullptr; - eglDestroyImageKHR = nullptr; - } - - if (hasGLExtension(QStringLiteral("EGL_NV_post_sub_buffer"))) { - eglPostSubBufferNV = (eglPostSubBufferNV_func)eglGetProcAddress("eglPostSubBufferNV"); - } else { - eglPostSubBufferNV = nullptr; - } } #endif void glResolveFunctions(OpenGLPlatformInterface platformInterface) { #ifndef KWIN_HAVE_OPENGLES - if (hasGLVersion(1, 3)) { - GL_RESOLVE(glActiveTexture); - // Get number of texture units - glGetIntegerv(GL_MAX_TEXTURE_UNITS, &glTextureUnitsCount); - } else if (hasGLExtension(QStringLiteral("GL_ARB_multitexture"))) { - GL_RESOLVE_WITH_EXT(glActiveTexture, glActiveTextureARB); - // Get number of texture units - glGetIntegerv(GL_MAX_TEXTURE_UNITS, &glTextureUnitsCount); - } else { - glActiveTexture = nullptr; - glTextureUnitsCount = 0; - } - - if (hasGLVersion(3, 0) || hasGLExtension(QStringLiteral("GL_ARB_framebuffer_object"))) { - // see http://www.opengl.org/registry/specs/ARB/framebuffer_object.txt - GL_RESOLVE(glIsRenderbuffer); - GL_RESOLVE(glBindRenderbuffer); - GL_RESOLVE(glDeleteRenderbuffers); - GL_RESOLVE(glGenRenderbuffers); - - GL_RESOLVE(glRenderbufferStorage); - - GL_RESOLVE(glGetRenderbufferParameteriv); - - GL_RESOLVE(glIsFramebuffer); - GL_RESOLVE(glBindFramebuffer); - GL_RESOLVE(glDeleteFramebuffers); - GL_RESOLVE(glGenFramebuffers); - - GL_RESOLVE(glCheckFramebufferStatus); - - GL_RESOLVE(glFramebufferTexture1D); - GL_RESOLVE(glFramebufferTexture2D); - GL_RESOLVE(glFramebufferTexture3D); - - GL_RESOLVE(glFramebufferRenderbuffer); - - GL_RESOLVE(glGetFramebufferAttachmentParameteriv); - - GL_RESOLVE(glGenerateMipmap); - } else if (hasGLExtension(QStringLiteral("GL_EXT_framebuffer_object"))) { - // see http://www.opengl.org/registry/specs/EXT/framebuffer_object.txt - GL_RESOLVE_WITH_EXT(glIsRenderbuffer, glIsRenderbufferEXT); - GL_RESOLVE_WITH_EXT(glBindRenderbuffer, glBindRenderbufferEXT); - GL_RESOLVE_WITH_EXT(glDeleteRenderbuffers, glDeleteRenderbuffersEXT); - GL_RESOLVE_WITH_EXT(glGenRenderbuffers, glGenRenderbuffersEXT); - - GL_RESOLVE_WITH_EXT(glRenderbufferStorage, glRenderbufferStorageEXT); - - GL_RESOLVE_WITH_EXT(glGetRenderbufferParameteriv, glGetRenderbufferParameterivEXT); - - GL_RESOLVE_WITH_EXT(glIsFramebuffer, glIsFramebufferEXT); - GL_RESOLVE_WITH_EXT(glBindFramebuffer, glBindFramebufferEXT); - GL_RESOLVE_WITH_EXT(glDeleteFramebuffers, glDeleteFramebuffersEXT); - GL_RESOLVE_WITH_EXT(glGenFramebuffers, glGenFramebuffersEXT); - - GL_RESOLVE_WITH_EXT(glCheckFramebufferStatus, glCheckFramebufferStatusEXT); - - GL_RESOLVE_WITH_EXT(glFramebufferTexture1D, glFramebufferTexture1DEXT); - GL_RESOLVE_WITH_EXT(glFramebufferTexture2D, glFramebufferTexture2DEXT); - GL_RESOLVE_WITH_EXT(glFramebufferTexture3D, glFramebufferTexture3DEXT); - - GL_RESOLVE_WITH_EXT(glFramebufferRenderbuffer, glFramebufferRenderbufferEXT); - - GL_RESOLVE_WITH_EXT(glGetFramebufferAttachmentParameteriv, glGetFramebufferAttachmentParameterivEXT); - - GL_RESOLVE_WITH_EXT(glGenerateMipmap, glGenerateMipmapEXT); - } else { - glIsRenderbuffer = nullptr; - glBindRenderbuffer = nullptr; - glDeleteRenderbuffers = nullptr; - glGenRenderbuffers = nullptr; - glRenderbufferStorage = nullptr; - glGetRenderbufferParameteriv = nullptr; - glIsFramebuffer = nullptr; - glBindFramebuffer = nullptr; - glDeleteFramebuffers = nullptr; - glGenFramebuffers = nullptr; - glCheckFramebufferStatus = nullptr; - glFramebufferTexture1D = nullptr; - glFramebufferTexture2D = nullptr; - glFramebufferTexture3D = nullptr; - glFramebufferRenderbuffer = nullptr; - glGetFramebufferAttachmentParameteriv = nullptr; - glGenerateMipmap = nullptr; - } - - if (hasGLVersion(3, 0) || hasGLExtension(QStringLiteral("GL_ARB_framebuffer_object"))) { - // see http://www.opengl.org/registry/specs/ARB/framebuffer_object.txt - GL_RESOLVE(glBlitFramebuffer); - } else if (hasGLExtension(QStringLiteral("GL_EXT_framebuffer_blit"))) { - // see http://www.opengl.org/registry/specs/EXT/framebuffer_blit.txt - GL_RESOLVE_WITH_EXT(glBlitFramebuffer, glBlitFramebufferEXT); - } else { - glBlitFramebuffer = nullptr; - } - - if (hasGLVersion(2, 0)) { - // see http://www.opengl.org/registry/specs/ARB/shader_objects.txt - GL_RESOLVE(glCreateShader); - GL_RESOLVE(glShaderSource); - GL_RESOLVE(glCompileShader); - GL_RESOLVE(glDeleteShader); - GL_RESOLVE(glCreateProgram); - GL_RESOLVE(glAttachShader); - GL_RESOLVE(glLinkProgram); - GL_RESOLVE(glUseProgram); - GL_RESOLVE(glDeleteProgram); - GL_RESOLVE(glGetShaderInfoLog); - GL_RESOLVE(glGetProgramInfoLog); - GL_RESOLVE(glGetProgramiv); - GL_RESOLVE(glGetShaderiv); - GL_RESOLVE(glUniform1f); - GL_RESOLVE(glUniform2f); - GL_RESOLVE(glUniform3f); - GL_RESOLVE(glUniform4f); - GL_RESOLVE(glUniform1i); - GL_RESOLVE(glUniform1fv); - GL_RESOLVE(glUniform2fv); - GL_RESOLVE(glUniform3fv); - GL_RESOLVE(glUniform4fv); - GL_RESOLVE(glUniformMatrix4fv); - GL_RESOLVE(glValidateProgram); - GL_RESOLVE(glGetUniformLocation); - GL_RESOLVE(glGetUniformfv); - } else if (hasGLExtension(QStringLiteral("GL_ARB_shader_objects"))) { - GL_RESOLVE_WITH_EXT(glCreateShader, glCreateShaderObjectARB); - GL_RESOLVE_WITH_EXT(glShaderSource, glShaderSourceARB); - GL_RESOLVE_WITH_EXT(glCompileShader, glCompileShaderARB); - GL_RESOLVE_WITH_EXT(glDeleteShader, glDeleteObjectARB); - GL_RESOLVE_WITH_EXT(glCreateProgram, glCreateProgramObjectARB); - GL_RESOLVE_WITH_EXT(glAttachShader, glAttachObjectARB); - GL_RESOLVE_WITH_EXT(glLinkProgram, glLinkProgramARB); - GL_RESOLVE_WITH_EXT(glUseProgram, glUseProgramObjectARB); - GL_RESOLVE_WITH_EXT(glDeleteProgram, glDeleteObjectARB); - GL_RESOLVE_WITH_EXT(glGetShaderInfoLog, glGetInfoLogARB); - GL_RESOLVE_WITH_EXT(glGetProgramInfoLog, glGetInfoLogARB); - GL_RESOLVE_WITH_EXT(glGetProgramiv, glGetObjectParameterivARB); - GL_RESOLVE_WITH_EXT(glGetShaderiv, glGetObjectParameterivARB); - GL_RESOLVE_WITH_EXT(glUniform1f, glUniform1fARB); - GL_RESOLVE_WITH_EXT(glUniform2f, glUniform2fARB); - GL_RESOLVE_WITH_EXT(glUniform3f, glUniform3fARB); - GL_RESOLVE_WITH_EXT(glUniform4f, glUniform4fARB); - GL_RESOLVE_WITH_EXT(glUniform1i, glUniform1iARB); - GL_RESOLVE_WITH_EXT(glUniform1fv, glUniform1fvARB); - GL_RESOLVE_WITH_EXT(glUniform2fv, glUniform2fvARB); - GL_RESOLVE_WITH_EXT(glUniform3fv, glUniform3fvARB); - GL_RESOLVE_WITH_EXT(glUniform4fv, glUniform4fvARB); - GL_RESOLVE_WITH_EXT(glUniformMatrix4fv, glUniformMatrix4fvARB); - GL_RESOLVE_WITH_EXT(glValidateProgram, glValidateProgramARB); - GL_RESOLVE_WITH_EXT(glGetUniformLocation, glGetUniformLocationARB); - GL_RESOLVE_WITH_EXT(glGetUniformfv, glGetUniformfvARB); - } else { - glCreateShader = nullptr; - glShaderSource = nullptr; - glCompileShader = nullptr; - glDeleteShader = nullptr; - glCreateProgram = nullptr; - glAttachShader = nullptr; - glLinkProgram = nullptr; - glUseProgram = nullptr; - glDeleteProgram = nullptr; - glGetShaderInfoLog = nullptr; - glGetProgramInfoLog = nullptr; - glGetProgramiv = nullptr; - glGetShaderiv = nullptr; - glUniform1f = nullptr; - glUniform2f = nullptr; - glUniform3f = nullptr; - glUniform4f = nullptr; - glUniform1i = nullptr; - glUniform1fv = nullptr; - glUniform2fv = nullptr; - glUniform3fv = nullptr; - glUniform4fv = nullptr; - glUniformMatrix4fv = nullptr; - glValidateProgram = nullptr; - glGetUniformLocation = nullptr; - glGetUniformfv = nullptr; - } - - if (hasGLVersion(2, 0)) { - // see http://www.opengl.org/registry/specs/ARB/vertex_shader.txt - GL_RESOLVE(glVertexAttrib1f); - GL_RESOLVE(glBindAttribLocation); - GL_RESOLVE(glGetAttribLocation); - GL_RESOLVE(glEnableVertexAttribArray); - GL_RESOLVE(glDisableVertexAttribArray); - GL_RESOLVE(glVertexAttribPointer); - } else if (hasGLExtension(QStringLiteral("GL_ARB_vertex_shader"))) { - GL_RESOLVE_WITH_EXT(glVertexAttrib1f, glVertexAttrib1fARB); - GL_RESOLVE_WITH_EXT(glBindAttribLocation, glBindAttribLocationARB); - GL_RESOLVE_WITH_EXT(glGetAttribLocation, glGetAttribLocationARB); - GL_RESOLVE_WITH_EXT(glEnableVertexAttribArray, glEnableVertexAttribArrayARB); - GL_RESOLVE_WITH_EXT(glDisableVertexAttribArray, glDisableVertexAttribArrayARB); - GL_RESOLVE_WITH_EXT(glVertexAttribPointer, glVertexAttribPointerARB); - } else { - glVertexAttrib1f = nullptr; - glBindAttribLocation = nullptr; - glGetAttribLocation = nullptr; - glEnableVertexAttribArray = nullptr; - glDisableVertexAttribArray = nullptr; - glVertexAttribPointer = nullptr; - } - - if (hasGLExtension(QStringLiteral("GL_ARB_fragment_program")) && hasGLExtension(QStringLiteral("GL_ARB_vertex_program"))) { - // see http://www.opengl.org/registry/specs/ARB/fragment_program.txt - GL_RESOLVE(glProgramStringARB); - GL_RESOLVE(glBindProgramARB); - GL_RESOLVE(glDeleteProgramsARB); - GL_RESOLVE(glGenProgramsARB); - GL_RESOLVE(glProgramLocalParameter4fARB); - GL_RESOLVE(glGetProgramivARB); - } else { - glProgramStringARB = nullptr; - glBindProgramARB = nullptr; - glDeleteProgramsARB = nullptr; - glGenProgramsARB = nullptr; - glProgramLocalParameter4fARB = nullptr; - glGetProgramivARB = nullptr; - } - - if (hasGLVersion(1, 5)) { - // see http://www.opengl.org/registry/specs/ARB/vertex_buffer_object.txt - GL_RESOLVE(glGenBuffers); - GL_RESOLVE(glDeleteBuffers); - GL_RESOLVE(glBindBuffer); - GL_RESOLVE(glBufferData); - GL_RESOLVE(glBufferSubData); - GL_RESOLVE(glMapBuffer); - GL_RESOLVE(glUnmapBuffer); - } else if (hasGLExtension(QStringLiteral("GL_ARB_vertex_buffer_object"))) { - GL_RESOLVE_WITH_EXT(glGenBuffers, glGenBuffersARB); - GL_RESOLVE_WITH_EXT(glDeleteBuffers, glDeleteBuffersARB); - GL_RESOLVE_WITH_EXT(glBindBuffer, glBindBufferARB); - GL_RESOLVE_WITH_EXT(glBufferData, glBufferDataARB); - GL_RESOLVE_WITH_EXT(glBufferSubData, glBufferSubDataARB); - GL_RESOLVE_WITH_EXT(glGetBufferSubData, glGetBufferSubDataARB); - GL_RESOLVE_WITH_EXT(glMapBuffer, glMapBufferARB); - GL_RESOLVE_WITH_EXT(glUnmapBuffer, glUnmapBufferARB); - } else { - glGenBuffers = nullptr; - glDeleteBuffers = nullptr; - glBindBuffer = nullptr; - glBufferData = nullptr; - glBufferSubData = nullptr; - glGetBufferSubData = nullptr; - glMapBuffer = nullptr; - glUnmapBuffer = nullptr; - } - - if (hasGLVersion(3, 0) || hasGLExtension(QStringLiteral("GL_ARB_vertex_array_object"))) { - // see http://www.opengl.org/registry/specs/ARB/vertex_array_object.txt - GL_RESOLVE(glBindVertexArray); - GL_RESOLVE(glDeleteVertexArrays); - GL_RESOLVE(glGenVertexArrays); - GL_RESOLVE(glIsVertexArray); - } else { - glBindVertexArray = nullptr; - glDeleteVertexArrays = nullptr; - glGenVertexArrays = nullptr; - glIsVertexArray = nullptr; - } - - if (hasGLVersion(3, 0)) { - GL_RESOLVE(glVertexAttribI1i); - GL_RESOLVE(glVertexAttribI2i); - GL_RESOLVE(glVertexAttribI3i); - GL_RESOLVE(glVertexAttribI4i); - GL_RESOLVE(glVertexAttribI1ui); - GL_RESOLVE(glVertexAttribI2ui); - GL_RESOLVE(glVertexAttribI3ui); - GL_RESOLVE(glVertexAttribI4ui); - GL_RESOLVE(glVertexAttribI1iv); - GL_RESOLVE(glVertexAttribI2iv); - GL_RESOLVE(glVertexAttribI3iv); - GL_RESOLVE(glVertexAttribI4iv); - GL_RESOLVE(glVertexAttribI1uiv); - GL_RESOLVE(glVertexAttribI2uiv); - GL_RESOLVE(glVertexAttribI3uiv); - GL_RESOLVE(glVertexAttribI4uiv); - GL_RESOLVE(glVertexAttribI4bv); - GL_RESOLVE(glVertexAttribI4sv); - GL_RESOLVE(glVertexAttribI4ubv); - GL_RESOLVE(glVertexAttribI4usv); - GL_RESOLVE(glVertexAttribIPointer); - GL_RESOLVE(glGetVertexAttribIiv); - GL_RESOLVE(glGetVertexAttribIuiv); - GL_RESOLVE(glGetUniformuiv); - GL_RESOLVE(glBindFragDataLocation); - GL_RESOLVE(glGetFragDataLocation); - GL_RESOLVE(glUniform1ui); - GL_RESOLVE(glUniform2ui); - GL_RESOLVE(glUniform3ui); - GL_RESOLVE(glUniform4ui); - GL_RESOLVE(glUniform1uiv); - GL_RESOLVE(glUniform2uiv); - GL_RESOLVE(glUniform3uiv); - } else if (hasGLExtension(QStringLiteral("GL_EXT_gpu_shader4"))) { - // See http://www.opengl.org/registry/specs/EXT/gpu_shader4.txt - GL_RESOLVE_WITH_EXT(glVertexAttribI1i, glVertexAttribI1iEXT); - GL_RESOLVE_WITH_EXT(glVertexAttribI2i, glVertexAttribI2iEXT); - GL_RESOLVE_WITH_EXT(glVertexAttribI3i, glVertexAttribI3iEXT); - GL_RESOLVE_WITH_EXT(glVertexAttribI4i, glVertexAttribI4iEXT); - GL_RESOLVE_WITH_EXT(glVertexAttribI1ui, glVertexAttribI1uiEXT); - GL_RESOLVE_WITH_EXT(glVertexAttribI2ui, glVertexAttribI2uiEXT); - GL_RESOLVE_WITH_EXT(glVertexAttribI3ui, glVertexAttribI3uiEXT); - GL_RESOLVE_WITH_EXT(glVertexAttribI4ui, glVertexAttribI4uiEXT); - GL_RESOLVE_WITH_EXT(glVertexAttribI1iv, glVertexAttribI1ivEXT); - GL_RESOLVE_WITH_EXT(glVertexAttribI2iv, glVertexAttribI2ivEXT); - GL_RESOLVE_WITH_EXT(glVertexAttribI3iv, glVertexAttribI3ivEXT); - GL_RESOLVE_WITH_EXT(glVertexAttribI4iv, glVertexAttribI4ivEXT); - GL_RESOLVE_WITH_EXT(glVertexAttribI1uiv, glVertexAttribI1uivEXT); - GL_RESOLVE_WITH_EXT(glVertexAttribI2uiv, glVertexAttribI2uivEXT); - GL_RESOLVE_WITH_EXT(glVertexAttribI3uiv, glVertexAttribI3uivEXT); - GL_RESOLVE_WITH_EXT(glVertexAttribI4uiv, glVertexAttribI4uivEXT); - GL_RESOLVE_WITH_EXT(glVertexAttribI4bv, glVertexAttribI4bvEXT); - GL_RESOLVE_WITH_EXT(glVertexAttribI4sv, glVertexAttribI4svEXT); - GL_RESOLVE_WITH_EXT(glVertexAttribI4ubv, glVertexAttribI4ubvEXT); - GL_RESOLVE_WITH_EXT(glVertexAttribI4usv, glVertexAttribI4usvEXT); - GL_RESOLVE_WITH_EXT(glVertexAttribIPointer, glVertexAttribIPointerEXT); - GL_RESOLVE_WITH_EXT(glGetVertexAttribIiv, glGetVertexAttribIivEXT); - GL_RESOLVE_WITH_EXT(glGetVertexAttribIuiv, glGetVertexAttribIuivEXT); - GL_RESOLVE_WITH_EXT(glGetUniformuiv, glGetUniformuivEXT); - GL_RESOLVE_WITH_EXT(glBindFragDataLocation, glBindFragDataLocationEXT); - GL_RESOLVE_WITH_EXT(glGetFragDataLocation, glGetFragDataLocationEXT); - GL_RESOLVE_WITH_EXT(glUniform1ui, glUniform1uiEXT); - GL_RESOLVE_WITH_EXT(glUniform2ui, glUniform2uiEXT); - GL_RESOLVE_WITH_EXT(glUniform3ui, glUniform3uiEXT); - GL_RESOLVE_WITH_EXT(glUniform4ui, glUniform4uiEXT); - GL_RESOLVE_WITH_EXT(glUniform1uiv, glUniform1uivEXT); - GL_RESOLVE_WITH_EXT(glUniform2uiv, glUniform2uivEXT); - GL_RESOLVE_WITH_EXT(glUniform3uiv, glUniform3uivEXT); - } else { - glVertexAttribI1i = nullptr; - glVertexAttribI2i = nullptr; - glVertexAttribI3i = nullptr; - glVertexAttribI4i = nullptr; - glVertexAttribI1ui = nullptr; - glVertexAttribI2ui = nullptr; - glVertexAttribI3ui = nullptr; - glVertexAttribI4ui = nullptr; - glVertexAttribI1iv = nullptr; - glVertexAttribI2iv = nullptr; - glVertexAttribI3iv = nullptr; - glVertexAttribI4iv = nullptr; - glVertexAttribI1uiv = nullptr; - glVertexAttribI2uiv = nullptr; - glVertexAttribI3uiv = nullptr; - glVertexAttribI4uiv = nullptr; - glVertexAttribI4bv = nullptr; - glVertexAttribI4sv = nullptr; - glVertexAttribI4ubv = nullptr; - glVertexAttribI4usv = nullptr; - glVertexAttribIPointer = nullptr; - glGetVertexAttribIiv = nullptr; - glGetVertexAttribIuiv = nullptr; - glGetUniformuiv = nullptr; - glBindFragDataLocation = nullptr; - glGetFragDataLocation = nullptr; - glUniform1ui = nullptr; - glUniform2ui = nullptr; - glUniform3ui = nullptr; - glUniform4ui = nullptr; - glUniform1uiv = nullptr; - glUniform2uiv = nullptr; - glUniform3uiv = nullptr; - } - - if (hasGLVersion(3, 0) || hasGLExtension(QStringLiteral("GL_ARB_map_buffer_range"))) { - // See http://www.opengl.org/registry/specs/ARB/map_buffer_range.txt - GL_RESOLVE(glMapBufferRange); - GL_RESOLVE(glFlushMappedBufferRange); - } else { - glMapBufferRange = nullptr; - glFlushMappedBufferRange = nullptr; - } - if (hasGLExtension(QStringLiteral("GL_ARB_robustness"))) { // See http://www.opengl.org/registry/specs/ARB/robustness.txt GL_RESOLVE_WITH_EXT(glGetGraphicsResetStatus, glGetGraphicsResetStatusARB); @@ -704,51 +101,7 @@ void glResolveFunctions(OpenGLPlatformInterface platformInterface) glReadnPixels = KWin::ReadnPixels; glGetnUniformfv = KWin::GetnUniformfv; } - - if (hasGLVersion(3, 2) || hasGLExtension(QStringLiteral("GL_ARB_draw_elements_base_vertex"))) { - // See http://www.opengl.org/registry/specs/ARB/draw_elements_base_vertex.txt - GL_RESOLVE(glDrawElementsBaseVertex); - GL_RESOLVE(glDrawElementsInstancedBaseVertex); - } else { - glDrawElementsBaseVertex = nullptr; - glDrawElementsInstancedBaseVertex = nullptr; - } - - if (hasGLVersion(3, 1) || hasGLExtension(QStringLiteral("GL_ARB_copy_buffer"))) { - // See http://www.opengl.org/registry/specs/ARB/copy_buffer.txt - GL_RESOLVE(glCopyBufferSubData); - } else { - glCopyBufferSubData = nullptr; - } - #else - - if (hasGLExtension(QStringLiteral("GL_OES_mapbuffer"))) { - // See http://www.khronos.org/registry/gles/extensions/OES/OES_mapbuffer.txt - glMapBuffer = (glMapBuffer_func) eglGetProcAddress("glMapBufferOES"); - glUnmapBuffer = (glUnmapBuffer_func) eglGetProcAddress("glUnmapBufferOES"); - glGetBufferPointerv = (glGetBufferPointerv_func) eglGetProcAddress("glGetBufferPointervOES"); - } else { - glMapBuffer = nullptr; - glUnmapBuffer = nullptr; - glGetBufferPointerv = nullptr; - } - - if (hasGLExtension(QStringLiteral("GL_OES_texture_3D"))) { - glTexImage3D = (glTexImage3DOES_func)eglGetProcAddress("glTexImage3DOES"); - } else { - glTexImage3D = nullptr; - } - - if (hasGLExtension(QStringLiteral("GL_EXT_map_buffer_range"))) { - // See http://www.khronos.org/registry/gles/extensions/EXT/EXT_map_buffer_range.txt - glMapBufferRange = (glMapBufferRange_func) eglGetProcAddress("glMapBufferRangeEXT"); - glFlushMappedBufferRange = (glFlushMappedBufferRange_func) eglGetProcAddress("glFlushMappedBufferRangeEXT"); - } else { - glMapBufferRange = nullptr; - glFlushMappedBufferRange = nullptr; - } - if (hasGLExtension(QStringLiteral("GL_EXT_robustness"))) { // See http://www.khronos.org/registry/gles/extensions/EXT/EXT_robustness.txt glGetGraphicsResetStatus = (glGetGraphicsResetStatus_func) eglGetProcAddress("glGetGraphicsResetStatusEXT"); @@ -759,18 +112,7 @@ void glResolveFunctions(OpenGLPlatformInterface platformInterface) glReadnPixels = KWin::ReadnPixels; glGetnUniformfv = KWin::GetnUniformfv; } - #endif // KWIN_HAVE_OPENGLES - -#ifdef KWIN_HAVE_EGL - if (platformInterface == EglPlatformInterface) { - if (hasGLExtension(QStringLiteral("GL_OES_EGL_image"))) { - glEGLImageTargetTexture2DOES = (glEGLImageTargetTexture2DOES_func)eglGetProcAddress("glEGLImageTargetTexture2DOES"); - } else { - glEGLImageTargetTexture2DOES = nullptr; - } - } -#endif } static GLenum GetGraphicsResetStatus() diff --git a/libkwineffects/kwinglutils_funcs.h b/libkwineffects/kwinglutils_funcs.h index 6540a79998..549ae1c99a 100644 --- a/libkwineffects/kwinglutils_funcs.h +++ b/libkwineffects/kwinglutils_funcs.h @@ -25,582 +25,47 @@ along with this program. If not, see . #include #include -// common functionality -namespace KWin { +#ifdef KWIN_HAVE_EGL +#include +#endif -void KWINGLUTILS_EXPORT glResolveFunctions(OpenGLPlatformInterface platformInterface); +#ifndef KWIN_HAVE_OPENGLES +#include +#endif -} +#include + +#include #define GL_QUADS_KWIN 0x0007 -#ifndef KWIN_HAVE_OPENGLES - -#include -#include - -#ifndef GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT -#define GL_FRAMEBUFFER_INCOMPLETE_MULTISAMPLE_EXT 0x8D56 -#endif - -#ifndef GL_FRAMEBUFFER -#define GL_FRAMEBUFFER GL_FRAMEBUFFER_EXT -#endif - -#ifndef GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT -#endif - -#ifndef GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT -#endif - -#ifndef GL_FRAMEBUFFER_UNSUPPORTED -#define GL_FRAMEBUFFER_UNSUPPORTED GL_FRAMEBUFFER_UNSUPPORTED_EXT -#endif - -#ifndef GL_COLOR_ATTACHMENT0 -#define GL_COLOR_ATTACHMENT0 GL_COLOR_ATTACHMENT0_EXT -#endif - -#ifndef GL_FRAMEBUFFER_COMPLETE -#define GL_FRAMEBUFFER_COMPLETE GL_FRAMEBUFFER_COMPLETE_EXT -#endif - -#ifndef GL_DRAW_FRAMEBUFFER -#define GL_DRAW_FRAMEBUFFER 0x8CA9 -#endif - -#ifndef GL_READ_FRAMEBUFFER -#define GL_READ_FRAMEBUFFER 0x8CA8 -#endif - -#ifndef GLX_BACK_BUFFER_AGE_EXT -#define GLX_BACK_BUFFER_AGE_EXT 0x20F4 -#endif - -#include - namespace KWin { +#ifndef KWIN_HAVE_OPENGLES void KWINGLUTILS_EXPORT glxResolveFunctions(); - - -// Defines -/* -** GLX_EXT_texture_from_pixmap -*/ -#define GLX_BIND_TO_TEXTURE_RGB_EXT 0x20D0 -#define GLX_BIND_TO_TEXTURE_RGBA_EXT 0x20D1 -#define GLX_BIND_TO_MIPMAP_TEXTURE_EXT 0x20D2 -#define GLX_BIND_TO_TEXTURE_TARGETS_EXT 0x20D3 -#define GLX_Y_INVERTED_EXT 0x20D4 - -#define GLX_TEXTURE_FORMAT_EXT 0x20D5 -#define GLX_TEXTURE_TARGET_EXT 0x20D6 -#define GLX_MIPMAP_TEXTURE_EXT 0x20D7 - -#define GLX_TEXTURE_FORMAT_NONE_EXT 0x20D8 -#define GLX_TEXTURE_FORMAT_RGB_EXT 0x20D9 -#define GLX_TEXTURE_FORMAT_RGBA_EXT 0x20DA - -#define GLX_TEXTURE_1D_BIT_EXT 0x00000001 -#define GLX_TEXTURE_2D_BIT_EXT 0x00000002 -#define GLX_TEXTURE_RECTANGLE_BIT_EXT 0x00000004 - -#define GLX_TEXTURE_1D_EXT 0x20DB -#define GLX_TEXTURE_2D_EXT 0x20DC -#define GLX_TEXTURE_RECTANGLE_EXT 0x20DD - -#define GLX_FRONT_LEFT_EXT 0x20DE - -// Shader stuff -#define GL_COMPILE_STATUS 0x8B81 -#define GL_LINK_STATUS 0x8B82 -#define GL_INFO_LOG_LENGTH 0x8B84 -#define GL_FRAGMENT_SHADER 0x8B30 -#define GL_VERTEX_SHADER 0x8B31 - -// FBO -#define GL_FRAMEBUFFER_EXT 0x8D40 -#define GL_RENDERBUFFER_EXT 0x8D41 -#define GL_STENCIL_INDEX1_EXT 0x8D46 -#define GL_STENCIL_INDEX4_EXT 0x8D47 -#define GL_STENCIL_INDEX8_EXT 0x8D48 -#define GL_STENCIL_INDEX16_EXT 0x8D49 -#define GL_RENDERBUFFER_WIDTH_EXT 0x8D42 -#define GL_RENDERBUFFER_HEIGHT_EXT 0x8D43 -#define GL_RENDERBUFFER_INTERNAL_FORMAT_EXT 0x8D44 -#define GL_RENDERBUFFER_RED_SIZE_EXT 0x8D50 -#define GL_RENDERBUFFER_GREEN_SIZE_EXT 0x8D51 -#define GL_RENDERBUFFER_BLUE_SIZE_EXT 0x8D52 -#define GL_RENDERBUFFER_ALPHA_SIZE_EXT 0x8D53 -#define GL_RENDERBUFFER_DEPTH_SIZE_EXT 0x8D54 -#define GL_RENDERBUFFER_STENCIL_SIZE_EXT 0x8D55 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_TYPE_EXT 0x8CD0 -#define GL_FRAMEBUFFER_ATTACHMENT_OBJECT_NAME_EXT 0x8CD1 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_LEVEL_EXT 0x8CD2 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_CUBE_MAP_FACE_EXT 0x8CD3 -#define GL_FRAMEBUFFER_ATTACHMENT_TEXTURE_3D_ZOFFSET_EXT 0x8CD4 -#define GL_COLOR_ATTACHMENT0_EXT 0x8CE0 -#define GL_COLOR_ATTACHMENT1_EXT 0x8CE1 -#define GL_COLOR_ATTACHMENT2_EXT 0x8CE2 -#define GL_COLOR_ATTACHMENT3_EXT 0x8CE3 -#define GL_COLOR_ATTACHMENT4_EXT 0x8CE4 -#define GL_COLOR_ATTACHMENT5_EXT 0x8CE5 -#define GL_COLOR_ATTACHMENT6_EXT 0x8CE6 -#define GL_COLOR_ATTACHMENT7_EXT 0x8CE7 -#define GL_COLOR_ATTACHMENT8_EXT 0x8CE8 -#define GL_COLOR_ATTACHMENT9_EXT 0x8CE9 -#define GL_COLOR_ATTACHMENT10_EXT 0x8CEA -#define GL_COLOR_ATTACHMENT11_EXT 0x8CEB -#define GL_COLOR_ATTACHMENT12_EXT 0x8CEC -#define GL_COLOR_ATTACHMENT13_EXT 0x8CED -#define GL_COLOR_ATTACHMENT14_EXT 0x8CEE -#define GL_COLOR_ATTACHMENT15_EXT 0x8CEF -#define GL_DEPTH_ATTACHMENT_EXT 0x8D00 -#define GL_STENCIL_ATTACHMENT_EXT 0x8D20 -#define GL_FRAMEBUFFER_COMPLETE_EXT 0x8CD5 -#define GL_FRAMEBUFFER_INCOMPLETE_ATTACHMENT_EXT 0x8CD6 -#define GL_FRAMEBUFFER_INCOMPLETE_MISSING_ATTACHMENT_EXT 0x8CD7 -#define GL_FRAMEBUFFER_INCOMPLETE_DIMENSIONS_EXT 0x8CD9 -#define GL_FRAMEBUFFER_INCOMPLETE_FORMATS_EXT 0x8CDA -#define GL_FRAMEBUFFER_INCOMPLETE_DRAW_BUFFER_EXT 0x8CDB -#define GL_FRAMEBUFFER_INCOMPLETE_READ_BUFFER_EXT 0x8CDC -#define GL_FRAMEBUFFER_UNSUPPORTED_EXT 0x8CDD -#define GL_FRAMEBUFFER_BINDING_EXT 0x8CA6 -#define GL_RENDERBUFFER_BINDING_EXT 0x8CA7 -#define GL_MAX_COLOR_ATTACHMENTS_EXT 0x8CDF -#define GL_MAX_RENDERBUFFER_SIZE_EXT 0x84E8 -#define GL_INVALID_FRAMEBUFFER_OPERATION_EXT 0x0506 - - -#define GL_TEXTURE_RECTANGLE_ARB 0x84F5 - - -// GLX typedefs -typedef struct __GLXcontextRec *GLXContext; -/* GLX 1.3 and later */ -typedef struct __GLXFBConfigRec *GLXFBConfig; - -// GL typedefs -typedef char GLchar; - -// Function pointers -// finding of OpenGL extensions functions -typedef void (*glXFuncPtr)(); -typedef glXFuncPtr(*glXGetProcAddress_func)(const GLubyte*); -extern KWINGLUTILS_EXPORT glXGetProcAddress_func glXGetProcAddress; -// glXQueryDrawable (added in GLX 1.3) -typedef void (*glXQueryDrawable_func)(Display* dpy, GLXDrawable drawable, - int attribute, unsigned int *value); -extern KWINGLUTILS_EXPORT glXQueryDrawable_func glXQueryDrawable; -// texture_from_pixmap extension functions -typedef void (*glXBindTexImageEXT_func)(Display* dpy, GLXDrawable drawable, - int buffer, const int* attrib_list); -typedef void (*glXReleaseTexImageEXT_func)(Display* dpy, GLXDrawable drawable, int buffer); -extern KWINGLUTILS_EXPORT glXReleaseTexImageEXT_func glXReleaseTexImageEXT; -extern KWINGLUTILS_EXPORT glXBindTexImageEXT_func glXBindTexImageEXT; -// glXCopySubBufferMESA -typedef void (*glXCopySubBuffer_func)(Display* , GLXDrawable, int, int, int, int); -extern KWINGLUTILS_EXPORT glXCopySubBuffer_func glXCopySubBuffer; -// video_sync extension functions -typedef int (*glXGetVideoSync_func)(unsigned int *count); -typedef int (*glXWaitVideoSync_func)(int divisor, int remainder, unsigned int *count); -typedef int (*glXSwapIntervalMESA_func)(unsigned int interval); -typedef void (*glXSwapIntervalEXT_func)(Display *dpy, GLXDrawable drawable, int interval); -typedef int (*glXSwapIntervalSGI_func)(int interval); -extern KWINGLUTILS_EXPORT glXGetVideoSync_func glXGetVideoSync; -extern KWINGLUTILS_EXPORT glXWaitVideoSync_func glXWaitVideoSync; -extern KWINGLUTILS_EXPORT glXSwapIntervalMESA_func glXSwapIntervalMESA; -extern KWINGLUTILS_EXPORT glXSwapIntervalEXT_func glXSwapIntervalEXT; -extern KWINGLUTILS_EXPORT glXSwapIntervalSGI_func glXSwapIntervalSGI; - -// GLX_ARB_create_context -typedef GLXContext (*glXCreateContextAttribsARB_func)(Display *dpy, GLXFBConfig config, - GLXContext share_context, Bool direct, - const int *attrib_list); - -extern KWINGLUTILS_EXPORT glXCreateContextAttribsARB_func glXCreateContextAttribsARB; - -// glActiveTexture -typedef void (*glActiveTexture_func)(GLenum); -extern KWINGLUTILS_EXPORT glActiveTexture_func glActiveTexture; -// framebuffer_object extension functions -typedef GLboolean(*glIsRenderbuffer_func)(GLuint renderbuffer); -typedef void (*glBindRenderbuffer_func)(GLenum target, GLuint renderbuffer); -typedef void (*glDeleteRenderbuffers_func)(GLsizei n, const GLuint *renderbuffers); -typedef void (*glGenRenderbuffers_func)(GLsizei n, GLuint *renderbuffers); -typedef void (*glRenderbufferStorage_func)(GLenum target, GLenum internalformat, GLsizei width, GLsizei height); -typedef void (*glGetRenderbufferParameteriv_func)(GLenum target, GLenum pname, GLint *params); -typedef GLboolean(*glIsFramebuffer_func)(GLuint framebuffer); -typedef void (*glBindFramebuffer_func)(GLenum target, GLuint framebuffer); -typedef void (*glDeleteFramebuffers_func)(GLsizei n, const GLuint *framebuffers); -typedef void (*glGenFramebuffers_func)(GLsizei n, GLuint *framebuffers); -typedef GLenum(*glCheckFramebufferStatus_func)(GLenum target); -typedef void (*glFramebufferTexture1D_func)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (*glFramebufferTexture2D_func)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level); -typedef void (*glFramebufferTexture3D_func)(GLenum target, GLenum attachment, GLenum textarget, GLuint texture, GLint level, GLint zoffset); -typedef void (*glFramebufferRenderbuffer_func)(GLenum target, GLenum attachment, GLenum renderbuffertarget, GLuint renderbuffer); -typedef void (*glGetFramebufferAttachmentParameteriv_func)(GLenum target, GLenum attachment, GLenum pname, GLint *params); -typedef void (*glGenerateMipmap_func)(GLenum target); -typedef void (*glBlitFramebuffer_func)(GLint srcX0, GLint srcY0, GLint srcX1, GLint srcY1, GLint dstX0, GLint dstY0, GLint dstX1, GLint dstY1, GLbitfield mask, GLenum filter); -extern KWINGLUTILS_EXPORT glIsRenderbuffer_func glIsRenderbuffer; -extern KWINGLUTILS_EXPORT glBindRenderbuffer_func glBindRenderbuffer; -extern KWINGLUTILS_EXPORT glDeleteRenderbuffers_func glDeleteRenderbuffers; -extern KWINGLUTILS_EXPORT glGenRenderbuffers_func glGenRenderbuffers; -extern KWINGLUTILS_EXPORT glRenderbufferStorage_func glRenderbufferStorage; -extern KWINGLUTILS_EXPORT glGetRenderbufferParameteriv_func glGetRenderbufferParameteriv; -extern KWINGLUTILS_EXPORT glIsFramebuffer_func glIsFramebuffer; -extern KWINGLUTILS_EXPORT glBindFramebuffer_func glBindFramebuffer; -extern KWINGLUTILS_EXPORT glDeleteFramebuffers_func glDeleteFramebuffers; -extern KWINGLUTILS_EXPORT glGenFramebuffers_func glGenFramebuffers; -extern KWINGLUTILS_EXPORT glCheckFramebufferStatus_func glCheckFramebufferStatus; -extern KWINGLUTILS_EXPORT glFramebufferTexture1D_func glFramebufferTexture1D; -extern KWINGLUTILS_EXPORT glFramebufferTexture2D_func glFramebufferTexture2D; -extern KWINGLUTILS_EXPORT glFramebufferTexture3D_func glFramebufferTexture3D; -extern KWINGLUTILS_EXPORT glFramebufferRenderbuffer_func glFramebufferRenderbuffer; -extern KWINGLUTILS_EXPORT glGetFramebufferAttachmentParameteriv_func glGetFramebufferAttachmentParameteriv; -extern KWINGLUTILS_EXPORT glGenerateMipmap_func glGenerateMipmap; -extern KWINGLUTILS_EXPORT glBlitFramebuffer_func glBlitFramebuffer; -// Shader stuff -typedef GLuint(*glCreateShader_func)(GLenum); -typedef GLvoid(*glShaderSource_func)(GLuint, GLsizei, const GLchar**, const GLint*); -typedef GLvoid(*glCompileShader_func)(GLuint); -typedef GLvoid(*glDeleteShader_func)(GLuint); -typedef GLuint(*glCreateProgram_func)(); -typedef GLvoid(*glAttachShader_func)(GLuint, GLuint); -typedef GLvoid(*glLinkProgram_func)(GLuint); -typedef GLvoid(*glUseProgram_func)(GLuint); -typedef GLvoid(*glDeleteProgram_func)(GLuint); -typedef GLvoid(*glGetShaderInfoLog_func)(GLuint, GLsizei, GLsizei*, GLchar*); -typedef GLvoid(*glGetProgramInfoLog_func)(GLuint, GLsizei, GLsizei*, GLchar*); -typedef GLvoid(*glGetProgramiv_func)(GLuint, GLenum, GLint*); -typedef GLvoid(*glGetShaderiv_func)(GLuint, GLenum, GLint*); -typedef GLvoid(*glUniform1f_func)(GLint, GLfloat); -typedef GLvoid(*glUniform2f_func)(GLint, GLfloat, GLfloat); -typedef GLvoid(*glUniform3f_func)(GLint, GLfloat, GLfloat, GLfloat); -typedef GLvoid(*glUniform4f_func)(GLint, GLfloat, GLfloat, GLfloat, GLfloat); -typedef GLvoid(*glUniformf_func)(GLint, GLfloat); -typedef GLvoid(*glUniform1i_func)(GLint, GLint); -typedef GLvoid(*glUniform1fv_func)(GLint, GLsizei, const GLfloat*); -typedef GLvoid(*glUniform2fv_func)(GLint, GLsizei, const GLfloat*); -typedef GLvoid(*glUniform3fv_func)(GLint, GLsizei, const GLfloat*); -typedef GLvoid(*glUniform4fv_func)(GLint, GLsizei, const GLfloat*); -typedef GLvoid(*glUniformMatrix4fv_func)(GLint, GLsizei, GLboolean, const GLfloat*); -typedef GLvoid(*glGetUniformfv_func)(GLuint, GLint, GLfloat*); -typedef GLvoid(*glValidateProgram_func)(GLuint); -typedef GLint(*glGetUniformLocation_func)(GLuint, const GLchar*); -typedef GLvoid(*glVertexAttrib1f_func)(GLuint, GLfloat); -typedef GLint(*glGetAttribLocation_func)(GLuint, const GLchar*); -typedef GLvoid(*glBindAttribLocation_func)(GLuint, GLuint, const GLchar*); -typedef void (*glGenProgramsARB_func)(GLsizei, GLuint*); -typedef void (*glBindProgramARB_func)(GLenum, GLuint); -typedef void (*glProgramStringARB_func)(GLenum, GLenum, GLsizei, const GLvoid*); -typedef void (*glProgramLocalParameter4fARB_func)(GLenum, GLuint, GLfloat, GLfloat, GLfloat, GLfloat); -typedef void (*glDeleteProgramsARB_func)(GLsizei, const GLuint*); -typedef void (*glGetProgramivARB_func)(GLenum, GLenum, GLint*); -extern KWINGLUTILS_EXPORT glCreateShader_func glCreateShader; -extern KWINGLUTILS_EXPORT glShaderSource_func glShaderSource; -extern KWINGLUTILS_EXPORT glCompileShader_func glCompileShader; -extern KWINGLUTILS_EXPORT glDeleteShader_func glDeleteShader; -extern KWINGLUTILS_EXPORT glCreateProgram_func glCreateProgram; -extern KWINGLUTILS_EXPORT glAttachShader_func glAttachShader; -extern KWINGLUTILS_EXPORT glLinkProgram_func glLinkProgram; -extern KWINGLUTILS_EXPORT glUseProgram_func glUseProgram; -extern KWINGLUTILS_EXPORT glDeleteProgram_func glDeleteProgram; -extern KWINGLUTILS_EXPORT glGetShaderInfoLog_func glGetShaderInfoLog; -extern KWINGLUTILS_EXPORT glGetProgramInfoLog_func glGetProgramInfoLog; -extern KWINGLUTILS_EXPORT glGetProgramiv_func glGetProgramiv; -extern KWINGLUTILS_EXPORT glGetShaderiv_func glGetShaderiv; -extern KWINGLUTILS_EXPORT glUniform1f_func glUniform1f; -extern KWINGLUTILS_EXPORT glUniform2f_func glUniform2f; -extern KWINGLUTILS_EXPORT glUniform3f_func glUniform3f; -extern KWINGLUTILS_EXPORT glUniform4f_func glUniform4f; -extern KWINGLUTILS_EXPORT glUniform1i_func glUniform1i; -extern KWINGLUTILS_EXPORT glUniform1fv_func glUniform1fv; -extern KWINGLUTILS_EXPORT glUniform2fv_func glUniform2fv; -extern KWINGLUTILS_EXPORT glUniform3fv_func glUniform3fv; -extern KWINGLUTILS_EXPORT glUniform4fv_func glUniform4fv; -extern KWINGLUTILS_EXPORT glGetUniformfv_func glGetUniformfv; -extern KWINGLUTILS_EXPORT glUniformMatrix4fv_func glUniformMatrix4fv; -extern KWINGLUTILS_EXPORT glValidateProgram_func glValidateProgram; -extern KWINGLUTILS_EXPORT glGetUniformLocation_func glGetUniformLocation; -extern KWINGLUTILS_EXPORT glVertexAttrib1f_func glVertexAttrib1f; -extern KWINGLUTILS_EXPORT glGetAttribLocation_func glGetAttribLocation; -extern KWINGLUTILS_EXPORT glBindAttribLocation_func glBindAttribLocation; -extern KWINGLUTILS_EXPORT glGenProgramsARB_func glGenProgramsARB; -extern KWINGLUTILS_EXPORT glBindProgramARB_func glBindProgramARB; -extern KWINGLUTILS_EXPORT glProgramStringARB_func glProgramStringARB; -extern KWINGLUTILS_EXPORT glProgramLocalParameter4fARB_func glProgramLocalParameter4fARB; -extern KWINGLUTILS_EXPORT glDeleteProgramsARB_func glDeleteProgramsARB; -extern KWINGLUTILS_EXPORT glGetProgramivARB_func glGetProgramivARB; -// vertex buffer objects -typedef void (*glGenBuffers_func)(GLsizei, GLuint*); -extern KWINGLUTILS_EXPORT glGenBuffers_func glGenBuffers; -typedef void (*glDeleteBuffers_func)(GLsizei n, const GLuint*); -extern KWINGLUTILS_EXPORT glDeleteBuffers_func glDeleteBuffers; -typedef void (*glBindBuffer_func)(GLenum, GLuint); -extern KWINGLUTILS_EXPORT glBindBuffer_func glBindBuffer; -typedef void (*glBufferData_func)(GLenum, GLsizeiptr, const GLvoid*, GLenum); -extern KWINGLUTILS_EXPORT glBufferData_func glBufferData; -typedef void (*glBufferSubData_func)(GLenum target, GLintptr offset, GLsizeiptr size, const GLvoid *data); -extern KWINGLUTILS_EXPORT glBufferSubData_func glBufferSubData; -typedef void (*glGetBufferSubData_func)(GLenum target, GLintptr offset, GLsizeiptr size, GLvoid *data); -extern KWINGLUTILS_EXPORT glGetBufferSubData_func glGetBufferSubData; -typedef void (*glEnableVertexAttribArray_func)(GLuint); -extern KWINGLUTILS_EXPORT glEnableVertexAttribArray_func glEnableVertexAttribArray; -typedef void (*glDisableVertexAttribArray_func)(GLuint); -extern KWINGLUTILS_EXPORT glDisableVertexAttribArray_func glDisableVertexAttribArray; -typedef void (*glVertexAttribPointer_func)(GLuint, GLint, GLenum, GLboolean, GLsizei, const GLvoid*); -extern KWINGLUTILS_EXPORT glVertexAttribPointer_func glVertexAttribPointer; -typedef GLvoid *(*glMapBuffer_func)(GLenum target, GLenum access); -extern KWINGLUTILS_EXPORT glMapBuffer_func glMapBuffer; -typedef GLboolean (*glUnmapBuffer_func)(GLenum target); -extern KWINGLUTILS_EXPORT glUnmapBuffer_func glUnmapBuffer; - -// GL_ARB_vertex_array_object -typedef void (*glBindVertexArray_func)(GLuint array); -typedef void (*glDeleteVertexArrays_func)(GLsizei n, const GLuint *arrays); -typedef void (*glGenVertexArrays_func)(GLsizei n, GLuint *arrays); -typedef GLboolean (*glIsVertexArray_func)(GLuint array); - -extern KWINGLUTILS_EXPORT glBindVertexArray_func glBindVertexArray; -extern KWINGLUTILS_EXPORT glDeleteVertexArrays_func glDeleteVertexArrays; -extern KWINGLUTILS_EXPORT glGenVertexArrays_func glGenVertexArrays; -extern KWINGLUTILS_EXPORT glIsVertexArray_func glIsVertexArray; - -// GL_EXT_gpu_shader4 / GL 3.0 -typedef void (*glVertexAttribI1i_func)(GLuint index, GLint x_func); -typedef void (*glVertexAttribI2i_func)(GLuint index, GLint x, GLint y_func); -typedef void (*glVertexAttribI3i_func)(GLuint index, GLint x, GLint y, GLint z_func); -typedef void (*glVertexAttribI4i_func)(GLuint index, GLint x, GLint y, GLint z, GLint w_func); -typedef void (*glVertexAttribI1ui_func)(GLuint index, GLuint x_func); -typedef void (*glVertexAttribI2ui_func)(GLuint index, GLuint x, GLuint y_func); -typedef void (*glVertexAttribI3ui_func)(GLuint index, GLuint x, GLuint y, GLuint z_func); -typedef void (*glVertexAttribI4ui_func)(GLuint index, GLuint x, GLuint y, GLuint z, GLuint w_func); -typedef void (*glVertexAttribI1iv_func)(GLuint index, const GLint *v_func); -typedef void (*glVertexAttribI2iv_func)(GLuint index, const GLint *v_func); -typedef void (*glVertexAttribI3iv_func)(GLuint index, const GLint *v_func); -typedef void (*glVertexAttribI4iv_func)(GLuint index, const GLint *v_func); -typedef void (*glVertexAttribI1uiv_func)(GLuint index, const GLuint *v_func); -typedef void (*glVertexAttribI2uiv_func)(GLuint index, const GLuint *v_func); -typedef void (*glVertexAttribI3uiv_func)(GLuint index, const GLuint *v_func); -typedef void (*glVertexAttribI4uiv_func)(GLuint index, const GLuint *v_func); -typedef void (*glVertexAttribI4bv_func)(GLuint index, const GLbyte *v_func); -typedef void (*glVertexAttribI4sv_func)(GLuint index, const GLshort *v_func); -typedef void (*glVertexAttribI4ubv_func)(GLuint index, const GLubyte *v_func); -typedef void (*glVertexAttribI4usv_func)(GLuint index, const GLushort *v_func); -typedef void (*glVertexAttribIPointer_func)(GLuint index, GLint size, GLenum type, GLsizei stride, const GLvoid *pointer_func); -typedef void (*glGetVertexAttribIiv_func)(GLuint index, GLenum pname, GLint *params_func); -typedef void (*glGetVertexAttribIuiv_func)(GLuint index, GLenum pname, GLuint *params_func); -typedef void (*glGetUniformuiv_func)(GLuint program, GLint location, GLuint *params); -typedef void (*glBindFragDataLocation_func)(GLuint program, GLuint color, const GLchar *name); -typedef GLint (*glGetFragDataLocation_func)(GLuint program, const GLchar *name); -typedef void (*glUniform1ui_func)(GLint location, GLuint v0); -typedef void (*glUniform2ui_func)(GLint location, GLuint v0, GLuint v1); -typedef void (*glUniform3ui_func)(GLint location, GLuint v0, GLuint v1, GLuint v2); -typedef void (*glUniform4ui_func)(GLint location, GLuint v0, GLuint v1, GLuint v2, GLuint v3); -typedef void (*glUniform1uiv_func)(GLint location, GLsizei count, const GLuint *value); -typedef void (*glUniform2uiv_func)(GLint location, GLsizei count, const GLuint *value); -typedef void (*glUniform3uiv_func)(GLint location, GLsizei count, const GLuint *value); - -extern KWINGLUTILS_EXPORT glVertexAttribI1i_func glVertexAttribI1i; -extern KWINGLUTILS_EXPORT glVertexAttribI2i_func glVertexAttribI2i; -extern KWINGLUTILS_EXPORT glVertexAttribI3i_func glVertexAttribI3i; -extern KWINGLUTILS_EXPORT glVertexAttribI4i_func glVertexAttribI4i; -extern KWINGLUTILS_EXPORT glVertexAttribI1ui_func glVertexAttribI1ui; -extern KWINGLUTILS_EXPORT glVertexAttribI2ui_func glVertexAttribI2ui; -extern KWINGLUTILS_EXPORT glVertexAttribI3ui_func glVertexAttribI3ui; -extern KWINGLUTILS_EXPORT glVertexAttribI4ui_func glVertexAttribI4ui; -extern KWINGLUTILS_EXPORT glVertexAttribI1iv_func glVertexAttribI1iv; -extern KWINGLUTILS_EXPORT glVertexAttribI2iv_func glVertexAttribI2iv; -extern KWINGLUTILS_EXPORT glVertexAttribI3iv_func glVertexAttribI3iv; -extern KWINGLUTILS_EXPORT glVertexAttribI4iv_func glVertexAttribI4iv; -extern KWINGLUTILS_EXPORT glVertexAttribI1uiv_func glVertexAttribI1uiv; -extern KWINGLUTILS_EXPORT glVertexAttribI2uiv_func glVertexAttribI2uiv; -extern KWINGLUTILS_EXPORT glVertexAttribI3uiv_func glVertexAttribI3uiv; -extern KWINGLUTILS_EXPORT glVertexAttribI4uiv_func glVertexAttribI4uiv; -extern KWINGLUTILS_EXPORT glVertexAttribI4bv_func glVertexAttribI4bv; -extern KWINGLUTILS_EXPORT glVertexAttribI4sv_func glVertexAttribI4sv; -extern KWINGLUTILS_EXPORT glVertexAttribI4ubv_func glVertexAttribI4ubv; -extern KWINGLUTILS_EXPORT glVertexAttribI4usv_func glVertexAttribI4usv; -extern KWINGLUTILS_EXPORT glVertexAttribIPointer_func glVertexAttribIPointer; -extern KWINGLUTILS_EXPORT glGetVertexAttribIiv_func glGetVertexAttribIiv; -extern KWINGLUTILS_EXPORT glGetVertexAttribIuiv_func glGetVertexAttribIuiv; -extern KWINGLUTILS_EXPORT glGetUniformuiv_func glGetUniformuiv; -extern KWINGLUTILS_EXPORT glBindFragDataLocation_func glBindFragDataLocation; -extern KWINGLUTILS_EXPORT glGetFragDataLocation_func glGetFragDataLocation; -extern KWINGLUTILS_EXPORT glUniform1ui_func glUniform1ui; -extern KWINGLUTILS_EXPORT glUniform2ui_func glUniform2ui; -extern KWINGLUTILS_EXPORT glUniform3ui_func glUniform3ui; -extern KWINGLUTILS_EXPORT glUniform4ui_func glUniform4ui; -extern KWINGLUTILS_EXPORT glUniform1uiv_func glUniform1uiv; -extern KWINGLUTILS_EXPORT glUniform2uiv_func glUniform2uiv; -extern KWINGLUTILS_EXPORT glUniform3uiv_func glUniform3uiv; - -// GL_ARB_map_buffer_range -typedef GLvoid* (*glMapBufferRange_func)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); -typedef void (*glFlushMappedBufferRange_func)(GLenum target, GLintptr offset, GLsizeiptr length); - -extern KWINGLUTILS_EXPORT glMapBufferRange_func glMapBufferRange; -extern KWINGLUTILS_EXPORT glFlushMappedBufferRange_func glFlushMappedBufferRange; - -// GL_ARB_robustness -typedef GLenum (*glGetGraphicsResetStatus_func)(); -typedef void (*glReadnPixels_func)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); -typedef void (*glGetnUniformfv_func)(GLuint program, GLint location, GLsizei bufSize, GLfloat *params); - -extern KWINGLUTILS_EXPORT glGetGraphicsResetStatus_func glGetGraphicsResetStatus; -extern KWINGLUTILS_EXPORT glReadnPixels_func glReadnPixels; -extern KWINGLUTILS_EXPORT glGetnUniformfv_func glGetnUniformfv; - -// GL_ARB_draw_elements_base_vertex -typedef void (*glDrawElementsBaseVertex_func)(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLint basevertex); -typedef void (*glDrawElementsInstancedBaseVertex_func)(GLenum mode, GLsizei count, GLenum type, const GLvoid *indices, GLsizei instancecount, GLint basevertex); - -extern KWINGLUTILS_EXPORT glDrawElementsBaseVertex_func glDrawElementsBaseVertex; -extern KWINGLUTILS_EXPORT glDrawElementsInstancedBaseVertex_func glDrawElementsInstancedBaseVertex; - -// GL_ARB_copy_buffer -typedef void (*glCopyBufferSubData_func)(GLenum readTarget, GLenum writeTarget, GLintptr readOffset, - GLintptr writeOffset, GLsizeiptr size); - -extern KWINGLUTILS_EXPORT glCopyBufferSubData_func glCopyBufferSubData; - -} // namespace - -#endif // not KWIN_HAVE_OPENGLES +#endif #ifdef KWIN_HAVE_EGL -#define EGL_EGLEXT_PROTOTYPES -#define GL_GLEXT_PROTOTYPES - -#ifdef KWIN_HAVE_OPENGLES -#include -#include - -// see http://www.khronos.org/registry/gles/extensions/EXT/EXT_robustness.txt -#ifndef GL_GUILTY_CONTEXT_RESET_EXT -#define GL_GUILTY_CONTEXT_RESET_EXT 0x8253 -#endif - -#ifndef GL_INNOCENT_CONTEXT_RESET_EXT -#define GL_INNOCENT_CONTEXT_RESET_EXT 0x8254 -#endif - -#ifndef GL_UNKNOWN_CONTEXT_RESET_EXT -#define GL_UNKNOWN_CONTEXT_RESET_EXT 0x8255 -#endif - -#endif - -#include -#include -#include - -#ifndef EGL_POST_SUB_BUFFER_SUPPORTED_NV -#define EGL_POST_SUB_BUFFER_SUPPORTED_NV 0x30BE -#endif - -#ifndef EGL_BUFFER_AGE_EXT -#define EGL_BUFFER_AGE_EXT 0x313D -#endif - -#ifndef GL_UNPACK_ROW_LENGTH -#define GL_UNPACK_ROW_LENGTH 0x0CF2 -#endif - -#ifndef GL_UNPACK_SKIP_ROWS -#define GL_UNPACK_SKIP_ROWS 0x0CF3 -#endif - -#ifndef GL_UNPACK_SKIP_PIXELS -#define GL_UNPACK_SKIP_PIXELS 0x0CF4 -#endif - -#ifndef EGL_KHR_create_context -#define EGL_CONTEXT_MAJOR_VERSION_KHR EGL_CONTEXT_CLIENT_VERSION -#define EGL_CONTEXT_MINOR_VERSION_KHR 0x30FB -#define EGL_CONTEXT_FLAGS_KHR 0x30FC -#define EGL_CONTEXT_OPENGL_PROFILE_MASK_KHR 0x30FD -#define EGL_CONTEXT_OPENGL_RESET_NOTIFICATION_STRATEGY_KHR 0x31BD -#define EGL_NO_RESET_NOTIFICATION_KHR 0x31BE -#define EGL_LOSE_CONTEXT_ON_RESET_KHR 0x31BF -#define EGL_CONTEXT_OPENGL_DEBUG_BIT_KHR 0x00000001 -#define EGL_CONTEXT_OPENGL_FORWARD_COMPATIBLE_BIT_KHR 0x00000002 -#define EGL_CONTEXT_OPENGL_ROBUST_ACCESS_BIT_KHR 0x00000004 -#define EGL_CONTEXT_OPENGL_CORE_PROFILE_BIT_KHR 0x00000001 -#define EGL_CONTEXT_OPENGL_COMPATIBILITY_PROFILE_BIT_KHR 0x00000002 -#define EGL_OPENGL_ES3_BIT_KHR 0x00000040 -#endif - -#ifndef __gl3_h_ -#define GL_MAP_READ_BIT 0x0001 -#define GL_MAP_WRITE_BIT 0x0002 -#define GL_MAP_INVALIDATE_RANGE_BIT 0x0004 -#define GL_MAP_INVALIDATE_BUFFER_BIT 0x0008 -#define GL_MAP_FLUSH_EXPLICIT_BIT 0x0010 -#define GL_MAP_UNSYNCHRONIZED_BIT 0x0020 -#define GL_TEXTURE_3D 0x806F -#define GL_TEXTURE_WRAP_R 0x8072 -#endif - -namespace KWin -{ - void KWINGLUTILS_EXPORT eglResolveFunctions(); +#endif + void KWINGLUTILS_EXPORT glResolveFunctions(OpenGLPlatformInterface platformInterface); -// EGL -typedef EGLImageKHR(*eglCreateImageKHR_func)(EGLDisplay, EGLContext, EGLenum, EGLClientBuffer, const EGLint*); -typedef EGLBoolean(*eglDestroyImageKHR_func)(EGLDisplay, EGLImageKHR); -typedef EGLBoolean (*eglPostSubBufferNV_func)(EGLDisplay dpy, EGLSurface surface, EGLint x, EGLint y, EGLint width, EGLint height); -extern KWINGLUTILS_EXPORT eglCreateImageKHR_func eglCreateImageKHR; -extern KWINGLUTILS_EXPORT eglDestroyImageKHR_func eglDestroyImageKHR; -extern KWINGLUTILS_EXPORT eglPostSubBufferNV_func eglPostSubBufferNV; +// GLX_MESA_swap_interval +using glXSwapIntervalMESA_func = int (*)(unsigned int interval); +extern KWINGLUTILS_EXPORT glXSwapIntervalMESA_func glXSwapIntervalMESA; -// GLES -typedef GLvoid(*glEGLImageTargetTexture2DOES_func)(GLenum, GLeglImageOES); -extern KWINGLUTILS_EXPORT glEGLImageTargetTexture2DOES_func glEGLImageTargetTexture2DOES; - - -#ifdef KWIN_HAVE_OPENGLES - -// GL_OES_mapbuffer -typedef GLvoid *(*glMapBuffer_func)(GLenum target, GLenum access); -typedef GLboolean (*glUnmapBuffer_func)(GLenum target); -typedef void (*glGetBufferPointerv_func)(GLenum target, GLenum pname, GLvoid **params); - -extern KWINGLUTILS_EXPORT glMapBuffer_func glMapBuffer; -extern KWINGLUTILS_EXPORT glUnmapBuffer_func glUnmapBuffer; -extern KWINGLUTILS_EXPORT glGetBufferPointerv_func glGetBufferPointerv; - -// GL_OES_texture_3D -typedef GLvoid(*glTexImage3DOES_func)(GLenum, GLint, GLenum, GLsizei, GLsizei, GLsizei, GLint, GLenum, GLenum, const GLvoid*); -extern KWINGLUTILS_EXPORT glTexImage3DOES_func glTexImage3D; - -// GL_EXT_map_buffer_range -typedef GLvoid *(*glMapBufferRange_func)(GLenum target, GLintptr offset, GLsizeiptr length, GLbitfield access); -typedef void (*glFlushMappedBufferRange_func)(GLenum target, GLintptr offset, GLsizeiptr length); - -extern KWINGLUTILS_EXPORT glMapBufferRange_func glMapBufferRange; -extern KWINGLUTILS_EXPORT glFlushMappedBufferRange_func glFlushMappedBufferRange; - -// GL_EXT_robustness -typedef GLenum (*glGetGraphicsResetStatus_func)(); -typedef void (*glReadnPixels_func)(GLint x, GLint y, GLsizei width, GLsizei height, GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); -typedef void (*glGetnUniformfv_func)(GLuint program, GLint location, GLsizei bufSize, GLfloat *params); +// GL_ARB_robustness / GL_EXT_robustness +using glGetGraphicsResetStatus_func = GLenum (*)(); +using glReadnPixels_func = void (*)(GLint x, GLint y, GLsizei width, GLsizei height, + GLenum format, GLenum type, GLsizei bufSize, GLvoid *data); +using glGetnUniformfv_func = void (*)(GLuint program, GLint location, GLsizei bufSize, GLfloat *params); extern KWINGLUTILS_EXPORT glGetGraphicsResetStatus_func glGetGraphicsResetStatus; extern KWINGLUTILS_EXPORT glReadnPixels_func glReadnPixels; extern KWINGLUTILS_EXPORT glGetnUniformfv_func glGetnUniformfv; -#endif // KWIN_HAVE_OPENGLES - } // namespace -#endif // KWIN_HAVE_EGL - #endif // KWIN_GLUTILS_FUNCS_H