src/opengl/qgl_qws.cpp
branchRCL_3
changeset 4 3b1da2848fc7
parent 3 41300fa6a67c
child 7 3f74d0d4af4c
equal deleted inserted replaced
3:41300fa6a67c 4:3b1da2848fc7
     1 /****************************************************************************
     1 /****************************************************************************
     2 **
     2 **
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
     3 ** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies).
     4 ** All rights reserved.
     4 ** All rights reserved.
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
     6 **
     6 **
     7 ** This file is part of the QtOpenGL module of the Qt Toolkit.
     7 ** This file is part of the QtOpenGL module of the Qt Toolkit.
     8 **
     8 **
    79     }
    79     }
    80     if (screen->classId() == QScreen::GLClass)
    80     if (screen->classId() == QScreen::GLClass)
    81         return static_cast<QGLScreen *>(screen);
    81         return static_cast<QGLScreen *>(screen);
    82     else
    82     else
    83         return 0;
    83         return 0;
       
    84 }
       
    85 
       
    86 /*
       
    87     QGLTemporaryContext implementation
       
    88 */
       
    89 
       
    90 class QGLTemporaryContextPrivate
       
    91 {
       
    92 public:
       
    93     QGLWidget *widget;
       
    94 };
       
    95 
       
    96 QGLTemporaryContext::QGLTemporaryContext(bool, QWidget *)
       
    97     : d(new QGLTemporaryContextPrivate)
       
    98 {
       
    99     d->widget = new QGLWidget;
       
   100     d->widget->makeCurrent();
       
   101 }
       
   102 
       
   103 QGLTemporaryContext::~QGLTemporaryContext()
       
   104 {
       
   105     delete d->widget;
    84 }
   106 }
    85 
   107 
    86 /*****************************************************************************
   108 /*****************************************************************************
    87   QOpenGL debug facilities
   109   QOpenGL debug facilities
    88  *****************************************************************************/
   110  *****************************************************************************/
   309 
   331 
   310 void QGLWidget::setColormap(const QGLColormap &)
   332 void QGLWidget::setColormap(const QGLColormap &)
   311 {
   333 {
   312 }
   334 }
   313 
   335 
   314 void QGLExtensions::init()
       
   315 {
       
   316     static bool init_done = false;
       
   317 
       
   318     if (init_done)
       
   319         return;
       
   320     init_done = true;
       
   321 
       
   322     // We need a context current to initialize the extensions,
       
   323     // but getting a valid EGLNativeWindowType this early can be
       
   324     // problematic under QWS.  So use a pbuffer instead.
       
   325     //
       
   326     // Unfortunately OpenGL/ES 2.0 systems don't normally
       
   327     // support pbuffers, so we have no choice but to try
       
   328     // our luck with a window on those systems.
       
   329 #if defined(QT_OPENGL_ES_2)
       
   330     QGLWidget tmpWidget;
       
   331     tmpWidget.makeCurrent();
       
   332 
       
   333     init_extensions();
       
   334 
       
   335     tmpWidget.doneCurrent();
       
   336 #else
       
   337     QGLPixelBuffer pbuffer(16, 16);
       
   338     pbuffer.makeCurrent();
       
   339 
       
   340     init_extensions();
       
   341 
       
   342     pbuffer.doneCurrent();
       
   343 #endif
       
   344 }
       
   345 
       
   346 QT_END_NAMESPACE
   336 QT_END_NAMESPACE