doc/src/platforms/emb-opengl-EmbLinux.qdoc
branchRCL_3
changeset 8 3f74d0d4af4c
equal deleted inserted replaced
6:dee5afe5301f 8:3f74d0d4af4c
       
     1 /****************************************************************************
       
     2 **
       
     3 ** Copyright (C) 2010 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 documentation 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 /*!
       
    43 \page qt-embeddedLinux-opengl.html
       
    44 
       
    45 \title Qt for Embedded Linux and OpenGL
       
    46 
       
    47 \ingroup qt-embedded-linux
       
    48 
       
    49 \input platforms/emb-opengl.qdocinc
       
    50 
       
    51 \section1 Using OpenGL with Qt for Embedded Linux
       
    52 Qt for Embedded Linux provides support for integrating OpenGL ES for
       
    53 drawing into a QGLWidget. The current implementation supports OpenGL and 2D
       
    54 painting within a QGLWidget. Using OpenGL to accelerate regular widgets and
       
    55 compositing top-level windows with OpenGL are not currently supported.
       
    56 
       
    57 \note OpenGL rendering only works with QGLWidget under QWS.  Regular
       
    58 widgets cannot currently support it.
       
    59 
       
    60 \section2 Configure
       
    61 
       
    62 It is recommended that Qt for Embedded Linux is configured with the
       
    63 \c{-DQT_QWS_CLIENTBLIT} and \c{-DQT_NO_QWS_CURSOR} options for optimum
       
    64 performance.  OpenGL is rendered direct to the screen and these options
       
    65 prevent Qt for Embedded Linux from trying to do its own non-OpenGL
       
    66 compositing on the QGLWidget contents.
       
    67 
       
    68 \section2 Using OpenGL to Implement Window Compositing and Effects
       
    69 
       
    70 Compositing effects can be simulated by adjusting the opacity and other
       
    71 parameters of the items within a QGraphicsView canvas on a QGLWidget
       
    72 viewport.
       
    73 
       
    74 While Qt for Embedded Linux does include a complete windowing system,
       
    75 using OpenGL to composite regular window surfaces can be quite difficult.
       
    76 Most of Qt for Embedded Linux assumes that the window surface is a plain
       
    77 raster memory buffer, with QGLWidget being the sole exception.
       
    78 The need to constantly re-upload the raster memory buffers into OpenGL
       
    79 textures for compositing can have a significant impact on performance,
       
    80 which is why we do not recommend implementing that form of compositing.
       
    81 We intend to address this problem in future versions of Qt.
       
    82 
       
    83 \section1 Integrating OpenGL/ES into Qt for Embedded Linux
       
    84 \section2 Reference Integration
       
    85 The reference integration for OpenGL into Qt for Embedded Linux is for the
       
    86 PowerVR chipset from \l{http://www.imgtec.com/}{Imagination Technologies}.
       
    87 It consists of two components: \c{pvreglscreen}, which provides the Qt for
       
    88 Embedded Linux screen driver, and \c{QWSWSEGL}, which implements a plug-in
       
    89 to the PowerVR EGL implementation to implement low-level OpenGL drawing
       
    90 surfaces.
       
    91 
       
    92 \section2 Integrating Other Chipsets
       
    93 In this section, we discuss the essential features of the reference
       
    94 integration that need to be provided for any other chipset integration.
       
    95 
       
    96 The QtOpenGL module assumes that a QGLWidget can be represented
       
    97 by an \c EGLNativeWindowType value in some underlying window system
       
    98 implementation, and that \c{eglSwapBuffers()} is sufficient to copy
       
    99 the contents of the native window to the screen when requested.
       
   100 
       
   101 However, many EGL implementations do not have a pre-existing window system.
       
   102 Usually only a single full-screen window is provided, and everything else
       
   103 must be simulated some other way.  This can be a problem because
       
   104 of QtOpenGL's assumptions.  We intend to address these assumptions in a
       
   105 future version of Qt, but for now, it is the responsibility of the integrator
       
   106 to provide a rudimentary window system within the EGL implementation.
       
   107 This is the purpose of \c{QWSWSEGL} in the reference integration.
       
   108 
       
   109 If it isn't possible for the EGL implementation to provide a rudimentary
       
   110 window system, then full-screen windows using QGLWidget can be supported,
       
   111 but very little else.
       
   112 
       
   113 The screen driver needs to inherit from QGLScreen and perform the
       
   114 following operations in its constructor:
       
   115 
       
   116 \snippet src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp 0
       
   117 
       
   118 The \c{setSurfaceFunctions()} call supplies an object that takes care
       
   119 of converting Qt paint devices such as widgets and pixmaps into
       
   120 \c EGLNativeWindowType and \c EGLNativePixmapType values.  Here we
       
   121 only support native windows.  Because OpenGL rendering is direct to
       
   122 the screen, we also indicate that client blit is supported.
       
   123 
       
   124 Next, we override the \c{createSurface()} functions in QGLScreen:
       
   125 
       
   126 \snippet src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp 1
       
   127 
       
   128 Even if Qt for Embedded Linux is used in single-process mode, it is
       
   129 necessary to create both client-side and server-side versions of the
       
   130 window surface.  In our case, the server-side is just a stub because
       
   131 the client side directly renders to the screen.
       
   132 
       
   133 Note that we only create a \c{PvrEglWindowSurface} if the widget is a
       
   134 QGLWidget.  All other widgets use the normal raster processing.
       
   135 It can be tempting to make \c{createSurface()} create an OpenGL
       
   136 window surface for other widget types as well.  This has not been
       
   137 extensively tested and we do not recommend its use at this time.
       
   138 
       
   139 The other main piece is the creation of the \c EGLNativeWindowType
       
   140 value for the widget.  This is done in the \c{createNativeWindow()}
       
   141 override:
       
   142 
       
   143 \snippet src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp 2
       
   144 
       
   145 The details of what needs to be placed in this function will vary
       
   146 from chipset to chipset.  The simplest is to return the native window
       
   147 handle corresponding to the "root" full-screen window:
       
   148 
       
   149 \code
       
   150 *native = rootWindowHandle;
       
   151 return true;
       
   152 \endcode
       
   153 
       
   154 The most common value for \c rootWindowHandle is zero, but this may
       
   155 not always be the case.  Consult the chipset documentation for the
       
   156 actual value to use.  The important thing is that whatever value is
       
   157 returned must be suitable for passing to the \c{eglCreateWindowSurface()}
       
   158 function of the chipset's EGL implementation.
       
   159 
       
   160 In the case of PowerVR, the rudimentary window system in \c{QWSWSEGL}
       
   161 provides a \c PvrQwsDrawable object to represent the \c EGLNativeWindowType
       
   162 value for the widget.
       
   163 
       
   164 */