Docs: Remove traces of QGL
The QGL* classes have been removed and the examples ported to QOpenGL, update the documentation to reflect that. Task-number: QTBUG-74408 Change-Id: Ibb4787cdeedc05a807d673943b61838f19092234 Reviewed-by: Laszlo Agocs <laszlo.agocs@qt.io>
This commit is contained in:
parent
734b3a33c1
commit
012bb039e3
@ -30,8 +30,8 @@
|
|||||||
\title 2D Painting Example
|
\title 2D Painting Example
|
||||||
\ingroup examples-widgets-opengl
|
\ingroup examples-widgets-opengl
|
||||||
|
|
||||||
\brief The 2D Painting example shows how QPainter and QGLWidget can be used
|
\brief The 2D Painting example shows how QPainter and QOpenGLWidget can be
|
||||||
together to display accelerated 2D graphics on supported hardware.
|
used together to display accelerated 2D graphics on supported hardware.
|
||||||
|
|
||||||
\image 2dpainting-example.png
|
\image 2dpainting-example.png
|
||||||
|
|
||||||
@ -39,23 +39,23 @@
|
|||||||
paint devices provided by QPaintDevice subclasses, such as QWidget
|
paint devices provided by QPaintDevice subclasses, such as QWidget
|
||||||
and QImage.
|
and QImage.
|
||||||
|
|
||||||
Since QGLWidget is a subclass of QWidget, it is possible
|
Since QOpenGLWidget is a subclass of QWidget, it is possible
|
||||||
to reimplement its \l{QWidget::paintEvent()}{paintEvent()} and use
|
to reimplement its \l{QWidget::paintEvent()}{paintEvent()} and use
|
||||||
QPainter to draw on the device, just as you would with a QWidget.
|
QPainter to draw on the device, just as you would with a QWidget.
|
||||||
The only difference is that the painting operations will be accelerated
|
The only difference is that the painting operations will be accelerated
|
||||||
in hardware if it is supported by your system's OpenGL drivers.
|
in hardware if it is supported by your system's OpenGL drivers.
|
||||||
|
|
||||||
In this example, we perform the same painting operations on a
|
In this example, we perform the same painting operations on a
|
||||||
QWidget and a QGLWidget. The QWidget is shown with anti-aliasing
|
QWidget and a QOpenGLWidget. The QWidget is shown with anti-aliasing
|
||||||
enabled, and the QGLWidget will also use anti-aliasing if the
|
enabled, and the QOpenGLWidget will also use anti-aliasing if the
|
||||||
required extensions are supported by your system's OpenGL driver.
|
required extensions are supported by your system's OpenGL driver.
|
||||||
|
|
||||||
\section1 Overview
|
\section1 Overview
|
||||||
|
|
||||||
To be able to compare the results of painting onto a QGLWidget subclass
|
To be able to compare the results of painting onto a QOpenGLWidget subclass
|
||||||
with native drawing in a QWidget subclass, we want to show both kinds
|
with native drawing in a QWidget subclass, we want to show both kinds
|
||||||
of widget side by side. To do this, we derive subclasses of QWidget and
|
of widget side by side. To do this, we derive subclasses of QWidget and
|
||||||
QGLWidget, using a separate \c Helper class to perform the same painting
|
QOpenGLWidget, using a separate \c Helper class to perform the same painting
|
||||||
operations for each, and lay them out in a top-level widget, itself
|
operations for each, and lay them out in a top-level widget, itself
|
||||||
provided a the \c Window class.
|
provided a the \c Window class.
|
||||||
|
|
||||||
@ -63,7 +63,7 @@
|
|||||||
|
|
||||||
In this example, the painting operations are performed by a helper class.
|
In this example, the painting operations are performed by a helper class.
|
||||||
We do this because we want the same painting operations to be performed
|
We do this because we want the same painting operations to be performed
|
||||||
for both our QWidget subclass and the QGLWidget subclass.
|
for both our QWidget subclass and the QOpenGLWidget subclass.
|
||||||
|
|
||||||
The \c Helper class is minimal:
|
The \c Helper class is minimal:
|
||||||
|
|
||||||
@ -81,7 +81,7 @@
|
|||||||
|
|
||||||
The actual painting is performed in the \c paint() function. This takes
|
The actual painting is performed in the \c paint() function. This takes
|
||||||
a QPainter that has already been set up to paint onto a paint device
|
a QPainter that has already been set up to paint onto a paint device
|
||||||
(either a QWidget or a QGLWidget), a QPaintEvent that provides information
|
(either a QWidget or a QOpenGLWidget), a QPaintEvent that provides information
|
||||||
about the region to be painted, and a measure of the elapsed time (in
|
about the region to be painted, and a measure of the elapsed time (in
|
||||||
milliseconds) since the paint device was last updated.
|
milliseconds) since the paint device was last updated.
|
||||||
|
|
||||||
@ -148,7 +148,7 @@
|
|||||||
\section1 GLWidget Class Definition
|
\section1 GLWidget Class Definition
|
||||||
|
|
||||||
The \c GLWidget class definition is basically the same as the \c Widget
|
The \c GLWidget class definition is basically the same as the \c Widget
|
||||||
class except that it is derived from QGLWidget.
|
class except that it is derived from QOpenGLWidget.
|
||||||
|
|
||||||
\snippet 2dpainting/glwidget.h 0
|
\snippet 2dpainting/glwidget.h 0
|
||||||
|
|
||||||
@ -161,11 +161,8 @@
|
|||||||
|
|
||||||
\snippet 2dpainting/glwidget.cpp 0
|
\snippet 2dpainting/glwidget.cpp 0
|
||||||
|
|
||||||
As well as initializing the \c elapsed member variable and storing the
|
The \c elapsed member variable is initialized and the \c Helper object used
|
||||||
\c Helper object used to paint the widget, the base class's constructor
|
to paint the widget is stored.
|
||||||
is called with the format that specifies the \l QGL::SampleBuffers flag.
|
|
||||||
This enables anti-aliasing if it is supported by your system's OpenGL
|
|
||||||
driver.
|
|
||||||
|
|
||||||
The \c animate() slot is exactly the same as that provided by the \c Widget
|
The \c animate() slot is exactly the same as that provided by the \c Widget
|
||||||
class:
|
class:
|
||||||
|
@ -47,7 +47,7 @@
|
|||||||
The example consist of two classes:
|
The example consist of two classes:
|
||||||
|
|
||||||
\list
|
\list
|
||||||
\li \c MainWidget extends QGLWidget and contains OpenGL ES 2.0
|
\li \c MainWidget extends QOpenGLWidget and contains OpenGL ES 2.0
|
||||||
initialization and drawing and mouse and timer event handling
|
initialization and drawing and mouse and timer event handling
|
||||||
\li \c GeometryEngine handles polygon geometries. Transfers polygon geometry
|
\li \c GeometryEngine handles polygon geometries. Transfers polygon geometry
|
||||||
to vertex buffer objects and draws geometries from vertex buffer objects.
|
to vertex buffer objects and draws geometries from vertex buffer objects.
|
||||||
@ -81,7 +81,7 @@
|
|||||||
|
|
||||||
\snippet cube/fshader.glsl 0
|
\snippet cube/fshader.glsl 0
|
||||||
|
|
||||||
Using \c QGLShaderProgram we can compile, link and bind shader code to
|
Using QOpenGLShaderProgram we can compile, link and bind shader code to
|
||||||
graphics pipeline. This code uses Qt Resource files to access shader source code.
|
graphics pipeline. This code uses Qt Resource files to access shader source code.
|
||||||
|
|
||||||
\snippet cube/mainwidget.cpp 3
|
\snippet cube/mainwidget.cpp 3
|
||||||
@ -92,9 +92,9 @@
|
|||||||
|
|
||||||
\section1 Loading Textures from Qt Resource Files
|
\section1 Loading Textures from Qt Resource Files
|
||||||
|
|
||||||
\c QGLWidget interface implements methods for loading textures from QImage to GL
|
The \c QOpenGLWidget interface implements methods for loading textures from QImage
|
||||||
texture memory. We still need to use OpenGL provided functions for specifying
|
to OpenGL texture memory. We still need to use OpenGL provided functions for
|
||||||
the GL texture unit and configuring texture filtering options.
|
specifying the OpenGL texture unit and configuring texture filtering options.
|
||||||
|
|
||||||
\snippet cube/mainwidget.cpp 4
|
\snippet cube/mainwidget.cpp 4
|
||||||
|
|
||||||
|
@ -545,7 +545,7 @@
|
|||||||
with OpenGL, but without OpenGL it avoids unnecessary re-scaling of the
|
with OpenGL, but without OpenGL it avoids unnecessary re-scaling of the
|
||||||
background pixmap.
|
background pixmap.
|
||||||
\li It sets render hints that increase rendering quality.
|
\li It sets render hints that increase rendering quality.
|
||||||
\li If OpenGL is supported, a QGLWidget viewport is assigned to the view.
|
\li If OpenGL is supported, a QOpenGLWidget viewport is assigned to the view.
|
||||||
\endlist
|
\endlist
|
||||||
|
|
||||||
Finally, we start the state engine.
|
Finally, we start the state engine.
|
||||||
|
@ -39,8 +39,7 @@
|
|||||||
right and Y increases downwards. The unit is one pixel.
|
right and Y increases downwards. The unit is one pixel.
|
||||||
|
|
||||||
The drawing capabilities of QPaintDevice are currently implemented
|
The drawing capabilities of QPaintDevice are currently implemented
|
||||||
by the QWidget, QImage, QPixmap, QGLPixelBuffer, QPicture, and
|
by the QWidget, QImage, QPixmap, QPicture, and QPrinter subclasses.
|
||||||
QPrinter subclasses.
|
|
||||||
|
|
||||||
To implement support for a new backend, you must derive from
|
To implement support for a new backend, you must derive from
|
||||||
QPaintDevice and reimplement the virtual paintEngine() function to
|
QPaintDevice and reimplement the virtual paintEngine() function to
|
||||||
|
@ -60,8 +60,8 @@ QT_BEGIN_NAMESPACE
|
|||||||
|
|
||||||
QOpenGLWindow is an enhanced QWindow that allows easily creating windows that
|
QOpenGLWindow is an enhanced QWindow that allows easily creating windows that
|
||||||
perform OpenGL rendering using an API that is compatible with QOpenGLWidget
|
perform OpenGL rendering using an API that is compatible with QOpenGLWidget
|
||||||
and is similar to the legacy QGLWidget. Unlike QOpenGLWidget, QOpenGLWindow
|
Unlike QOpenGLWidget, QOpenGLWindow has no dependency on the widgets module
|
||||||
has no dependency on the widgets module and offers better performance.
|
and offers better performance.
|
||||||
|
|
||||||
A typical application will subclass QOpenGLWindow and reimplement the following
|
A typical application will subclass QOpenGLWindow and reimplement the following
|
||||||
virtual functions:
|
virtual functions:
|
||||||
@ -100,8 +100,8 @@ QT_BEGIN_NAMESPACE
|
|||||||
QPainter-based drawing.
|
QPainter-based drawing.
|
||||||
|
|
||||||
QOpenGLWindow supports multiple update behaviors. The default,
|
QOpenGLWindow supports multiple update behaviors. The default,
|
||||||
\c NoPartialUpdate is equivalent to a regular, OpenGL-based QWindow or the
|
\c NoPartialUpdate is equivalent to a regular, OpenGL-based QWindow. In
|
||||||
legacy QGLWidget. In contrast, \c PartialUpdateBlit and \c PartialUpdateBlend are
|
contrast, \c PartialUpdateBlit and \c PartialUpdateBlend are
|
||||||
more in line with QOpenGLWidget's way of working, where there is always an
|
more in line with QOpenGLWidget's way of working, where there is always an
|
||||||
extra, dedicated framebuffer object present. These modes allow, by
|
extra, dedicated framebuffer object present. These modes allow, by
|
||||||
sacrificing some performance, redrawing only a smaller area on each paint and
|
sacrificing some performance, redrawing only a smaller area on each paint and
|
||||||
|
@ -117,7 +117,7 @@
|
|||||||
of a scene. You can attach several views to the same scene, to provide
|
of a scene. You can attach several views to the same scene, to provide
|
||||||
several viewports into the same data set. The view widget is a scroll
|
several viewports into the same data set. The view widget is a scroll
|
||||||
area, and provides scroll bars for navigating through large scenes. To
|
area, and provides scroll bars for navigating through large scenes. To
|
||||||
enable OpenGL support, you can set a QGLWidget as the viewport by
|
enable OpenGL support, you can set a QOpenGLWidget as the viewport by
|
||||||
calling QGraphicsView::setViewport().
|
calling QGraphicsView::setViewport().
|
||||||
|
|
||||||
\snippet graphicsview.cpp 1
|
\snippet graphicsview.cpp 1
|
||||||
@ -436,10 +436,10 @@
|
|||||||
|
|
||||||
\section2 OpenGL Rendering
|
\section2 OpenGL Rendering
|
||||||
|
|
||||||
To enable OpenGL rendering, you simply set a new QGLWidget as the
|
To enable OpenGL rendering, you simply set a new QOpenGLWidget as the
|
||||||
viewport of QGraphicsView by calling QGraphicsView::setViewport(). If
|
viewport of QGraphicsView by calling QGraphicsView::setViewport(). If
|
||||||
you want OpenGL with antialiasing, you need OpenGL sample buffer
|
you want OpenGL with antialiasing, you need OpenGL sample buffer
|
||||||
support (see QGLFormat::sampleBuffers()).
|
support (see QSurfaceFormat::samples()).
|
||||||
|
|
||||||
Example:
|
Example:
|
||||||
|
|
||||||
|
@ -4913,9 +4913,6 @@ void qt_qpa_set_cursor(QWidget *w, bool force)
|
|||||||
|
|
||||||
\note To obtain the contents of a QOpenGLWidget, use QOpenGLWidget::grabFramebuffer()
|
\note To obtain the contents of a QOpenGLWidget, use QOpenGLWidget::grabFramebuffer()
|
||||||
instead.
|
instead.
|
||||||
|
|
||||||
\note To obtain the contents of a QGLWidget (deprecated), use
|
|
||||||
QGLWidget::grabFrameBuffer() or QGLWidget::renderPixmap() instead.
|
|
||||||
*/
|
*/
|
||||||
void QWidget::render(QPaintDevice *target, const QPoint &targetOffset,
|
void QWidget::render(QPaintDevice *target, const QPoint &targetOffset,
|
||||||
const QRegion &sourceRegion, RenderFlags renderFlags)
|
const QRegion &sourceRegion, RenderFlags renderFlags)
|
||||||
|
@ -1349,7 +1349,7 @@ bool QMainWindow::event(QEvent *event)
|
|||||||
|
|
||||||
Note that the Qt 5 implementation has several limitations compared to Qt 4:
|
Note that the Qt 5 implementation has several limitations compared to Qt 4:
|
||||||
\list
|
\list
|
||||||
\li Use in windows with OpenGL content is not supported. This includes QGLWidget and QOpenGLWidget.
|
\li Use in windows with OpenGL content is not supported. This includes QOpenGLWidget.
|
||||||
\li Using dockable or movable toolbars may result in painting errors and is not recommended
|
\li Using dockable or movable toolbars may result in painting errors and is not recommended
|
||||||
\endlist
|
\endlist
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user