Ignore:
Timestamp:
Mar 8, 2010, 12:52:58 PM (15 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.6.2 sources.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/opengl/qgl_x11.cpp

    r561 r651  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    550550    bool triedSample = false;
    551551    if (fmt.sampleBuffers())
    552         fmt.setSampleBuffers(QGLExtensions::glExtensions & QGLExtensions::SampleBuffers);
     552        fmt.setSampleBuffers(QGLExtensions::glExtensions() & QGLExtensions::SampleBuffers);
    553553    while(!fail && !(vis = tryVisual(fmt, bufDepths[i]))) {
    554554        if (!fmt.rgba() && bufDepths[i] > 1) {
     
    826826    d->transpColor = QColor();
    827827    d->initDone = false;
    828     qgl_share_reg()->removeShare(this);
     828    QGLContextGroup::removeShare(this);
    829829}
    830830
     
    11331133}
    11341134
     1135/*
     1136    QGLTemporaryContext implementation
     1137*/
     1138
     1139class QGLTemporaryContextPrivate {
     1140public:
     1141    bool initialized;
     1142    Window drawable;
     1143    GLXContext context;
     1144    GLXDrawable oldDrawable;
     1145    GLXContext oldContext;
     1146};
     1147
     1148QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *)
     1149    : d(new QGLTemporaryContextPrivate)
     1150{
     1151    d->initialized = false;
     1152    d->oldDrawable = 0;
     1153    d->oldContext = 0;
     1154    int screen = 0;
     1155
     1156    int attribs[] = {GLX_RGBA, XNone};
     1157    XVisualInfo *vi = glXChooseVisual(X11->display, screen, attribs);
     1158    if (!vi) {
     1159        qWarning("QGLTempContext: No GL capable X visuals available.");
     1160        return;
     1161    }
     1162
     1163    int useGL;
     1164    glXGetConfig(X11->display, vi, GLX_USE_GL, &useGL);
     1165    if (!useGL) {
     1166        XFree(vi);
     1167        return;
     1168    }
     1169
     1170    d->oldDrawable = glXGetCurrentDrawable();
     1171    d->oldContext = glXGetCurrentContext();
     1172
     1173    XSetWindowAttributes a;
     1174    a.colormap = qt_gl_choose_cmap(X11->display, vi);
     1175    d->drawable = XCreateWindow(X11->display, RootWindow(X11->display, screen),
     1176                                0, 0, 1, 1, 0,
     1177                                vi->depth, InputOutput, vi->visual,
     1178                                CWColormap, &a);
     1179    d->context = glXCreateContext(X11->display, vi, 0, True);
     1180    if (d->context && glXMakeCurrent(X11->display, d->drawable, d->context)) {
     1181        d->initialized = true;
     1182    } else {
     1183        qWarning("QGLTempContext: Unable to create GL context.");
     1184        XDestroyWindow(X11->display, d->drawable);
     1185    }
     1186    XFree(vi);
     1187}
     1188
     1189QGLTemporaryContext::~QGLTemporaryContext()
     1190{
     1191    if (d->initialized) {
     1192        glXMakeCurrent(X11->display, 0, 0);
     1193        glXDestroyContext(X11->display, d->context);
     1194        XDestroyWindow(X11->display, d->drawable);
     1195    }
     1196    if (d->oldDrawable && d->oldContext)
     1197        glXMakeCurrent(X11->display, d->oldDrawable, d->oldContext);
     1198}
     1199
    11351200/*****************************************************************************
    11361201  QGLOverlayWidget (Internal overlay class for X11)
     
    15671632}
    15681633
    1569 void QGLExtensions::init()
    1570 {
    1571     static bool init_done = false;
    1572 
    1573     if (init_done)
    1574         return;
    1575     init_done = true;
    1576 
    1577     QGLWidget dmy;
    1578     dmy.makeCurrent();
    1579     init_extensions();
    1580 
    1581     // nvidia 9x.xx unix drivers contain a bug which requires us to call glFinish before releasing an fbo
    1582     // to avoid painting artifacts
    1583     const QByteArray versionString(reinterpret_cast<const char*>(glGetString(GL_VERSION)));
    1584     const int pos = versionString.indexOf("NVIDIA");
    1585     if (pos >= 0) {
    1586         const float nvidiaDriverVersion = versionString.mid(pos + strlen("NVIDIA")).toFloat();
    1587         nvidiaFboNeedsFinish = nvidiaDriverVersion >= 90.0 && nvidiaDriverVersion < 100.0;
    1588     }
    1589 }
    1590 
    15911634// Solaris defines glXBindTexImageEXT as part of the GL library
    15921635#if defined(GLX_VERSION_1_3) && !defined(Q_OS_HPUX)
     
    16041647
    16051648        // Check to see if we have NPOT texture support
    1606         if ( !(QGLExtensions::glExtensions & QGLExtensions::NPOTTextures) &&
     1649        if ( !(QGLExtensions::glExtensions() & QGLExtensions::NPOTTextures) &&
    16071650             !(QGLFormat::openGLVersionFlags() & QGLFormat::OpenGL_Version_2_0))
    16081651        {
    16091652            return false; // Can't use TFP without NPOT
    16101653        }
     1654
    16111655        const QX11Info *xinfo = qt_x11Info(paintDevice);
    1612         QGLExtensionMatcher extensions(glXQueryExtensionsString(xinfo->display(), xinfo->screen()));
     1656        Display *display = xinfo ? xinfo->display() : X11->display;
     1657        int screen = xinfo ? xinfo->screen() : X11->defaultScreen;
     1658
     1659        QGLExtensionMatcher extensions(glXQueryExtensionsString(display, screen));
    16131660        if (extensions.match("GLX_EXT_texture_from_pixmap")) {
    16141661            glXBindTexImageEXT = (qt_glXBindTexImageEXT) qglx_getProcAddress("glXBindTexImageEXT");
Note: See TracChangeset for help on using the changeset viewer.