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_win.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)
     
    552552    QVarLengthArray<int> iValues(40);
    553553    int i = 0;
    554     bool has_sample_buffers = QGLExtensions::glExtensions & QGLExtensions::SampleBuffers;
     554    bool has_sample_buffers = QGLExtensions::glExtensions() & QGLExtensions::SampleBuffers;
    555555
    556556    iAttributes[i++] = WGL_DOUBLE_BUFFER_ARB; // 0
     
    629629
    630630/*
    631    Creates a temporary GL context and makes it current
    632    - cleans up when the object is destructed.
     631    QGLTemporaryContext implementation
    633632*/
    634633
    635634Q_GUI_EXPORT const QString qt_getRegisteredWndClass();
    636635
    637 class QGLTempContext
     636class QGLTemporaryContextPrivate
    638637{
    639638public:
    640     QGLTempContext(bool directRendering, QWidget *parent = 0)
    641     {
    642         QString windowClassName = qt_getRegisteredWndClass();
    643         if (parent && !parent->internalWinId())
    644             parent = parent->nativeParentWidget();
    645 
    646         dmy_id = CreateWindow((const wchar_t *)windowClassName.utf16(),
    647                               0, 0, 0, 0, 1, 1,
    648                               parent ? parent->winId() : 0, 0, qWinAppInst(), 0);
    649 
    650         dmy_pdc = GetDC(dmy_id);
    651         PIXELFORMATDESCRIPTOR dmy_pfd;
    652         memset(&dmy_pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
    653         dmy_pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
    654         dmy_pfd.nVersion = 1;
    655         dmy_pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW;
    656         dmy_pfd.iPixelType = PFD_TYPE_RGBA;
    657         if (!directRendering)
    658             dmy_pfd.dwFlags |= PFD_GENERIC_FORMAT;
    659 
    660         int dmy_pf = ChoosePixelFormat(dmy_pdc, &dmy_pfd);
    661         SetPixelFormat(dmy_pdc, dmy_pf, &dmy_pfd);
    662         dmy_rc = wglCreateContext(dmy_pdc);
    663         old_dc = wglGetCurrentDC();
    664         old_context = wglGetCurrentContext();
    665         wglMakeCurrent(dmy_pdc, dmy_rc);
    666     }
    667 
    668     ~QGLTempContext() {
    669         wglMakeCurrent(dmy_pdc, 0);
    670         wglDeleteContext(dmy_rc);
    671         ReleaseDC(dmy_id, dmy_pdc);
    672         DestroyWindow(dmy_id);
    673         if (old_dc && old_context)
    674             wglMakeCurrent(old_dc, old_context);
    675     }
    676 
    677639    HDC dmy_pdc;
    678640    HGLRC dmy_rc;
     
    681643    WId dmy_id;
    682644};
     645
     646QGLTemporaryContext::QGLTemporaryContext(bool directRendering, QWidget *parent)
     647    : d(new QGLTemporaryContextPrivate)
     648{
     649    QString windowClassName = qt_getRegisteredWndClass();
     650    if (parent && !parent->internalWinId())
     651        parent = parent->nativeParentWidget();
     652
     653    d->dmy_id = CreateWindow((const wchar_t *)windowClassName.utf16(),
     654                             0, 0, 0, 0, 1, 1,
     655                             parent ? parent->winId() : 0, 0, qWinAppInst(), 0);
     656
     657    d->dmy_pdc = GetDC(d->dmy_id);
     658    PIXELFORMATDESCRIPTOR dmy_pfd;
     659    memset(&dmy_pfd, 0, sizeof(PIXELFORMATDESCRIPTOR));
     660    dmy_pfd.nSize = sizeof(PIXELFORMATDESCRIPTOR);
     661    dmy_pfd.nVersion = 1;
     662    dmy_pfd.dwFlags = PFD_SUPPORT_OPENGL | PFD_DRAW_TO_WINDOW;
     663    dmy_pfd.iPixelType = PFD_TYPE_RGBA;
     664    if (!directRendering)
     665        dmy_pfd.dwFlags |= PFD_GENERIC_FORMAT;
     666
     667    int dmy_pf = ChoosePixelFormat(d->dmy_pdc, &dmy_pfd);
     668    SetPixelFormat(d->dmy_pdc, dmy_pf, &dmy_pfd);
     669    d->dmy_rc = wglCreateContext(d->dmy_pdc);
     670    d->old_dc = wglGetCurrentDC();
     671    d->old_context = wglGetCurrentContext();
     672    wglMakeCurrent(d->dmy_pdc, d->dmy_rc);
     673}
     674
     675QGLTemporaryContext::~QGLTemporaryContext()
     676{
     677    wglMakeCurrent(d->dmy_pdc, 0);
     678    wglDeleteContext(d->dmy_rc);
     679    ReleaseDC(d->dmy_id, d->dmy_pdc);
     680    DestroyWindow(d->dmy_id);
     681    if (d->old_dc && d->old_context)
     682        wglMakeCurrent(d->old_dc, d->old_context);
     683}
    683684
    684685bool QGLContext::chooseContext(const QGLContext* shareContext)
     
    722723    }
    723724
    724     // NB! the QGLTempContext object is needed for the
     725    // NB! the QGLTemporaryContext object is needed for the
    725726    // wglGetProcAddress() calls to succeed and are absolutely
    726727    // necessary - don't remove!
    727     QGLTempContext tmp_ctx(d->glFormat.directRendering(), widget);
     728    QGLTemporaryContext tmp_ctx(d->glFormat.directRendering(), widget);
    728729
    729730    if (!myDc) {
     
    966967        }
    967968        int si = 0;
    968         bool trySampleBuffers = QGLExtensions::glExtensions & QGLExtensions::SampleBuffers;
     969        bool trySampleBuffers = QGLExtensions::glExtensions() & QGLExtensions::SampleBuffers;
    969970        if (trySampleBuffers && d->glFormat.sampleBuffers()) {
    970971            iAttributes[i++] = WGL_SAMPLE_BUFFERS_ARB;
     
    11461147    d->cmap = 0;
    11471148    d->initDone = false;
    1148     qgl_share_reg()->removeShare(this);
     1149    QGLContextGroup::removeShare(this);
    11491150}
    11501151
     
    14721473}
    14731474
    1474 void QGLExtensions::init()
    1475 {
    1476     static bool init_done = false;
    1477 
    1478     if (init_done)
    1479         return;
    1480     init_done = true;
    1481     QGLTempContext temp_ctx(QGLFormat::defaultFormat().directRendering());
    1482     init_extensions();
    1483 }
    1484 
    14851475QT_END_NAMESPACE
Note: See TracChangeset for help on using the changeset viewer.