Qt
Internal/Contributor docs for the Qt SDK. <b>Note:</b> These are NOT official API docs; those are found <a href='https://doc.qt.io/'>here</a>.
Loading...
Searching...
No Matches
QOpenGLPaintDevice Class Reference

The QOpenGLPaintDevice class enables painting to an OpenGL context using QPainter. More...

#include <qopenglpaintdevice.h>

+ Inheritance diagram for QOpenGLPaintDevice:
+ Collaboration diagram for QOpenGLPaintDevice:

Public Member Functions

 QOpenGLPaintDevice ()
 Constructs a QOpenGLPaintDevice.
 
 QOpenGLPaintDevice (const QSize &size)
 Constructs a QOpenGLPaintDevice with the given size.
 
 QOpenGLPaintDevice (int width, int height)
 Constructs a QOpenGLPaintDevice with the given width and height.
 
 ~QOpenGLPaintDevice ()
 Destroys the QOpenGLPaintDevice.
 
int devType () const override
 
QPaintEnginepaintEngine () const override
 \reimp
 
QOpenGLContextcontext () const
 Returns the OpenGL context associated with the paint device.
 
QSize size () const
 Returns the pixel size of the paint device.
 
void setSize (const QSize &size)
 Sets the pixel size of the paint device to size.
 
void setDevicePixelRatio (qreal devicePixelRatio)
 Sets the device pixel ratio for the paint device to devicePixelRatio.
 
qreal dotsPerMeterX () const
 Returns the number of pixels per meter horizontally.
 
qreal dotsPerMeterY () const
 Returns the number of pixels per meter vertically.
 
void setDotsPerMeterX (qreal)
 Sets the number of pixels per meter horizontally to dpmx.
 
void setDotsPerMeterY (qreal)
 Sets the number of pixels per meter vertically to dpmy.
 
void setPaintFlipped (bool flipped)
 Sets whether painting should be flipped around the Y-axis or not to flipped.
 
bool paintFlipped () const
 Returns true if painting is flipped around the Y-axis.
 
virtual void ensureActiveTarget ()
 This virtual method is provided as a callback to allow re-binding a target frame buffer object or context when different QOpenGLPaintDevice instances are issuing draw calls alternately.
 
- Public Member Functions inherited from QPaintDevice
virtual ~QPaintDevice ()
 
bool paintingActive () const
 
int width () const
 
int height () const
 
int widthMM () const
 
int heightMM () const
 
int logicalDpiX () const
 
int logicalDpiY () const
 
int physicalDpiX () const
 
int physicalDpiY () const
 
qreal devicePixelRatio () const
 
qreal devicePixelRatioF () const
 
int colorCount () const
 
int depth () const
 

Protected Member Functions

 QOpenGLPaintDevice (QOpenGLPaintDevicePrivate &dd)
 
int metric (QPaintDevice::PaintDeviceMetric metric) const override
 \reimp
 
- Protected Member Functions inherited from QPaintDevice
 QPaintDevice () noexcept
 
virtual void initPainter (QPainter *painter) const
 
virtual QPaintDeviceredirected (QPoint *offset) const
 
virtual QPaintersharedPainter () const
 

Protected Attributes

QScopedPointer< QOpenGLPaintDevicePrivated_ptr
 
- Protected Attributes inherited from QPaintDevice
ushort painters
 

Additional Inherited Members

- Public Types inherited from QPaintDevice
enum  PaintDeviceMetric {
  PdmWidth = 1 , PdmHeight , PdmWidthMM , PdmHeightMM ,
  PdmNumColors , PdmDepth , PdmDpiX , PdmDpiY ,
  PdmPhysicalDpiX , PdmPhysicalDpiY , PdmDevicePixelRatio , PdmDevicePixelRatioScaled
}
 
- Static Public Member Functions inherited from QPaintDevice
static qreal devicePixelRatioFScale ()
 

Detailed Description

The QOpenGLPaintDevice class enables painting to an OpenGL context using QPainter.

Since
5.0 \inmodule QtOpenGL

The QOpenGLPaintDevice uses the current QOpenGL context to render QPainter draw commands. The context is captured upon construction. It requires support for OpenGL (ES) 2.0 or higher.

