Skip to content

Commit d8efe51

Browse files
Update Qt OpenGL docs and add porting docs
This fleshes out the Qt OpenGL documentation, since this is now a first class citizen and no longer a compatibility module. It also adds Qt OpenGL-related info on porting to Qt 6. Fixes: QTBUG-88150 Change-Id: I85fcaa2eb5ae574416dcebcc0104bf97428ff42d Reviewed-by: Eskil Abrahamsen Blomfeldt <[email protected]>
1 parent c87692a commit d8efe51

File tree

4 files changed

+114
-14
lines changed

4 files changed

+114
-14
lines changed

src/gui/doc/src/qt6-changes.qdoc

+15
Original file line numberDiff line numberDiff line change
@@ -102,4 +102,19 @@
102102
\section2 QIntValidator and QDoubleValidator
103103

104104
The \l{QIntValidator::}{setRange()} method is no longer marked as virtual.
105+
106+
\section1 OpenGL classes
107+
108+
With the introduction of Qt RHI as the rendering foundation in Qt,
109+
most classes prefixed by \c QOpenGL have been moved into the \l{Qt OpenGL}
110+
module.
111+
112+
More details can be found in \l{Changes to Qt OpenGL}{the Qt OpenGL porting guide}.
113+
114+
One notable exception is the class \l QOpenGLContext, which still resides in
115+
Qt GUI.
116+
117+
In addition, the class \l QOpenGLWidget has been moved to a new module, named
118+
Qt OpenGL Widgets.
119+
105120
*/

src/opengl/doc/qtopengl.qdocconf

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ exampledirs += ../../../examples/opengl \
2828
imagedirs += images \
2929
../../../examples/opengl/doc/images
3030

31-
depends += qtcore qtgui qtwidgets qtdoc qmake qtcmake
31+
depends += qtcore qtgui qtwidgets qtdoc qmake qtcmake qtquick
3232

3333
examplesinstallpath = opengl
3434

src/opengl/doc/src/qt6-changes.qdoc

+56-2
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,63 @@
3838
APIs in each release. But some changes were inevitable in an effort to
3939
make Qt a better framework.
4040

41-
In this topic we summarize those changes in Qt OpenGL, and provide
41+
In this topic we summarize those changes in \l{Qt OpenGL}, and provide
4242
guidance to handle them.
4343

44-
\section1 ADD STUFF HERE
44+
\section1 Deprecated classes removed
4545

46+
The \l{Qt OpenGL} module was deprecated for the life time of Qt 5, and the
47+
classes it contained have been removed in Qt 6.
48+
49+
This refers specifically to the classes prefixed by \c{QGL}.
50+
51+
\section1 QOpenGL classes migrated
52+
53+
In Qt 5, a replacement set of OpenGL-support classes were added to Qt Gui.
54+
This was in order to support OpenGL as the cross-platform graphics API that
55+
served as foundation for graphics in Qt.
56+
57+
In Qt 6, these have been migrated to the \l{Qt OpenGL} module. They are still
58+
usable and fully supported for applications depending on OpenGL directly.
59+
However, they are no longer considered foundational, since Qt has been extended
60+
to support other graphics APIs in its foundation, such as Direct3D, Metal and
61+
Vulkan.
62+
63+
Existing application code will largely continue working, but should now
64+
include \l{Qt OpenGL} in project files, as well as include the headers if
65+
these were previously included indirectly through Qt Gui.
66+
67+
\note A notable exception is \l QOpenGLContext, which still resides in
68+
Qt Gui.
69+
70+
\section1 QOpenGLWidgets
71+
72+
Another exception is the \l QOpenGLWidget class. This has been moved to a new
73+
module named \c{Qt OpenGL Widgets} and should be included from there.
74+
75+
\section1 Selecting the OpenGL backend for RHI
76+
77+
In addition to adjusting project files and including headers, the application
78+
should also manually set the rendering backend to OpenGL in order to use
79+
this functionality when working with Qt Quick. By default, Qt will use the most
80+
appropriate graphics API on the target platform. See the
81+
\l{Rendering via the Qt Rendering Hardware Interface}{RHI rendering documentation}
82+
for more details.
83+
84+
\section1 Removal of ANGLE
85+
86+
On Windows, ANGLE, a third-party OpenGL ES to Direct 3D translator, is no
87+
longer included in Qt 6. This means \c Qt::AA_UseOpenGLES and the
88+
environment variable \c{QT_OPENGL=angle} no longer has any effect. In
89+
dynamic OpenGL builds there is no automatic fallback to ANGLE in case
90+
OpenGL-proper fails to initialize. For QWindow or QWidget based applications
91+
using OpenGL directly, for example via QOpenGLWidget, this means that
92+
OpenGL-proper is the only option at runtime. However, the use of a pure
93+
software OpenGL implementation, such as Mesa llvmpipe that is shipped with
94+
the pre-built Qt packages, is still available.
95+
96+
For Qt Quick and Qt Quick 3D applications, Qt 6 introduces support for
97+
Direct 3D 11, Vulkan, and Metal, in addition to OpenGL. On Windows, Qt 6
98+
defaults to Direct 3D, therefore the effect of the removal of ANGLE is
99+
lessened by the addition of support to other graphics APIs.
46100
*/

