summaryrefslogtreecommitdiffstats
path: root/doc/src/platforms/emb-opengl-EmbLinux.qdoc
blob: 92293c24b3525042076f96386bb82a8785501a33 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
/****************************************************************************
**
** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
** All rights reserved.
** Contact: Nokia Corporation (qt-info@nokia.com)
**
** This file is part of the documentation of the Qt Toolkit.
**
** $QT_BEGIN_LICENSE:FDL$
** No Commercial Usage
** This file contains pre-release code and may not be distributed.
** You may use this file in accordance with the terms and conditions
** contained in the Technology Preview License Agreement accompanying
** this package.
**
** GNU Free Documentation License
** Alternatively, this file may be used under the terms of the GNU Free
** Documentation License version 1.3 as published by the Free Software
** Foundation and appearing in the file included in the packaging of this
** file.
**
** If you have questions regarding the use of this file, please contact
** Nokia at qt-info@nokia.com.
** $QT_END_LICENSE$
**
****************************************************************************/

/*!
\page qt-embeddedLinux-opengl.html

\title Qt for Embedded Linux and OpenGL

\ingroup qt-embedded-linux

\input platforms/emb-opengl.qdocinc

\section1 Using OpenGL with Qt for Embedded Linux
Qt for Embedded Linux provides support for integrating OpenGL ES for
drawing into a QGLWidget. The current implementation supports OpenGL and 2D
painting within a QGLWidget. Using OpenGL to accelerate regular widgets and
compositing top-level windows with OpenGL are not currently supported.

\note OpenGL rendering only works with QGLWidget under QWS.  Regular
widgets cannot currently support it.

\section2 Configure

It is recommended that Qt for Embedded Linux is configured with the
\c{-DQT_QWS_CLIENTBLIT} and \c{-DQT_NO_QWS_CURSOR} options for optimum
performance.  OpenGL is rendered direct to the screen and these options
prevent Qt for Embedded Linux from trying to do its own non-OpenGL
compositing on the QGLWidget contents.

\section2 Using OpenGL to Implement Window Compositing and Effects

Compositing effects can be simulated by adjusting the opacity and other
parameters of the items within a QGraphicsView canvas on a QGLWidget
viewport.

While Qt for Embedded Linux does include a complete windowing system,
using OpenGL to composite regular window surfaces can be quite difficult.
Most of Qt for Embedded Linux assumes that the window surface is a plain
raster memory buffer, with QGLWidget being the sole exception.
The need to constantly re-upload the raster memory buffers into OpenGL
textures for compositing can have a significant impact on performance,
which is why we do not recommend implementing that form of compositing.
We intend to address this problem in future versions of Qt.

\section1 Integrating OpenGL/ES into Qt for Embedded Linux
\section2 Reference Integration
The reference integration for OpenGL into Qt for Embedded Linux is for the
PowerVR chipset from \l{http://www.imgtec.com/}{Imagination Technologies}.
It consists of two components: \c{pvreglscreen}, which provides the Qt for
Embedded Linux screen driver, and \c{QWSWSEGL}, which implements a plug-in
to the PowerVR EGL implementation to implement low-level OpenGL drawing
surfaces.

\section2 Integrating Other Chipsets
In this section, we discuss the essential features of the reference
integration that need to be provided for any other chipset integration.

The QtOpenGL module assumes that a QGLWidget can be represented
by an \c EGLNativeWindowType value in some underlying window system
implementation, and that \c{eglSwapBuffers()} is sufficient to copy
the contents of the native window to the screen when requested.

However, many EGL implementations do not have a pre-existing window system.
Usually only a single full-screen window is provided, and everything else
must be simulated some other way.  This can be a problem because
of QtOpenGL's assumptions.  We intend to address these assumptions in a
future version of Qt, but for now, it is the responsibility of the integrator
to provide a rudimentary window system within the EGL implementation.
This is the purpose of \c{QWSWSEGL} in the reference integration.

If it isn't possible for the EGL implementation to provide a rudimentary
window system, then full-screen windows using QGLWidget can be supported,
but very little else.

The screen driver needs to inherit from QGLScreen and perform the
following operations in its constructor:

\snippet src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp 0

The \c{setSurfaceFunctions()} call supplies an object that takes care
of converting Qt paint devices such as widgets and pixmaps into
\c EGLNativeWindowType and \c EGLNativePixmapType values.  Here we
only support native windows.  Because OpenGL rendering is direct to
the screen, we also indicate that client blit is supported.

Next, we override the \c{createSurface()} functions in QGLScreen:

\snippet src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp 1

Even if Qt for Embedded Linux is used in single-process mode, it is
necessary to create both client-side and server-side versions of the
window surface.  In our case, the server-side is just a stub because
the client side directly renders to the screen.

Note that we only create a \c{PvrEglWindowSurface} if the widget is a
QGLWidget.  All other widgets use the normal raster processing.
It can be tempting to make \c{createSurface()} create an OpenGL
window surface for other widget types as well.  This has not been
extensively tested and we do not recommend its use at this time.

The other main piece is the creation of the \c EGLNativeWindowType
value for the widget.  This is done in the \c{createNativeWindow()}
override:

\snippet src/plugins/gfxdrivers/powervr/pvreglscreen/pvreglscreen.cpp 2

The details of what needs to be placed in this function will vary
from chipset to chipset.  The simplest is to return the native window
handle corresponding to the "root" full-screen window:

\code
*native = rootWindowHandle;
return true;
\endcode

The most common value for \c rootWindowHandle is zero, but this may
not always be the case.  Consult the chipset documentation for the
actual value to use.  The important thing is that whatever value is
returned must be suitable for passing to the \c{eglCreateWindowSurface()}
function of the chipset's EGL implementation.

In the case of PowerVR, the rudimentary window system in \c{QWSWSEGL}
provides a \c PvrQwsDrawable object to represent the \c EGLNativeWindowType
value for the widget.

*/