Qt
Internal/Contributor docs for the Qt SDK. Note: These are NOT official API docs; those are found at https://doc.qt.io/
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
 
double getDecodedMetricF (PaintDeviceMetric metricA, PaintDeviceMetric metricB) 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 ,
  PdmDevicePixelRatioF_EncodedA , PdmDevicePixelRatioF_EncodedB
}
 
- Static Public Member Functions inherited from QPaintDevice
static qreal devicePixelRatioFScale ()
 
static int encodeMetricF (PaintDeviceMetric metric, double value)
 

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.

◆ 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.

◆ devType()

int QOpenGLPaintDevice::devType ( ) const
inlineoverridevirtual

\reimp

Reimplemented from QPaintDevice.

Definition at line 28 of file qopenglpaintdevice.h.

◆ dotsPerMeterX()

qreal QOpenGLPaintDevice::dotsPerMeterX ( ) const

Returns the number of pixels per meter horizontally.

See also
setDotsPerMeterX()

Definition at line 267 of file qopenglpaintdevice.cpp.

◆ dotsPerMeterY()

qreal QOpenGLPaintDevice::dotsPerMeterY ( ) const

Returns the number of pixels per meter vertically.

See also
setDotsPerMeterY()

Definition at line 278 of file qopenglpaintdevice.cpp.

◆ 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 QOpenGLWidgetPaintDevice, QOpenGLWidgetPaintDevice, QOpenGLWindowPaintDevice, and QOpenGLWindowPaintDevice.

Definition at line 336 of file qopenglpaintdevice.cpp.

◆ metric()

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

\reimp

Reimplemented from QPaintDevice.

Definition at line 223 of file qopenglpaintdevice.cpp.

◆ paintEngine()

QPaintEngine * QOpenGLPaintDevice::paintEngine ( ) const
overridevirtual

\reimp

Implements QPaintDevice.

Definition at line 166 of file qopenglpaintdevice.cpp.

◆ paintFlipped()

bool QOpenGLPaintDevice::paintFlipped ( ) const

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

See also
setPaintFlipped()

Definition at line 321 of file qopenglpaintdevice.cpp.

◆ 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.

◆ setDotsPerMeterX()

void QOpenGLPaintDevice::setDotsPerMeterX ( qreal dpmx)

Sets the number of pixels per meter horizontally to dpmx.

See also
dotsPerMeterX()

Definition at line 289 of file qopenglpaintdevice.cpp.

◆ setDotsPerMeterY()

void QOpenGLPaintDevice::setDotsPerMeterY ( qreal dpmy)

Sets the number of pixels per meter vertically to dpmy.

See also
dotsPerMeterY()

Definition at line 300 of file qopenglpaintdevice.cpp.

◆ 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 310 of file qopenglpaintdevice.cpp.

◆ 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.

◆ size()

QSize QOpenGLPaintDevice::size ( ) const

Returns the pixel size of the paint device.

See also
setSize()

Definition at line 195 of file qopenglpaintdevice.cpp.

Member Data Documentation

◆ d_ptr

QScopedPointer<QOpenGLPaintDevicePrivate> QOpenGLPaintDevice::d_ptr
protected

Definition at line 52 of file qopenglpaintdevice.h.


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