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

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

trunk: Merged in qt 4.6.2 sources.

  • Property svn:eol-style set to native
File size: 7.3 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2010 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:LGPL$
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
14** a written agreement between you and Nokia.
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** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
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
52Qt for Embedded Linux provides support for integrating OpenGL ES for
53drawing into a QGLWidget. The current implementation supports OpenGL and 2D
54painting within a QGLWidget. Using OpenGL to accelerate regular widgets and
55compositing top-level windows with OpenGL are not currently supported.
56
57\note OpenGL rendering only works with QGLWidget under QWS. Regular
58widgets cannot currently support it.
59
60\section2 Configure
61
62It 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
64performance. OpenGL is rendered direct to the screen and these options
65prevent Qt for Embedded Linux from trying to do its own non-OpenGL
66compositing on the QGLWidget contents.
67
68\section2 Using OpenGL to Implement Window Compositing and Effects
69
70Compositing effects can be simulated by adjusting the opacity and other
71parameters of the items within a QGraphicsView canvas on a QGLWidget
72viewport.
73
74While Qt for Embedded Linux does include a complete windowing system,
75using OpenGL to composite regular window surfaces can be quite difficult.
76Most of Qt for Embedded Linux assumes that the window surface is a plain
77raster memory buffer, with QGLWidget being the sole exception.
78The need to constantly re-upload the raster memory buffers into OpenGL
79textures for compositing can have a significant impact on performance,
80which is why we do not recommend implementing that form of compositing.
81We 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
85The reference integration for OpenGL into Qt for Embedded Linux is for the
86PowerVR chipset from \l{http://www.imgtec.com/}{Imagination Technologies}.
87It consists of two components: \c{pvreglscreen}, which provides the Qt for
88Embedded Linux screen driver, and \c{QWSWSEGL}, which implements a plug-in
89to the PowerVR EGL implementation to implement low-level OpenGL drawing
90surfaces.
91
92\section2 Integrating Other Chipsets
93In this section, we discuss the essential features of the reference
94integration that need to be provided for any other chipset integration.
95
96The QtOpenGL module assumes that a QGLWidget can be represented
97by an \c EGLNativeWindowType value in some underlying window system
98implementation, and that \c{eglSwapBuffers()} is sufficient to copy
99the contents of the native window to the screen when requested.
100
101However, many EGL implementations do not have a pre-existing window system.
102Usually only a single full-screen window is provided, and everything else
103must be simulated some other way. This can be a problem because
104of QtOpenGL's assumptions. We intend to address these assumptions in a
105future version of Qt, but for now, it is the responsibility of the integrator
106to provide a rudimentary window system within the EGL implementation.
107This is the purpose of \c{QWSWSEGL} in the reference integration.
108
109If it isn't possible for the EGL implementation to provide a rudimentary
110window system, then full-screen windows using QGLWidget can be supported,
111but very little else.
112
113The screen driver needs to inherit from QGLScreen and perform the
114following operations in its constructor:
115
116\snippet src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp 0
117
118The \c{setSurfaceFunctions()} call supplies an object that takes care
119of converting Qt paint devices such as widgets and pixmaps into
120\c EGLNativeWindowType and \c EGLNativePixmapType values. Here we
121only support native windows. Because OpenGL rendering is direct to
122the screen, we also indicate that client blit is supported.
123
124Next, we override the \c{createSurface()} functions in QGLScreen:
125
126\snippet src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp 1
127
128Even if Qt for Embedded Linux is used in single-process mode, it is
129necessary to create both client-side and server-side versions of the
130window surface. In our case, the server-side is just a stub because
131the client side directly renders to the screen.
132
133Note that we only create a \c{PvrEglWindowSurface} if the widget is a
134QGLWidget. All other widgets use the normal raster processing.
135It can be tempting to make \c{createSurface()} create an OpenGL
136window surface for other widget types as well. This has not been
137extensively tested and we do not recommend its use at this time.
138
139The other main piece is the creation of the \c EGLNativeWindowType
140value for the widget. This is done in the \c{createNativeWindow()}
141override:
142
143\snippet src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp 2
144
145The details of what needs to be placed in this function will vary
146from chipset to chipset. The simplest is to return the native window
147handle corresponding to the "root" full-screen window:
148
149\code
150*native = rootWindowHandle;
151return true;
152\endcode
153
154The most common value for \c rootWindowHandle is zero, but this may
155not always be the case. Consult the chipset documentation for the
156actual value to use. The important thing is that whatever value is
157returned must be suitable for passing to the \c{eglCreateWindowSurface()}
158function of the chipset's EGL implementation.
159
160In the case of PowerVR, the rudimentary window system in \c{QWSWSEGL}
161provides a \c PvrQwsDrawable object to represent the \c EGLNativeWindowType
162value for the widget.
163
164*/
Note: See TracBrowser for help on using the repository browser.