src/opengl/qglscreen_qws.cpp
changeset 0 1918ee327afb
child 4 3b1da2848fc7
equal deleted inserted replaced
-1:000000000000 0:1918ee327afb
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
       
     4 ** All rights reserved.
       
     5 ** Contact: Nokia Corporation (qt-info@nokia.com)
       
     6 **
       
     7 ** This file is part of the QtOpenGL module of the Qt Toolkit.
       
     8 **
       
     9 ** $QT_BEGIN_LICENSE:LGPL$
       
    10 ** No Commercial Usage
       
    11 ** This file contains pre-release code and may not be distributed.
       
    12 ** You may use this file in accordance with the terms and conditions
       
    13 ** contained in the Technology Preview License Agreement accompanying
       
    14 ** this package.
       
    15 **
       
    16 ** GNU Lesser General Public License Usage
       
    17 ** Alternatively, this file may be used under the terms of the GNU Lesser
       
    18 ** General Public License version 2.1 as published by the Free Software
       
    19 ** Foundation and appearing in the file LICENSE.LGPL included in the
       
    20 ** packaging of this file.  Please review the following information to
       
    21 ** ensure the GNU Lesser General Public License version 2.1 requirements
       
    22 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
       
    23 **
       
    24 ** In addition, as a special exception, Nokia gives you certain additional
       
    25 ** rights.  These rights are described in the Nokia Qt LGPL Exception
       
    26 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
       
    27 **
       
    28 ** If you have questions regarding the use of this file, please contact
       
    29 ** Nokia at qt-info@nokia.com.
       
    30 **
       
    31 **
       
    32 **
       
    33 **
       
    34 **
       
    35 **
       
    36 **
       
    37 **
       
    38 ** $QT_END_LICENSE$
       
    39 **
       
    40 ****************************************************************************/
       
    41 
       
    42 #include <QGLScreen>
       
    43 #include <QGLContext>
       
    44 #include <QGLWidget>
       
    45 #include "private/qglwindowsurface_qws_p.h"
       
    46 
       
    47 QT_BEGIN_NAMESPACE
       
    48 
       
    49 class QGLScreenPrivate
       
    50 {
       
    51 public:
       
    52     QGLScreen::Options options;
       
    53     QGLScreenSurfaceFunctions *functions;
       
    54 };
       
    55 
       
    56 /*!
       
    57   \internal
       
    58   \preliminary
       
    59   \class QGLScreen
       
    60 
       
    61   \brief This class encapsulates an OpenGL screen driver.
       
    62 */
       
    63 
       
    64 QGLScreen::QGLScreen(int displayId)
       
    65     : QScreen(displayId, GLClass), d_ptr(new QGLScreenPrivate)
       
    66 {
       
    67     d_ptr->options = NoOptions;
       
    68     d_ptr->functions = new QGLScreenSurfaceFunctions();
       
    69 }
       
    70 
       
    71 QGLScreen::~QGLScreen()
       
    72 {
       
    73     delete d_ptr->functions;
       
    74     delete d_ptr;
       
    75 }
       
    76 
       
    77 /*!
       
    78     \since 4.3
       
    79     \obsolete
       
    80 
       
    81     Initializes the \a context and sets up the QGLWindowSurface of the
       
    82     QWidget of \a context based on the parameters of \a context and
       
    83     based on its own requirements.  The format() of \a context needs
       
    84     to be updated with the actual parameters of the OpenGLES drawable
       
    85     that was set up.
       
    86 
       
    87     \a shareContext is used in the same way as for QGLContext. It is
       
    88     the context with which \a context shares display lists and texture
       
    89     ids etc. The window surface must be set up so that this sharing
       
    90     works.
       
    91 
       
    92     Returns true in case of success and false if it is not possible to
       
    93     create the necessary OpenGLES drawable/context.
       
    94 
       
    95     Since 4.4.2, this function will be not be called if options()
       
    96     indicates that a native window or pixmap drawable can be created
       
    97     via the functions in the surfaceFunctions() object.
       
    98 
       
    99     This function is obsolete in Qt 4.5 and higher.  Use surfaceFunctions()
       
   100     instead.
       
   101 
       
   102     \sa options(), surfaceFunctions()
       
   103 */
       
   104 bool
       
   105 QGLScreen::chooseContext(QGLContext *context, const QGLContext *shareContext)
       
   106 {
       
   107     Q_UNUSED(context);
       
   108     Q_UNUSED(shareContext);
       
   109     return false;
       
   110 }
       
   111 
       
   112 /*!
       
   113     \enum QGLScreen::Option
       
   114     This enum defines options that can be set on QGLScreen instances.
       
   115 
       
   116     \value NoOptions There are no special options on the screen.  This is the default.
       
   117     \value NativeWindows Native windows can be created with QGLScreenSurfaceFunctions::createNativeWindow().
       
   118     \value NativePixmaps Native pixmaps can be created with QGLScreenSurfaceFunctions::createNativePixmap().
       
   119     \value NativeImages Native images can be created with QGLScreenSurfaceFunctions::createNativeImage().
       
   120     \value Overlays The screen supports GL overlays.
       
   121 */
       
   122 
       
   123 /*!
       
   124     \since 4.4.2
       
   125 
       
   126     Returns the options associated with this QGLScreen.
       
   127 
       
   128     \sa setOptions()
       
   129 */
       
   130 QGLScreen::Options QGLScreen::options() const
       
   131 {
       
   132     return d_ptr->options;
       
   133 }
       
   134 
       
   135 /*!
       
   136     \since 4.4.2
       
   137 
       
   138     Sets the options associated with this QGLScreen to \a value.
       
   139 
       
   140     \sa options()
       
   141 */
       
   142 void QGLScreen::setOptions(QGLScreen::Options value)
       
   143 {
       
   144     d_ptr->options = value;
       
   145 }
       
   146 
       
   147 /*!
       
   148     \since 4.4.2
       
   149 
       
   150     Returns the surface functions object for this QGLScreen.
       
   151 
       
   152     \sa setSurfaceFunctions()
       
   153 */
       
   154 QGLScreenSurfaceFunctions *QGLScreen::surfaceFunctions() const
       
   155 {
       
   156     return d_ptr->functions;
       
   157 }
       
   158 
       
   159 /*!
       
   160     \since 4.4.2
       
   161 
       
   162     Sets the surface functions object for this QGLScreen to \a functions.
       
   163     The QGLScreen will take over ownership of \a functions and delete
       
   164     it when the QGLScreen is deleted.
       
   165 
       
   166     \sa setSurfaceFunctions()
       
   167 */
       
   168 void QGLScreen::setSurfaceFunctions(QGLScreenSurfaceFunctions *functions)
       
   169 {
       
   170     if (functions && functions != d_ptr->functions) {
       
   171         delete d_ptr->functions;
       
   172         d_ptr->functions = functions;
       
   173     }
       
   174 }
       
   175 
       
   176 /*!
       
   177     \internal
       
   178     \preliminary
       
   179     \class QGLScreenSurfaceFunctions
       
   180     \brief The QGLScreenSurfaceFunctions class encapsulates the functions for creating native windows and pixmaps for OpenGL ES.
       
   181 */
       
   182 
       
   183 /*!
       
   184     \since 4.4.2
       
   185 
       
   186     Creates a native OpenGLES drawable for the surface of \a widget and
       
   187     returns it in \a native.  Returns true if the OpenGLES drawable could
       
   188     be created, or false if windows are not supported.
       
   189 
       
   190     This function will be called if the NativeWindows option is set on
       
   191     the screen.
       
   192 
       
   193     \sa createNativePixmap(), createNativeImage(), QGLScreen::options()
       
   194 */
       
   195 bool QGLScreenSurfaceFunctions::createNativeWindow(QWidget *widget, EGLNativeWindowType *native)
       
   196 {
       
   197     Q_UNUSED(widget);
       
   198     Q_UNUSED(native);
       
   199     return false;
       
   200 }
       
   201 
       
   202 /*!
       
   203     \since 4.4.2
       
   204 
       
   205     Creates a native OpenGLES drawable for directly rendering into
       
   206     \a pixmap and returns it in \a native.  Returns true if the OpenGLES
       
   207     drawable could be created, or false if direct rendering into pixmaps
       
   208     is not supported.
       
   209 
       
   210     This function will be called if the NativePixmaps option is set on
       
   211     the screen.
       
   212 
       
   213     \sa createNativeWindow(), createNativeImage(), QGLScreen::options()
       
   214 */
       
   215 bool QGLScreenSurfaceFunctions::createNativePixmap(QPixmap *pixmap, EGLNativePixmapType *native)
       
   216 {
       
   217     Q_UNUSED(pixmap);
       
   218     Q_UNUSED(native);
       
   219     return false;
       
   220 }
       
   221 
       
   222 /*!
       
   223     \since 4.4.2
       
   224 
       
   225     Creates a native OpenGLES drawable for directly rendering into
       
   226     \a image and returns it in \a native.  Returns true if the OpenGLES
       
   227     drawable could be created, or false if direct rendering into images
       
   228     is not supported.
       
   229 
       
   230     This function will be called if the NativeImages option is set on
       
   231     the screen.
       
   232 
       
   233     \sa createNativeWindow(), createNativePixmap(), QGLScreen::options()
       
   234 */
       
   235 bool QGLScreenSurfaceFunctions::createNativeImage(QImage *image, EGLNativePixmapType *native)
       
   236 {
       
   237     Q_UNUSED(image);
       
   238     Q_UNUSED(native);
       
   239     return false;
       
   240 }
       
   241 
       
   242 QT_END_NAMESPACE