Ignore:
Timestamp:
May 5, 2011, 5:36:53 AM (14 years ago)
Author:
Dmitry A. Kuminov
Message:

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

Location:
trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • trunk

  • trunk/src/opengl/qglpixelbuffer_win.cpp

    r651 r846  
    11/****************************************************************************
    22**
    3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
    44** All rights reserved.
    55** Contact: Nokia Corporation (qt-info@nokia.com)
     
    168168#endif
    169169
     170#ifndef WGL_ARB_multisample
     171#define WGL_SAMPLE_BUFFERS_ARB         0x2041
     172#define WGL_SAMPLES_ARB                0x2042
     173#endif
     174
     175#ifndef GL_SAMPLES_ARB
     176#define GL_SAMPLES_ARB 0x80A9
     177#endif
     178
    170179QGLFormat pfiToQGLFormat(HDC hdc, int pfi);
    171180
     
    227236        attribs[i++] = TRUE;
    228237    }
    229     // sample buffers doesn't work in conjunction with the render_texture extension
    230     // so igonre that for now
    231     // if (f.sampleBuffers()) {
    232     //     attribs[i++] = WGL_SAMPLE_BUFFERS_ARB;
    233     //     attribs[i++] = 1;
    234     //     attribs[i++] = WGL_SAMPLES_ARB;
    235     //     attribs[i++] = f.samples() == -1 ? 16 : f.samples();
    236     // }
     238    if (f.sampleBuffers()) {
     239        attribs[i++] = WGL_SAMPLE_BUFFERS_ARB;
     240        attribs[i++] = 1;
     241        attribs[i++] = WGL_SAMPLES_ARB;
     242        attribs[i++] = f.samples() == -1 ? 16 : f.samples();
     243    }
    237244    attribs[i] = 0;
    238245}
     
    240247bool QGLPixelBufferPrivate::init(const QSize &size, const QGLFormat &f, QGLWidget *shareWidget)
    241248{
    242     QGLWidget dmy;
    243     dmy.makeCurrent(); // needed for wglGetProcAddress() to succeed
     249    QGLTemporaryContext tempContext;
    244250
    245251    PFNWGLCREATEPBUFFERARBPROC wglCreatePbufferARB =
     
    255261        return false;
    256262
    257     dc = GetDC(dmy.winId());
     263    dc = wglGetCurrentDC();
    258264    Q_ASSERT(dc);
    259 
    260     PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB =
    261         (PFNWGLGETEXTENSIONSSTRINGARBPROC) wglGetProcAddress("wglGetExtensionsStringARB");
    262 
    263     if (wglGetExtensionsStringARB) {
    264         QString extensions(QLatin1String(wglGetExtensionsStringARB(dc)));
    265         has_render_texture = extensions.contains(QLatin1String("WGL_ARB_render_texture"));
     265    has_render_texture = false;
     266
     267    // sample buffers doesn't work in conjunction with the render_texture extension
     268    if (!f.sampleBuffers()) {
     269        PFNWGLGETEXTENSIONSSTRINGARBPROC wglGetExtensionsStringARB =
     270                (PFNWGLGETEXTENSIONSSTRINGARBPROC) wglGetProcAddress("wglGetExtensionsStringARB");
     271
     272        if (wglGetExtensionsStringARB) {
     273            QString extensions(QLatin1String(wglGetExtensionsStringARB(dc)));
     274            has_render_texture = extensions.contains(QLatin1String("WGL_ARB_render_texture"));
     275        }
    266276    }
    267277
     
    285295    if (num_formats == 0) {
    286296        qWarning("QGLPixelBuffer: Unable to find a pixel format with pbuffer  - giving up.");
    287         ReleaseDC(dmy.winId(), dc);
    288297        return false;
    289298    }
     
    298307    pbuf = wglCreatePbufferARB(dc, pixel_format, size.width(), size.height(),
    299308                               has_render_texture ? pb_attribs : 0);
    300     if(!pbuf) {
     309    if (!pbuf) {
    301310        // try again without the render_texture extension
    302311        pbuf = wglCreatePbufferARB(dc, pixel_format, size.width(), size.height(), 0);
     
    304313        if (!pbuf) {
    305314            qWarning("QGLPixelBuffer: Unable to create pbuffer [w=%d, h=%d] - giving up.", size.width(), size.height());
    306             ReleaseDC(dmy.winId(), dc);
    307315            return false;
    308316        }
    309317    }
    310318
    311     ReleaseDC(dmy.winId(), dc);
    312319    dc = wglGetPbufferDCARB(pbuf);
    313320    ctx = wglCreateContext(dc);
    314 
    315321    if (!dc || !ctx) {
    316322        qWarning("QGLPixelBuffer: Unable to create pbuffer context - giving up.");
    317323        return false;
    318324    }
     325
     326    // Explicitly disable the render_texture extension if we have a
     327    // multi-sampled pbuffer context. This seems to be a problem only with
     328    // ATI cards if multi-sampling is forced globally in the driver.
     329    wglMakeCurrent(dc, ctx);
     330    GLint samples = 0;
     331    glGetIntegerv(GL_SAMPLES_ARB, &samples);
     332    if (has_render_texture && samples != 0)
     333        has_render_texture = false;
    319334
    320335    HGLRC share_ctx = shareWidget ? shareWidget->d_func()->glcx->d_func()->rc : 0;
Note: See TracChangeset for help on using the changeset viewer.