source: trunk/doc/src/qtopiacore-opengl.qdoc@ 342

Last change on this file since 342 was 2, checked in by Dmitry A. Kuminov, 16 years ago

Initially imported qt-all-opensource-src-4.5.1 from Trolltech.

File size: 9.4 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
4** Contact: Qt Software Information ([email protected])
5**
6** This file is part of the documentation of the Qt Toolkit.
7**
8** $QT_BEGIN_LICENSE:LGPL$
9** Commercial Usage
10** Licensees holding valid Qt Commercial licenses may use this file in
11** accordance with the Qt Commercial License Agreement provided with the
12** Software or, alternatively, in accordance with the terms contained in
13** a written agreement between you and Nokia.
14**
15** GNU Lesser General Public License Usage
16** Alternatively, this file may be used under the terms of the GNU Lesser
17** General Public License version 2.1 as published by the Free Software
18** Foundation and appearing in the file LICENSE.LGPL included in the
19** packaging of this file. Please review the following information to
20** ensure the GNU Lesser General Public License version 2.1 requirements
21** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
22**
23** In addition, as a special exception, Nokia gives you certain
24** additional rights. These rights are described in the Nokia Qt LGPL
25** Exception version 1.0, included in the file LGPL_EXCEPTION.txt in this
26** 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 are unsure which license is appropriate for your use, please
37** contact the sales department at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42/*!
43\page qt-embedded-opengl.html
44
45\title Qt for Embedded Linux and OpenGL
46\ingroup qt-embedded-linux
47
48\section1 Introduction
49
50\l {http://www.opengl.org}{OpenGL} is an industry standard API for
512D/3D graphics. It provides a powerful, low-level interface between
52software and acceleration hardware, and it is operating system and
53window system independent.
54
55\l {http://www.khronos.org/opengles}{OpenGL ES} is a subset
56of the \l {http://www.opengl.org}{OpenGL} standard.
57Because it is meant for use in embedded systems, it has a smaller,
58more constrained API.
59
60For reference, Nokia provides a plugin which integrates \l
61{http://www.khronos.org/opengles}{OpenGL ES} with Qt for Embedded Linux,
62but Qt for Embedded Linux can be adapted to a wide range of OpenGL
63versions.
64
65There are three ways to use OpenGL with Qt for Embedded Linux:
66\list
67 \o Perform OpenGL 3D graphics operations in applications;
68 \o Accelerate normal 2D painting operations;
69 \o Implement window compositing and special effects.
70\endlist
71
72Qt for Embedded Linux is shipped with a reference integration example
73that demonstrates all three uses.
74
75\section2 Using OpenGL 3D Graphics in Applications
76
77The \l {QtOpenGL module} offers classes that make it easy to draw 3D
78graphics in GUI applications. The module API is cross-platform, so it
79is also available on Windows, X11, and Mac OS X.
80
81To use OpenGL-enabled widgets in a Qt for Embedded Linux application,
82all that is required is to subclass the QGLWidget and draw into instances of
83the subclass with standard OpenGL functions.
84
85\section2 Using OpenGL to Accelerate Normal 2D Painting
86
87Qt provides QOpenGLPaintEngine, a subclass of QPaintEngine that
88translates QPainter operations into OpenGL calls. This specialized
89paint engine can be used to improve 2D rendering performance on
90appropriate hardware. It can also overlay controls and decorations
91onto 3D scenes drawn using OpenGL.
92
93\section2 Using OpenGL to Implement Window Compositing and Effects
94
95Qt for Embedded Linux includes a complete windowing system, which implements
96real transparency. The windowing system can be accelerated using
97OpenGL to implement top level window compositing. This makes it easy
98to add 3D effects to applications, for instance when windows are
99minimized or maximized.
100
101\section1 Acceleration Architecture
102
103The diagram below shows the Qt for Embedded Linux painting architecture.
104
105\image qt-embedded-opengl3.png
106
107A client process widget uses a paint engine to draw into a window
108surface. The server then combines the window surfaces and displays the
109composition on the screen. This architecture lets you
110control the steps of the painting process by subclassing.
111
112Subclassing QPaintEngine allows you to implement the QPainter API
113using accelerated hardware. Subclassing QWindowSurface lets you
114decide the properties of the space your widgets will draw themselves
115into, as well as which paint engine they should use to draw themselves
116into that space. Subclassing QScreen lets you control the creation of
117window surfaces and lets you decide how to implement window
118compositing. Using subclassing, your implementation work is minimized
119since you can reuse base class functionality you don't need to change.
120
121The elements of an accelerated Qt for Embedded Linux system are shown in the
122diagram below.
123
124\image qt-embedded-opengl1.png
125
126The applications, using the Qt API, do not depend on the presence of
127the acceleration plugin. The plugin uses the graphics hardware to
128accelerate painting primitives. Any operations not accelerated by the
129plugin are done in software by the software paint engine.
130
131To integrate an OpenGL implementation into Qt for Embedded Linux for a
132particular platform, you use the same mechanisms you would use for
133writing any other accelerated driver. Base classes, e.g., QGLScreen
134and QWSGLWindowSurface, are provided to minimize the need for
135reimplementing common functionality.
136
137\section1 The Reference Integration
138
139The \l{OpenGL for Embedded Systems Example} is the reference implementation
140for integrating OpenGL ES and \l{http://www.khronos.org/egl/}{EGL} with
141the graphics acceleration architecture of Qt for Embedded Linux.
142(\l{http://www.khronos.org/egl/}{EGL} is a library that binds OpenGL ES to
143native windowing systems.)
144
145The diagram below shows how OpenGL ES is used within the acceleration architecture:
146
147\image qt-embedded-opengl2.png
148
149The example implements a screen driver plugin that demonstrates all
150three uses of OpenGL in Qt for Embedded Linux: 2D graphics acceleration, 3D
151graphics operations using the \l {QtOpenGL module}, and top-level
152window compositing and special effects. The applications still do
153not talk directly to the accelerated plugin.
154
155For 2D graphics, applications use the normal Qt painting API. The example accelerates 2D
156painting by using the QOpenGLPaintEngine, which is included in the \l {QtOpenGL module}.
157
158For 3D graphics applications use the OpenGL API directly, together with the functionality
159in the Qt OpenGL support classes. The example supports this by creating a
160QWSGLWindowSurface whenever a QGLWidget is instantiated.
161
162All access to the display is done through OpenGL. The example subclasses
163QWSGLWindowSurface implementation and uses the \l
164{http://oss.sgi.com/projects/ogl-sample/registry/EXT/framebuffer_object.txt}
165{OpenGL Framebuffer Object extension} to draw windows into an offscreen buffer. This
166lets the example use OpenGL to implement top level window compositing of opaque and
167semi-transparent windows, and to provide a 3D animated transition effect as each new
168window is shown.
169
170The specific OpenGL library being used by the example restricts all
171OpenGL operations to occur in a single process. Hence the example
172creates instances of QWSGLWindowSurface only in the server process.
173Other processes then perform 2D graphics by creating instances
174of the standard QWindowSurface classes for client processes. The
175standard window surface performs software-based rendering into a
176shared memory segment. The server then transfers the contents of this
177shared memory into an OpenGL texture before they are drawn onto the
178screen during window compositing.
179
180\omit
181
182\section1 Future Directions
183
184\section2 API Improvements
185
186Nokia is now working on enhancing the API for integrating OpenGL
187with Qt for Embedded Linux. The current design plan includes the following
188features:
189
190\list
191
192 \o Provide convenience classes, e.g., QEGLScreen and
193 QWSEGLWindowSurface, which implement common uses of the EGL
194 API. These classes will simplify implementing an OpenGL ES
195 integration.
196
197 \o Extend the screen driver API to provide more control over window
198 properties and animations, and provide a software-based integration
199 to enable testing on the desktop.
200
201 \o Improve performance as opportunities arise.
202
203\endlist
204
205\section2 OpenVG Support
206
207\l {http://www.khronos.org/openvg} {OpenVG} is a dedicated API for 2D
208graphics on mobile devices. It is therefore more likely to be a better
209alternative for 2D acceleration than OpenGL. Until recently, no
210OpenVG-capable hardware has been available, so Nokia has not yet
211included an OpenVG solution in Qt for Embedded Linux.
212
213However, Nokia has done a feasibility study, implementing an
214OpenVG paint engine on top of a software OpenVG implementation.
215Assuming availability of the appropriate hardware, this OpenVG paint
216engine can easily be completed and integrated using the existing
217acceleration architecture. Since OpenVG shares the same EGL layer as
218OpenGL ES, the work already done on the OpenGL integration can be
219reused.
220
221Related technologies included in the \l
222{http://www.khronos.org/openkode} {OpenKODE} API set will also be
223considered.
224
225\endomit
226
227*/
Note: See TracBrowser for help on using the repository browser.