Definition at line 19 of file qopenglpaintdevice.h.

Constructor & Destructor Documentation

◆ QOpenGLPaintDevice() [1/4]

QOpenGLPaintDevice::QOpenGLPaintDevice ( )

Constructs a QOpenGLPaintDevice.

The QOpenGLPaintDevice is only valid for the current context.

See also
QOpenGLContext::currentContext()

Definition at line 79 of file qopenglpaintdevice.cpp.

◆ QOpenGLPaintDevice() [2/4]

QOpenGLPaintDevice::QOpenGLPaintDevice ( const QSize & size)
explicit

Constructs a QOpenGLPaintDevice with the given size.

The QOpenGLPaintDevice is only valid for the current context.

See also
QOpenGLContext::currentContext()

Definition at line 91 of file qopenglpaintdevice.cpp.

◆ QOpenGLPaintDevice() [3/4]

QOpenGLPaintDevice::QOpenGLPaintDevice ( int width,
int height )

Constructs a QOpenGLPaintDevice with the given width and height.

The QOpenGLPaintDevice is only valid for the current context.

See also
QOpenGLContext::currentContext()

Definition at line 103 of file qopenglpaintdevice.cpp.

◆ ~QOpenGLPaintDevice()

QOpenGLPaintDevice::~QOpenGLPaintDevice ( )

Destroys the QOpenGLPaintDevice.

Definition at line 120 of file qopenglpaintdevice.cpp.

References d_ptr, and QOpenGLPaintDevicePrivate::engine.

◆ QOpenGLPaintDevice() [4/4]

QOpenGLPaintDevice::QOpenGLPaintDevice ( QOpenGLPaintDevicePrivate & dd)
protected

Definition at line 111 of file qopenglpaintdevice.cpp.

Member Function Documentation

◆ context()

QOpenGLContext * QOpenGLPaintDevice::context ( ) const

Returns the OpenGL context associated with the paint device.

Definition at line 184 of file qopenglpaintdevice.cpp.

References QOpenGLPaintDevicePrivate::ctx, and d_ptr.

Referenced by QOpenGL2PaintEngineExPrivate::fill().

+ Here is the caller graph for this function:

◆ devType()

int QOpenGLPaintDevice::devType ( ) const
inlineoverridevirtual

\reimp

Reimplemented from QPaintDevice.

Definition at line 28 of file qopenglpaintdevice.h.

References QInternal::OpenGL.

◆ dotsPerMeterX()

qreal QOpenGLPaintDevice::dotsPerMeterX ( ) const

Returns the number of pixels per meter horizontally.

See also
setDotsPerMeterX()

Definition at line 263 of file qopenglpaintdevice.cpp.

References d_ptr, and QOpenGLPaintDevicePrivate::dpmx.

◆ dotsPerMeterY()

qreal QOpenGLPaintDevice::dotsPerMeterY ( ) const

Returns the number of pixels per meter vertically.

See also
setDotsPerMeterY()

Definition at line 274 of file qopenglpaintdevice.cpp.

References d_ptr, and QOpenGLPaintDevicePrivate::dpmy.

◆ ensureActiveTarget()

void QOpenGLPaintDevice::ensureActiveTarget ( )
virtual

This virtual method is provided as a callback to allow re-binding a target frame buffer object or context when different QOpenGLPaintDevice instances are issuing draw calls alternately.

\l{QPainter::beginNativePainting()}{beginNativePainting()} will also trigger this method.

The default implementation does nothing.

Reimplemented in QOpenGLWindowPaintDevice, and QOpenGLWidgetPaintDevice.

Definition at line 332 of file qopenglpaintdevice.cpp.

Referenced by QOpenGL2PaintEngineEx::begin().

+ Here is the caller graph for this function:

◆ metric()

int QOpenGLPaintDevice::metric ( QPaintDevice::PaintDeviceMetric metric) const
overrideprotectedvirtual

\reimp

Reimplemented from QPaintDevice.

Definition at line 223 of file qopenglpaintdevice.cpp.

