GLXFBConfig qglx_findConfig(Display *display, int screen , const QPlatformWindowFormat &format, int drawableBit) { bool reduced = true; GLXFBConfig chosenConfig = 0; QPlatformWindowFormat reducedFormat = format; while (!chosenConfig && reduced) { QVector<int> spec = qglx_buildSpec(reducedFormat, drawableBit); int confcount = 0; GLXFBConfig *configs; configs = glXChooseFBConfig(display, screen,spec.constData(),&confcount); if (confcount) { for (int i = 0; i < confcount; i++) { chosenConfig = configs[i]; // Make sure we try to get an ARGB visual if the format asked for an alpha: if (reducedFormat.alpha()) { int alphaSize; glXGetFBConfigAttrib(display,configs[i],GLX_ALPHA_SIZE,&alphaSize); if (alphaSize > 0) break; } else { break; // Just choose the first in the list if there's no alpha requested } } XFree(configs); } reducedFormat = qglx_reducePlatformWindowFormat(reducedFormat,&reduced); } if (!chosenConfig) qWarning("Warning: no suitable glx confiuration found"); return chosenConfig; }
void XCompositeGLXClientBufferIntegration::bindTextureToBuffer(struct ::wl_resource *buffer) { XCompositeBuffer *compositorBuffer = XCompositeBuffer::fromResource(buffer); Pixmap pixmap = XCompositeNameWindowPixmap(mDisplay, compositorBuffer->window()); QVector<int> glxConfigSpec = qglx_buildSpec(); int numberOfConfigs; GLXFBConfig *configs = glXChooseFBConfig(mDisplay,mScreen,glxConfigSpec.constData(),&numberOfConfigs); QVector<int> attribList; attribList.append(GLX_TEXTURE_FORMAT_EXT); attribList.append(GLX_TEXTURE_FORMAT_RGB_EXT); attribList.append(GLX_TEXTURE_TARGET_EXT); attribList.append(GLX_TEXTURE_2D_EXT); attribList.append(0); GLXPixmap glxPixmap = glXCreatePixmap(mDisplay,*configs,pixmap,attribList.constData()); uint inverted = 0; glXQueryDrawable(mDisplay, glxPixmap, GLX_Y_INVERTED_EXT,&inverted); compositorBuffer->setInvertedY(!inverted); XFree(configs); m_glxBindTexImageEXT(mDisplay,glxPixmap,GLX_FRONT_EXT, 0); //Do we need to change the api so that we do bind and release in the painevent? //The specification states that when deleting the texture the color buffer is deleted // m_glxReleaseTexImageEXT(mDisplay,glxPixmap,GLX_FRONT_EXT); }
GLXFBConfig qglx_findConfig(Display *display, int screen , const QSurfaceFormat &format, int drawableBit) { bool reduced = true; GLXFBConfig chosenConfig = 0; QSurfaceFormat reducedFormat = format; while (!chosenConfig && reduced) { QVector<int> spec = qglx_buildSpec(reducedFormat, drawableBit); int confcount = 0; GLXFBConfig *configs; configs = glXChooseFBConfig(display, screen,spec.constData(),&confcount); if (confcount) { for (int i = 0; i < confcount; i++) { chosenConfig = configs[i]; // Make sure we try to get an ARGB visual if the format asked for an alpha: if (reducedFormat.hasAlpha()) { int alphaSize; glXGetFBConfigAttrib(display,configs[i],GLX_ALPHA_SIZE,&alphaSize); if (alphaSize > 0) { XVisualInfo *visual = glXGetVisualFromFBConfig(display, chosenConfig); bool hasAlpha = false; #if !defined(QT_NO_XRENDER) XRenderPictFormat *pictFormat = XRenderFindVisualFormat(display, visual->visual); hasAlpha = pictFormat->direct.alphaMask > 0; #else hasAlpha = visual->depth == 32; #endif XFree(visual); if (hasAlpha) break; } } else { break; // Just choose the first in the list if there's no alpha requested } } XFree(configs); } if (!chosenConfig) reducedFormat = qglx_reduceSurfaceFormat(reducedFormat,&reduced); } return chosenConfig; }
GLXFBConfig qglx_findConfig(Display *display, int screen , const QSurfaceFormat &format, int drawableBit) { // Allow forcing LIBGL_ALWAYS_SOFTWARE for Qt 5 applications only. // This is most useful with drivers that only support OpenGL 1. // We need OpenGL 2, but the user probably doesn't want // LIBGL_ALWAYS_SOFTWARE in OpenGL 1 apps. static bool checkedForceSoftwareOpenGL = false; static bool forceSoftwareOpenGL = false; if (!checkedForceSoftwareOpenGL) { // If LIBGL_ALWAYS_SOFTWARE is already set, don't mess with it. // We want to unset LIBGL_ALWAYS_SOFTWARE at the end so it does not // get inherited by other processes, of course only if it wasn't // already set before. if (!qEnvironmentVariableIsEmpty("QT_XCB_FORCE_SOFTWARE_OPENGL") && !qEnvironmentVariableIsSet("LIBGL_ALWAYS_SOFTWARE")) forceSoftwareOpenGL = true; checkedForceSoftwareOpenGL = true; } if (forceSoftwareOpenGL) qputenv("LIBGL_ALWAYS_SOFTWARE", QByteArrayLiteral("1")); bool reduced = true; GLXFBConfig chosenConfig = 0; QSurfaceFormat reducedFormat = format; while (!chosenConfig && reduced) { QVector<int> spec = qglx_buildSpec(reducedFormat, drawableBit); int confcount = 0; GLXFBConfig *configs; configs = glXChooseFBConfig(display, screen,spec.constData(),&confcount); if (confcount) { for (int i = 0; i < confcount; i++) { chosenConfig = configs[i]; // Make sure we try to get an ARGB visual if the format asked for an alpha: if (reducedFormat.hasAlpha()) { int alphaSize; glXGetFBConfigAttrib(display,configs[i],GLX_ALPHA_SIZE,&alphaSize); if (alphaSize > 0) { XVisualInfo *visual = glXGetVisualFromFBConfig(display, chosenConfig); bool hasAlpha = false; #if !defined(QT_NO_XRENDER) XRenderPictFormat *pictFormat = XRenderFindVisualFormat(display, visual->visual); hasAlpha = pictFormat->direct.alphaMask > 0; #else hasAlpha = visual->depth == 32; #endif XFree(visual); if (hasAlpha) break; } } else { break; // Just choose the first in the list if there's no alpha requested } } XFree(configs); } if (!chosenConfig) reducedFormat = qglx_reduceSurfaceFormat(reducedFormat,&reduced); } // unset LIBGL_ALWAYS_SOFTWARE now so other processes don't inherit it if (forceSoftwareOpenGL) qunsetenv("LIBGL_ALWAYS_SOFTWARE"); return chosenConfig; }