source: trunk/doc/src/platforms/emb-opengl-EmbLinux.qdoc@ 846

Last change on this file since 846 was 846, checked in by Dmitry A. Kuminov, 14 years ago

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

  • Property svn:eol-style set to native
File size: 6.4 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the documentation of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:FDL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in a
14** written agreement between you and Nokia.
15**
16** GNU Free Documentation License
17** Alternatively, this file may be used under the terms of the GNU Free
18** Documentation License version 1.3 as published by the Free Software
19** Foundation and appearing in the file included in the packaging of this
20** file.
21**
22** If you have questions regarding the use of this file, please contact
23** Nokia at [email protected].
24** $QT_END_LICENSE$
25**
26****************************************************************************/
27
28/*!
29\page qt-embeddedLinux-opengl.html
30
31\title Qt for Embedded Linux and OpenGL
32
33\ingroup qt-embedded-linux
34
35\input platforms/emb-opengl.qdocinc
36
37\section1 Using OpenGL with Qt for Embedded Linux
38Qt for Embedded Linux provides support for integrating OpenGL ES for
39drawing into a QGLWidget. The current implementation supports OpenGL and 2D
40painting within a QGLWidget. Using OpenGL to accelerate regular widgets and
41compositing top-level windows with OpenGL are not currently supported.
42
43\note OpenGL rendering only works with QGLWidget under QWS. Regular
44widgets cannot currently support it.
45
46\section2 Configure
47
48It is recommended that Qt for Embedded Linux is configured with the
49\c{-DQT_QWS_CLIENTBLIT} and \c{-DQT_NO_QWS_CURSOR} options for optimum
50performance. OpenGL is rendered direct to the screen and these options
51prevent Qt for Embedded Linux from trying to do its own non-OpenGL
52compositing on the QGLWidget contents.
53
54\section2 Using OpenGL to Implement Window Compositing and Effects
55
56Compositing effects can be simulated by adjusting the opacity and other
57parameters of the items within a QGraphicsView canvas on a QGLWidget
58viewport.
59
60While Qt for Embedded Linux does include a complete windowing system,
61using OpenGL to composite regular window surfaces can be quite difficult.
62Most of Qt for Embedded Linux assumes that the window surface is a plain
63raster memory buffer, with QGLWidget being the sole exception.
64The need to constantly re-upload the raster memory buffers into OpenGL
65textures for compositing can have a significant impact on performance,
66which is why we do not recommend implementing that form of compositing.
67We intend to address this problem in future versions of Qt.
68
69\section1 Integrating OpenGL/ES into Qt for Embedded Linux
70\section2 Reference Integration
71The reference integration for OpenGL into Qt for Embedded Linux is for the
72PowerVR chipset from \l{http://www.imgtec.com/}{Imagination Technologies}.
73It consists of two components: \c{pvreglscreen}, which provides the Qt for
74Embedded Linux screen driver, and \c{QWSWSEGL}, which implements a plug-in
75to the PowerVR EGL implementation to implement low-level OpenGL drawing
76surfaces.
77
78\section2 Integrating Other Chipsets
79In this section, we discuss the essential features of the reference
80integration that need to be provided for any other chipset integration.
81
82The QtOpenGL module assumes that a QGLWidget can be represented
83by an \c EGLNativeWindowType value in some underlying window system
84implementation, and that \c{eglSwapBuffers()} is sufficient to copy
85the contents of the native window to the screen when requested.
86
87However, many EGL implementations do not have a pre-existing window system.
88Usually only a single full-screen window is provided, and everything else
89must be simulated some other way. This can be a problem because
90of QtOpenGL's assumptions. We intend to address these assumptions in a
91future version of Qt, but for now, it is the responsibility of the integrator
92to provide a rudimentary window system within the EGL implementation.
93This is the purpose of \c{QWSWSEGL} in the reference integration.
94
95If it isn't possible for the EGL implementation to provide a rudimentary
96window system, then full-screen windows using QGLWidget can be supported,
97but very little else.
98
99The screen driver needs to inherit from QGLScreen and perform the
100following operations in its constructor:
101
102\snippet src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp 0
103
104The \c{setSurfaceFunctions()} call supplies an object that takes care
105of converting Qt paint devices such as widgets and pixmaps into
106\c EGLNativeWindowType and \c EGLNativePixmapType values. Here we
107only support native windows. Because OpenGL rendering is direct to
108the screen, we also indicate that client blit is supported.
109
110Next, we override the \c{createSurface()} functions in QGLScreen:
111
112\snippet src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp 1
113
114Even if Qt for Embedded Linux is used in single-process mode, it is
115necessary to create both client-side and server-side versions of the
116window surface. In our case, the server-side is just a stub because
117the client side directly renders to the screen.
118
119Note that we only create a \c{PvrEglWindowSurface} if the widget is a
120QGLWidget. All other widgets use the normal raster processing.
121It can be tempting to make \c{createSurface()} create an OpenGL
122window surface for other widget types as well. This has not been
123extensively tested and we do not recommend its use at this time.
124
125The other main piece is the creation of the \c EGLNativeWindowType
126value for the widget. This is done in the \c{createNativeWindow()}
127override:
128
129\snippet src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp 2
130
131The details of what needs to be placed in this function will vary
132from chipset to chipset. The simplest is to return the native window
133handle corresponding to the "root" full-screen window:
134
135\code
136*native = rootWindowHandle;
137return true;
138\endcode
139
140The most common value for \c rootWindowHandle is zero, but this may
141not always be the case. Consult the chipset documentation for the
142actual value to use. The important thing is that whatever value is
143returned must be suitable for passing to the \c{eglCreateWindowSurface()}
144function of the chipset's EGL implementation.
145
146In the case of PowerVR, the rudimentary window system in \c{QWSWSEGL}
147provides a \c PvrQwsDrawable object to represent the \c EGLNativeWindowType
148value for the widget.
149
150*/
Note: See TracBrowser for help on using the repository browser.