src/opengl/doc/src/qtopengl-index.qdoc

+42-11
Original file line numberDiff line numberDiff line change
@@ -31,19 +31,50 @@
3131
\brief The Qt OpenGL module offers classes that make it easy to
3232
use OpenGL in Qt applications.
3333

34+
OpenGL is a low-level, cross-platform API for graphics. In Qt,
35+
it can optionally be used as the foundation for rendering.
36+
3437
\section1 Introduction
3538

36-
The Qt OpenGL module makes it easy to use OpenGL in Qt applications.
37-
It provides an OpenGL widget class that can be used just like any
38-
other Qt widget, except that it opens an OpenGL display buffer where
39-
you can use the OpenGL API to render the contents.
40-
41-
The Qt OpenGL module is implemented as a platform-independent Qt/C++
42-
wrapper around the platform-dependent GLX (version 1.3 or later),
43-
WGL, or AGL C APIs. Although the basic functionality provided is very
44-
similar to Mark Kilgard's GLUT library, applications can use the
45-
other \l{All Modules}{Qt modules} to implement the rest of the user
46-
interface.
39+
Qt has two main approaches to UI development: \l[QtQuick]{Qt Quick} and
40+
\l{Qt Widgets}. They exist to support different types of user
41+
interfaces, and build on separate graphics engines which have been
42+
optimized for each of these types.
43+
44+
It is possible to combine code written in the OpenGL graphics API
45+
with both these user interface types in Qt. This can be useful
46+
when the application has its own OpenGL-dependent code, or when it
47+
is integrating with a third-party OpenGL-based renderer.
48+
49+
The Qt OpenGL module contains convenience classes to make this type of
50+
integration easier and faster.
51+
52+
\section1 Qt OpenGL and Qt Widgets
53+
54+
\l{Qt Widgets} is typically rendered by a highly optimized and accurate
55+
software rasterizer, and the final content reproduced on screen using a
56+
method appropriate for the platform where the application is running.
57+
58+
But it is also possible to combine \l{Qt Widgets} with OpenGL. The main entry
59+
point for this is the \l{QOpenGLWidget} class. This class can be used to
60+
enable OpenGL rendering for a certain part of the widget tree, and the
61+
classes in the Qt OpenGL module can be used to facilitate any application-side
62+
OpenGL code.
63+
64+
\section1 Qt OpenGL and Qt Quick
65+
66+
\l[QtQuick]{Qt Quick} is optimized for hardware-accelerated rendering. By default,
67+
it will be built on the low-level graphics API most appropriate for the
68+
target platform.
69+
70+
For instance, it will default to \c Direct3D on Windows, whereas on macOS,
71+
it will default to \c Metal. But the it is also possible to manually
72+
select OpenGL as the active graphics API on platforms where this is supported.
73+
74+
For more details on enabling OpenGL with \l[QtQuick]{Qt Quick}, see
75+
\l{Rendering via the Qt Rendering Hardware Interface}{scenegraph renderer documentation}.
76+
77+
\section1 Overview
4778

4879
The \l{Qt OpenGL C++ Classes} page gives an overview over the available classes
4980
in this module.

0 commit comments

Comments
 (0)