src/opengl/qgl_x11.cpp
changeset 33 3e2da88830cd
parent 30 5dc02b23752f
equal deleted inserted replaced
30:5dc02b23752f 33:3e2da88830cd
   113 #define GLX_TEXTURE_2D_EXT                 0x20DC
   113 #define GLX_TEXTURE_2D_EXT                 0x20DC
   114 #define GLX_TEXTURE_RECTANGLE_EXT          0x20DD
   114 #define GLX_TEXTURE_RECTANGLE_EXT          0x20DD
   115 #define GLX_FRONT_LEFT_EXT                 0x20DE
   115 #define GLX_FRONT_LEFT_EXT                 0x20DE
   116 #endif
   116 #endif
   117 
   117 
       
   118 #ifndef GLX_ARB_create_context
       
   119 #define GLX_CONTEXT_DEBUG_BIT_ARB          0x00000001
       
   120 #define GLX_CONTEXT_FORWARD_COMPATIBLE_BIT_ARB 0x00000002
       
   121 #define GLX_CONTEXT_MAJOR_VERSION_ARB      0x2091
       
   122 #define GLX_CONTEXT_MINOR_VERSION_ARB      0x2092
       
   123 #define GLX_CONTEXT_FLAGS_ARB              0x2094
       
   124 #endif
       
   125 
       
   126 #ifndef GLX_ARB_create_context_profile
       
   127 #define GLX_CONTEXT_CORE_PROFILE_BIT_ARB   0x00000001
       
   128 #define GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB 0x00000002
       
   129 #define GLX_CONTEXT_PROFILE_MASK_ARB       0x9126
       
   130 #endif
       
   131 
   118 /*
   132 /*
   119   The qt_gl_choose_cmap function is internal and used by QGLWidget::setContext()
   133   The qt_gl_choose_cmap function is internal and used by QGLWidget::setContext()
   120   and GLX (not Windows).  If the application can't find any sharable
   134   and GLX (not Windows).  If the application can't find any sharable
   121   colormaps, it must at least create as few colormaps as possible.  The
   135   colormaps, it must at least create as few colormaps as possible.  The
   122   dictionary solution below ensures only one colormap is created per visual.
   136   dictionary solution below ensures only one colormap is created per visual.
   397 bool QGLFormat::hasOpenGLOverlays()
   411 bool QGLFormat::hasOpenGLOverlays()
   398 {
   412 {
   399     if (!trans_colors_init)
   413     if (!trans_colors_init)
   400         find_trans_colors();
   414         find_trans_colors();
   401     return trans_colors.size() > 0;
   415     return trans_colors.size() > 0;
       
   416 }
       
   417 
       
   418 static bool buildSpec(int* spec, const QGLFormat& f, QPaintDevice* paintDevice,
       
   419                       int bufDepth, bool onlyFBConfig = false)
       
   420 {
       
   421     int i = 0;
       
   422     spec[i++] = GLX_LEVEL;
       
   423     spec[i++] = f.plane();
       
   424     const QX11Info *xinfo = qt_x11Info(paintDevice);
       
   425     bool useFBConfig = onlyFBConfig;
       
   426 
       
   427 #if defined(GLX_VERSION_1_3) && !defined(QT_NO_XRENDER) && !defined(Q_OS_HPUX)
       
   428     /*
       
   429       HPUX defines GLX_VERSION_1_3 but does not implement the corresponding functions.
       
   430       Specifically glXChooseFBConfig and glXGetVisualFromFBConfig are not implemented.
       
   431      */
       
   432     QWidget* widget = 0;
       
   433     if (paintDevice->devType() == QInternal::Widget)
       
   434         widget = static_cast<QWidget*>(paintDevice);
       
   435 
       
   436     // Only use glXChooseFBConfig for widgets if we're trying to get an ARGB visual
       
   437     if (widget && widget->testAttribute(Qt::WA_TranslucentBackground) && X11->use_xrender)
       
   438         useFBConfig = true;
       
   439 #endif
       
   440 
       
   441 #if defined(GLX_VERSION_1_1) && defined(GLX_EXT_visual_info)
       
   442     static bool useTranspExt = false;
       
   443     static bool useTranspExtChecked = false;
       
   444     if (f.plane() && !useTranspExtChecked && paintDevice) {
       
   445         QGLExtensionMatcher extensions(glXQueryExtensionsString(xinfo->display(), xinfo->screen()));
       
   446         useTranspExt = extensions.match("GLX_EXT_visual_info");
       
   447         //# (A bit simplistic; that could theoretically be a substring)
       
   448         if (useTranspExt) {
       
   449             QByteArray cstr(glXGetClientString(xinfo->display(), GLX_VENDOR));
       
   450             useTranspExt = !cstr.contains("Xi Graphics"); // bug workaround
       
   451             if (useTranspExt) {
       
   452                 // bug workaround - some systems (eg. FireGL) refuses to return an overlay
       
   453                 // visual if the GLX_TRANSPARENT_TYPE_EXT attribute is specified, even if
       
   454                 // the implementation supports transparent overlays
       
   455                 int tmpSpec[] = { GLX_LEVEL, f.plane(), GLX_TRANSPARENT_TYPE_EXT,
       
   456                                   f.rgba() ? GLX_TRANSPARENT_RGB_EXT : GLX_TRANSPARENT_INDEX_EXT,
       
   457                                   XNone };
       
   458                 XVisualInfo * vinf = glXChooseVisual(xinfo->display(), xinfo->screen(), tmpSpec);
       
   459                 if (!vinf) {
       
   460                     useTranspExt = false;
       
   461                 }
       
   462             }
       
   463         }
       
   464 
       
   465         useTranspExtChecked = true;
       
   466     }
       
   467     if (f.plane() && useTranspExt && !useFBConfig) {
       
   468         // Required to avoid non-transparent overlay visual(!) on some systems
       
   469         spec[i++] = GLX_TRANSPARENT_TYPE_EXT;
       
   470         spec[i++] = f.rgba() ? GLX_TRANSPARENT_RGB_EXT : GLX_TRANSPARENT_INDEX_EXT;
       
   471     }
       
   472 #endif
       
   473 
       
   474 #if defined(GLX_VERSION_1_3)  && !defined(Q_OS_HPUX)
       
   475     // GLX_RENDER_TYPE is only in glx >=1.3
       
   476     if (useFBConfig) {
       
   477         spec[i++] = GLX_RENDER_TYPE;
       
   478         spec[i++] = f.rgba() ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT;
       
   479     }
       
   480 #endif
       
   481 
       
   482     if (f.doubleBuffer())
       
   483         spec[i++] = GLX_DOUBLEBUFFER;
       
   484         if (useFBConfig)
       
   485             spec[i++] = True;
       
   486     if (f.depth()) {
       
   487         spec[i++] = GLX_DEPTH_SIZE;
       
   488         spec[i++] = f.depthBufferSize() == -1 ? 1 : f.depthBufferSize();
       
   489     }
       
   490     if (f.stereo()) {
       
   491         spec[i++] = GLX_STEREO;
       
   492         if (useFBConfig)
       
   493             spec[i++] = True;
       
   494     }
       
   495     if (f.stencil()) {
       
   496         spec[i++] = GLX_STENCIL_SIZE;
       
   497         spec[i++] = f.stencilBufferSize() == -1 ? 1 : f.stencilBufferSize();
       
   498     }
       
   499     if (f.rgba()) {
       
   500         if (!useFBConfig)
       
   501             spec[i++] = GLX_RGBA;
       
   502         spec[i++] = GLX_RED_SIZE;
       
   503         spec[i++] = f.redBufferSize() == -1 ? 1 : f.redBufferSize();
       
   504         spec[i++] = GLX_GREEN_SIZE;
       
   505         spec[i++] = f.greenBufferSize() == -1 ? 1 : f.greenBufferSize();
       
   506         spec[i++] = GLX_BLUE_SIZE;
       
   507         spec[i++] = f.blueBufferSize() == -1 ? 1 : f.blueBufferSize();
       
   508         if (f.alpha()) {
       
   509             spec[i++] = GLX_ALPHA_SIZE;
       
   510             spec[i++] = f.alphaBufferSize() == -1 ? 1 : f.alphaBufferSize();
       
   511         }
       
   512         if (f.accum()) {
       
   513             spec[i++] = GLX_ACCUM_RED_SIZE;
       
   514             spec[i++] = f.accumBufferSize() == -1 ? 1 : f.accumBufferSize();
       
   515             spec[i++] = GLX_ACCUM_GREEN_SIZE;
       
   516             spec[i++] = f.accumBufferSize() == -1 ? 1 : f.accumBufferSize();
       
   517             spec[i++] = GLX_ACCUM_BLUE_SIZE;
       
   518             spec[i++] = f.accumBufferSize() == -1 ? 1 : f.accumBufferSize();
       
   519             if (f.alpha()) {
       
   520                 spec[i++] = GLX_ACCUM_ALPHA_SIZE;
       
   521                 spec[i++] = f.accumBufferSize() == -1 ? 1 : f.accumBufferSize();
       
   522             }
       
   523         }
       
   524     } else {
       
   525         spec[i++] = GLX_BUFFER_SIZE;
       
   526         spec[i++] = bufDepth;
       
   527     }
       
   528 
       
   529     if (f.sampleBuffers()) {
       
   530         spec[i++] = GLX_SAMPLE_BUFFERS_ARB;
       
   531         spec[i++] = 1;
       
   532         spec[i++] = GLX_SAMPLES_ARB;
       
   533         spec[i++] = f.samples() == -1 ? 4 : f.samples();
       
   534     }
       
   535 
       
   536 #if defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX)
       
   537     if (useFBConfig) {
       
   538         spec[i++] = GLX_DRAWABLE_TYPE;
       
   539         switch(paintDevice->devType()) {
       
   540         case QInternal::Pixmap:
       
   541             spec[i++] = GLX_PIXMAP_BIT;
       
   542             break;
       
   543         case QInternal::Pbuffer:
       
   544             spec[i++] = GLX_PBUFFER_BIT;
       
   545             break;
       
   546         default:
       
   547             qWarning("QGLContext: Unknown paint device type %d", paintDevice->devType());
       
   548             // Fall-through & assume it's a window
       
   549         case QInternal::Widget:
       
   550             spec[i++] = GLX_WINDOW_BIT;
       
   551             break;
       
   552         };
       
   553     }
       
   554 #endif
       
   555 
       
   556     spec[i] = XNone;
       
   557     return useFBConfig;
   402 }
   558 }
   403 
   559 
   404 /*****************************************************************************
   560 /*****************************************************************************
   405   QGLContext UNIX/GLX-specific code
   561   QGLContext UNIX/GLX-specific code
   406  *****************************************************************************/
   562  *****************************************************************************/
   491             || (shareContext->d_func()->screen != xinfo->screen())))
   647             || (shareContext->d_func()->screen != xinfo->screen())))
   492     {
   648     {
   493         shareContext = 0;
   649         shareContext = 0;
   494     }
   650     }
   495 
   651 
       
   652     const int major = d->reqFormat.majorVersion();
       
   653     const int minor = d->reqFormat.minorVersion();
       
   654     const int profile = d->reqFormat.profile() == QGLFormat::CompatibilityProfile
       
   655         ? GLX_CONTEXT_COMPATIBILITY_PROFILE_BIT_ARB
       
   656         : GLX_CONTEXT_CORE_PROFILE_BIT_ARB;
       
   657 
   496     d->cx = 0;
   658     d->cx = 0;
   497     if (shareContext) {
   659 
       
   660 #if defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX)
       
   661     /*
       
   662       HPUX defines GLX_VERSION_1_3 but does not implement the corresponding functions.
       
   663       Specifically glXChooseFBConfig and glXGetVisualFromFBConfig are not implemented.
       
   664      */
       
   665     if ((major == 3 && minor >= 2) || major > 3) {
       
   666         QGLTemporaryContext *tmpContext = 0;
       
   667         if (!QGLContext::currentContext())
       
   668             tmpContext = new QGLTemporaryContext;
       
   669 
       
   670         int attributes[] = { GLX_CONTEXT_MAJOR_VERSION_ARB, major,
       
   671                              GLX_CONTEXT_MINOR_VERSION_ARB, minor,
       
   672                              GLX_CONTEXT_PROFILE_MASK_ARB, profile,
       
   673                              0 };
       
   674 
       
   675         typedef GLXContext ( * Q_PFNGLXCREATECONTEXTATTRIBSARBPROC)
       
   676             (Display* dpy, GLXFBConfig config, GLXContext share_context, Bool direct, const int *attrib_list);
       
   677 
       
   678 
       
   679         Q_PFNGLXCREATECONTEXTATTRIBSARBPROC glXCreateContextAttribs =
       
   680             (Q_PFNGLXCREATECONTEXTATTRIBSARBPROC) qglx_getProcAddress("glXCreateContextAttribsARB");
       
   681 
       
   682         if (glXCreateContextAttribs) {
       
   683             int spec[45];
       
   684             glXGetConfig(disp, (XVisualInfo*)d->vi, GLX_BUFFER_SIZE, &res);
       
   685             buildSpec(spec, format(), d->paintDevice, res, true);
       
   686 
       
   687             GLXFBConfig *configs;
       
   688             int configCount = 0;
       
   689             configs = glXChooseFBConfig(disp, xinfo->screen(), spec, &configCount);
       
   690 
       
   691             if (configs && configCount > 0) {
       
   692                 d->cx = glXCreateContextAttribs(disp, configs[0],
       
   693                     shareContext ? (GLXContext)shareContext->d_func()->cx : 0, direct, attributes);
       
   694                 if (!d->cx && shareContext) {
       
   695                     shareContext = 0;
       
   696                     d->cx = glXCreateContextAttribs(disp, configs[0], 0, direct, attributes);
       
   697                 }
       
   698                 d->screen = ((XVisualInfo*)d->vi)->screen;
       
   699             }
       
   700             XFree(configs);
       
   701         } else {
       
   702             qWarning("QGLContext::chooseContext(): OpenGL %d.%d is not supported", major, minor);
       
   703         }
       
   704 
       
   705         if (tmpContext)
       
   706             delete tmpContext;
       
   707     }
       
   708 #else
       
   709     Q_UNUSED(major);
       
   710     Q_UNUSED(minor);
       
   711     Q_UNUSED(profile);
       
   712 #endif
       
   713 
       
   714     if (!d->cx && shareContext) {
   498         d->cx = glXCreateContext(disp, (XVisualInfo *)d->vi,
   715         d->cx = glXCreateContext(disp, (XVisualInfo *)d->vi,
   499                                (GLXContext)shareContext->d_func()->cx, direct);
   716                                (GLXContext)shareContext->d_func()->cx, direct);
   500         d->screen = ((XVisualInfo*)d->vi)->screen;
   717         d->screen = ((XVisualInfo*)d->vi)->screen;
   501         if (d->cx) {
       
   502             QGLContext *share = const_cast<QGLContext *>(shareContext);
       
   503             d->sharing = true;
       
   504             share->d_func()->sharing = true;
       
   505         }
       
   506     }
   718     }
   507     if (!d->cx) {
   719     if (!d->cx) {
   508         d->cx = glXCreateContext(disp, (XVisualInfo *)d->vi, NULL, direct);
   720         d->cx = glXCreateContext(disp, (XVisualInfo *)d->vi, NULL, direct);
   509         d->screen = ((XVisualInfo*)d->vi)->screen;
   721         d->screen = ((XVisualInfo*)d->vi)->screen;
   510     }
   722         shareContext = 0;
       
   723     }
       
   724 
       
   725     if (shareContext && d->cx) {
       
   726         QGLContext *share = const_cast<QGLContext *>(shareContext);
       
   727         d->sharing = true;
       
   728         share->d_func()->sharing = true;
       
   729     }
       
   730 
   511     if (!d->cx)
   731     if (!d->cx)
   512         return false;
   732         return false;
   513     d->glFormat.setDirectRendering(glXIsDirect(disp, (GLXContext)d->cx));
   733     d->glFormat.setDirectRendering(glXIsDirect(disp, (GLXContext)d->cx));
   514     if (deviceIsPixmap()) {
   734     if (deviceIsPixmap()) {
   515 #if defined(GLX_MESA_pixmap_colormap) && defined(QGL_USE_MESA_EXT)
   735 #if defined(GLX_MESA_pixmap_colormap) && defined(QGL_USE_MESA_EXT)
   604  */
   824  */
   605 void *QGLContext::tryVisual(const QGLFormat& f, int bufDepth)
   825 void *QGLContext::tryVisual(const QGLFormat& f, int bufDepth)
   606 {
   826 {
   607     Q_D(QGLContext);
   827     Q_D(QGLContext);
   608     int spec[45];
   828     int spec[45];
   609     int i = 0;
       
   610     spec[i++] = GLX_LEVEL;
       
   611     spec[i++] = f.plane();
       
   612     const QX11Info *xinfo = qt_x11Info(d->paintDevice);
   829     const QX11Info *xinfo = qt_x11Info(d->paintDevice);
   613     bool useFBConfig = false;
   830     bool useFBConfig = buildSpec(spec, f, d->paintDevice, bufDepth, false);
   614 
       
   615 #if defined(GLX_VERSION_1_3) && !defined(QT_NO_XRENDER) && !defined(Q_OS_HPUX)
       
   616     /*
       
   617       HPUX defines GLX_VERSION_1_3 but does not implement the corresponding functions.
       
   618       Specifically glXChooseFBConfig and glXGetVisualFromFBConfig are not implemented.
       
   619      */
       
   620     QWidget* widget = 0;
       
   621     if (d->paintDevice->devType() == QInternal::Widget)
       
   622         widget = static_cast<QWidget*>(d->paintDevice);
       
   623 
       
   624     // Only use glXChooseFBConfig for widgets if we're trying to get an ARGB visual
       
   625     if (widget && widget->testAttribute(Qt::WA_TranslucentBackground) && X11->use_xrender)
       
   626         useFBConfig = true;
       
   627 #endif
       
   628 
       
   629 #if defined(GLX_VERSION_1_1) && defined(GLX_EXT_visual_info)
       
   630     static bool useTranspExt = false;
       
   631     static bool useTranspExtChecked = false;
       
   632     if (f.plane() && !useTranspExtChecked && d->paintDevice) {
       
   633         QGLExtensionMatcher extensions(glXQueryExtensionsString(xinfo->display(), xinfo->screen()));
       
   634         useTranspExt = extensions.match("GLX_EXT_visual_info");
       
   635         //# (A bit simplistic; that could theoretically be a substring)
       
   636         if (useTranspExt) {
       
   637             QByteArray cstr(glXGetClientString(xinfo->display(), GLX_VENDOR));
       
   638             useTranspExt = !cstr.contains("Xi Graphics"); // bug workaround
       
   639             if (useTranspExt) {
       
   640                 // bug workaround - some systems (eg. FireGL) refuses to return an overlay
       
   641                 // visual if the GLX_TRANSPARENT_TYPE_EXT attribute is specified, even if
       
   642                 // the implementation supports transparent overlays
       
   643                 int tmpSpec[] = { GLX_LEVEL, f.plane(), GLX_TRANSPARENT_TYPE_EXT,
       
   644                                   f.rgba() ? GLX_TRANSPARENT_RGB_EXT : GLX_TRANSPARENT_INDEX_EXT,
       
   645                                   XNone };
       
   646                 XVisualInfo * vinf = glXChooseVisual(xinfo->display(), xinfo->screen(), tmpSpec);
       
   647                 if (!vinf) {
       
   648                     useTranspExt = false;
       
   649                 }
       
   650             }
       
   651         }
       
   652 
       
   653         useTranspExtChecked = true;
       
   654     }
       
   655     if (f.plane() && useTranspExt && !useFBConfig) {
       
   656         // Required to avoid non-transparent overlay visual(!) on some systems
       
   657         spec[i++] = GLX_TRANSPARENT_TYPE_EXT;
       
   658         spec[i++] = f.rgba() ? GLX_TRANSPARENT_RGB_EXT : GLX_TRANSPARENT_INDEX_EXT;
       
   659     }
       
   660 #endif
       
   661 
       
   662 #if defined(GLX_VERSION_1_3)  && !defined(Q_OS_HPUX)
       
   663     // GLX_RENDER_TYPE is only in glx >=1.3
       
   664     if (useFBConfig) {
       
   665         spec[i++] = GLX_RENDER_TYPE;
       
   666         spec[i++] = f.rgba() ? GLX_RGBA_BIT : GLX_COLOR_INDEX_BIT;
       
   667     }
       
   668 #endif
       
   669 
       
   670     if (f.doubleBuffer())
       
   671         spec[i++] = GLX_DOUBLEBUFFER;
       
   672         if (useFBConfig)
       
   673             spec[i++] = True;
       
   674     if (f.depth()) {
       
   675         spec[i++] = GLX_DEPTH_SIZE;
       
   676         spec[i++] = f.depthBufferSize() == -1 ? 1 : f.depthBufferSize();
       
   677     }
       
   678     if (f.stereo()) {
       
   679         spec[i++] = GLX_STEREO;
       
   680         if (useFBConfig)
       
   681             spec[i++] = True;
       
   682     }
       
   683     if (f.stencil()) {
       
   684         spec[i++] = GLX_STENCIL_SIZE;
       
   685         spec[i++] = f.stencilBufferSize() == -1 ? 1 : f.stencilBufferSize();
       
   686     }
       
   687     if (f.rgba()) {
       
   688         if (!useFBConfig)
       
   689             spec[i++] = GLX_RGBA;
       
   690         spec[i++] = GLX_RED_SIZE;
       
   691         spec[i++] = f.redBufferSize() == -1 ? 1 : f.redBufferSize();
       
   692         spec[i++] = GLX_GREEN_SIZE;
       
   693         spec[i++] = f.greenBufferSize() == -1 ? 1 : f.greenBufferSize();
       
   694         spec[i++] = GLX_BLUE_SIZE;
       
   695         spec[i++] = f.blueBufferSize() == -1 ? 1 : f.blueBufferSize();
       
   696         if (f.alpha()) {
       
   697             spec[i++] = GLX_ALPHA_SIZE;
       
   698             spec[i++] = f.alphaBufferSize() == -1 ? 1 : f.alphaBufferSize();
       
   699         }
       
   700         if (f.accum()) {
       
   701             spec[i++] = GLX_ACCUM_RED_SIZE;
       
   702             spec[i++] = f.accumBufferSize() == -1 ? 1 : f.accumBufferSize();
       
   703             spec[i++] = GLX_ACCUM_GREEN_SIZE;
       
   704             spec[i++] = f.accumBufferSize() == -1 ? 1 : f.accumBufferSize();
       
   705             spec[i++] = GLX_ACCUM_BLUE_SIZE;
       
   706             spec[i++] = f.accumBufferSize() == -1 ? 1 : f.accumBufferSize();
       
   707             if (f.alpha()) {
       
   708                 spec[i++] = GLX_ACCUM_ALPHA_SIZE;
       
   709                 spec[i++] = f.accumBufferSize() == -1 ? 1 : f.accumBufferSize();
       
   710             }
       
   711         }
       
   712     } else {
       
   713         spec[i++] = GLX_BUFFER_SIZE;
       
   714         spec[i++] = bufDepth;
       
   715     }
       
   716 
       
   717     if (f.sampleBuffers()) {
       
   718         spec[i++] = GLX_SAMPLE_BUFFERS_ARB;
       
   719         spec[i++] = 1;
       
   720         spec[i++] = GLX_SAMPLES_ARB;
       
   721         spec[i++] = f.samples() == -1 ? 4 : f.samples();
       
   722     }
       
   723 
       
   724 #if defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX)
       
   725     if (useFBConfig) {
       
   726         spec[i++] = GLX_DRAWABLE_TYPE;
       
   727         switch(d->paintDevice->devType()) {
       
   728         case QInternal::Pixmap:
       
   729             spec[i++] = GLX_PIXMAP_BIT;
       
   730             break;
       
   731         case QInternal::Pbuffer:
       
   732             spec[i++] = GLX_PBUFFER_BIT;
       
   733             break;
       
   734         default:
       
   735             qWarning("QGLContext: Unknown paint device type %d", d->paintDevice->devType());
       
   736             // Fall-through & assume it's a window
       
   737         case QInternal::Widget:
       
   738             spec[i++] = GLX_WINDOW_BIT;
       
   739             break;
       
   740         };
       
   741     }
       
   742 #endif
       
   743 
       
   744     spec[i] = XNone;
       
   745 
       
   746 
   831 
   747     XVisualInfo* chosenVisualInfo = 0;
   832     XVisualInfo* chosenVisualInfo = 0;
   748 
   833 
   749 #if defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX)
   834 #if defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX)
   750     while (useFBConfig) {
   835     while (useFBConfig) {
   753         configs = glXChooseFBConfig(xinfo->display(), xinfo->screen(), spec, &configCount);
   838         configs = glXChooseFBConfig(xinfo->display(), xinfo->screen(), spec, &configCount);
   754 
   839 
   755         if (!configs)
   840         if (!configs)
   756             break; // fallback to trying glXChooseVisual
   841             break; // fallback to trying glXChooseVisual
   757 
   842 
   758         for (i = 0; i < configCount; ++i) {
   843         for (int i = 0; i < configCount; ++i) {
   759             XVisualInfo* vi;
   844             XVisualInfo* vi;
   760             vi = glXGetVisualFromFBConfig(xinfo->display(), configs[i]);
   845             vi = glXGetVisualFromFBConfig(xinfo->display(), configs[i]);
   761             if (!vi)
   846             if (!vi)
   762                 continue;
   847                 continue;
   763 
   848 
   841     if (d->paintDevice->devType() == QInternal::Pixmap) {
   926     if (d->paintDevice->devType() == QInternal::Pixmap) {
   842         ok = glXMakeCurrent(xinfo->display(), (GLXPixmap)d->gpm, (GLXContext)d->cx);
   927         ok = glXMakeCurrent(xinfo->display(), (GLXPixmap)d->gpm, (GLXContext)d->cx);
   843     } else if (d->paintDevice->devType() == QInternal::Pbuffer) {
   928     } else if (d->paintDevice->devType() == QInternal::Pbuffer) {
   844         ok = glXMakeCurrent(xinfo->display(), (GLXPbuffer)d->pbuf, (GLXContext)d->cx);
   929         ok = glXMakeCurrent(xinfo->display(), (GLXPbuffer)d->pbuf, (GLXContext)d->cx);
   845     } else if (d->paintDevice->devType() == QInternal::Widget) {
   930     } else if (d->paintDevice->devType() == QInternal::Widget) {
   846         ok = glXMakeCurrent(xinfo->display(), ((QWidget *)d->paintDevice)->winId(), (GLXContext)d->cx);
   931         ok = glXMakeCurrent(xinfo->display(), ((QWidget *)d->paintDevice)->internalWinId(), (GLXContext)d->cx);
   847     }
   932     }
   848     if (!ok)
   933     if (!ok)
   849         qWarning("QGLContext::makeCurrent(): Failed.");
   934         qWarning("QGLContext::makeCurrent(): Failed.");
   850 
   935 
   851     if (ok)
   936     if (ok)
  1771     glGenTextures(1, &textureId);
  1856     glGenTextures(1, &textureId);
  1772     glBindTexture(GL_TEXTURE_2D, textureId);
  1857     glBindTexture(GL_TEXTURE_2D, textureId);
  1773     glXBindTexImageEXT(x11Info.display(), (GLXPixmap)pixmapData->gl_surface, GLX_FRONT_LEFT_EXT, 0);
  1858     glXBindTexImageEXT(x11Info.display(), (GLXPixmap)pixmapData->gl_surface, GLX_FRONT_LEFT_EXT, 0);
  1774 
  1859 
  1775     glBindTexture(GL_TEXTURE_2D, textureId);
  1860     glBindTexture(GL_TEXTURE_2D, textureId);
       
  1861     GLuint filtering = (options & QGLContext::LinearFilteringBindOption) ? GL_LINEAR : GL_NEAREST;
       
  1862     glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MIN_FILTER, filtering);
       
  1863     glTexParameterf(GL_TEXTURE_2D, GL_TEXTURE_MAG_FILTER, filtering);
  1776 
  1864 
  1777     if (!((hasAlpha && RGBAConfigInverted) || (!hasAlpha && RGBConfigInverted)))
  1865     if (!((hasAlpha && RGBAConfigInverted) || (!hasAlpha && RGBConfigInverted)))
  1778         options &= ~QGLContext::InvertedYBindOption;
  1866         options &= ~QGLContext::InvertedYBindOption;
  1779 
  1867 
  1780     QGLTexture *texture = new QGLTexture(q, textureId, GL_TEXTURE_2D, options);
  1868     QGLTexture *texture = new QGLTexture(q, textureId, GL_TEXTURE_2D, options);