References d_ptr, QOpenGLPaintDevicePrivate::devicePixelRatio, QPaintDevice::devicePixelRatioFScale(), QOpenGLPaintDevicePrivate::dpmx, QOpenGLPaintDevicePrivate::dpmy, QSize::height(), metric(), QPaintDevice::PdmDepth, QPaintDevice::PdmDevicePixelRatio, QPaintDevice::PdmDevicePixelRatioScaled, QPaintDevice::PdmDpiX, QPaintDevice::PdmDpiY, QPaintDevice::PdmHeight, QPaintDevice::PdmHeightMM, QPaintDevice::PdmNumColors, QPaintDevice::PdmPhysicalDpiX, QPaintDevice::PdmPhysicalDpiY, QPaintDevice::PdmWidth, QPaintDevice::PdmWidthMM, qRound(), qWarning, QOpenGLPaintDevicePrivate::size, and QSize::width().

Referenced by metric().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ paintEngine()

QPaintEngine * QOpenGLPaintDevice::paintEngine ( ) const
overridevirtual

\reimp

Implements QPaintDevice.

Definition at line 166 of file qopenglpaintdevice.cpp.

References engine.

◆ paintFlipped()

bool QOpenGLPaintDevice::paintFlipped ( ) const

Returns true if painting is flipped around the Y-axis.

See also
setPaintFlipped()

Definition at line 317 of file qopenglpaintdevice.cpp.

References d_ptr, and QOpenGLPaintDevicePrivate::flipped.

Referenced by QOpenGL2PaintEngineExPrivate::setScissor(), QOpenGL2PaintEngineExPrivate::updateBrushUniforms(), and QOpenGL2PaintEngineExPrivate::updateMatrix().

+ Here is the caller graph for this function:

◆ setDevicePixelRatio()

void QOpenGLPaintDevice::setDevicePixelRatio ( qreal devicePixelRatio)

Sets the device pixel ratio for the paint device to devicePixelRatio.

Definition at line 214 of file qopenglpaintdevice.cpp.

References d_ptr, QPaintDevice::devicePixelRatio(), and QOpenGLPaintDevicePrivate::devicePixelRatio.

Referenced by QOpenGLWindowPrivate::beginPaint(), QOpenGLWidgetPrivate::initialize(), and QOpenGLWidgetPrivate::recreateFbos().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ setDotsPerMeterX()

void QOpenGLPaintDevice::setDotsPerMeterX ( qreal dpmx)

Sets the number of pixels per meter horizontally to dpmx.

See also
dotsPerMeterX()

Definition at line 285 of file qopenglpaintdevice.cpp.

References d_ptr, and QOpenGLPaintDevicePrivate::dpmx.

◆ setDotsPerMeterY()

void QOpenGLPaintDevice::setDotsPerMeterY ( qreal dpmy)

Sets the number of pixels per meter vertically to dpmy.

See also
dotsPerMeterY()

Definition at line 296 of file qopenglpaintdevice.cpp.

References d_ptr, and QOpenGLPaintDevicePrivate::dpmy.

◆ setPaintFlipped()

void QOpenGLPaintDevice::setPaintFlipped ( bool flipped)

Sets whether painting should be flipped around the Y-axis or not to flipped.

See also
paintFlipped()

Definition at line 306 of file qopenglpaintdevice.cpp.

References d_ptr, and QOpenGLPaintDevicePrivate::flipped.

◆ setSize()

void QOpenGLPaintDevice::setSize ( const QSize & size)

Sets the pixel size of the paint device to size.

See also
size()

Definition at line 206 of file qopenglpaintdevice.cpp.

References d_ptr, size(), and QOpenGLPaintDevicePrivate::size.

Referenced by QOpenGLWindowPrivate::beginPaint(), QOpenGLWidgetPrivate::initialize(), and QOpenGLWidgetPrivate::recreateFbos().

+ Here is the call graph for this function:
+ Here is the caller graph for this function:

◆ size()

QSize QOpenGLPaintDevice::size ( ) const

Returns the pixel size of the paint device.

See also
setSize()

Definition at line 195 of file qopenglpaintdevice.cpp.

References d_ptr, and QOpenGLPaintDevicePrivate::size.

Referenced by setSize().

+ Here is the caller graph for this function:

Member Data Documentation

◆ d_ptr


The documentation for this class was generated from the following files: