QCPPaintBufferGlFbo Class Reference
Author: Emanuel Eichhammer

· · · ·
Public Functions | Protected Functions
QCPPaintBufferGlFbo Class Reference

A paint buffer based on OpenGL frame buffers objects, using hardware accelerated rendering. More...

Inheritance diagram for QCPPaintBufferGlFbo:

## Public Functions
| QCPPaintBufferGlFbo (const QSize &size, double devicePixelRatio, QWeakPointer< QOpenGLContext > glContext, QWeakPointer< QOpenGLPaintDevice > glPaintDevice)
virtual QCPPainter * | startPainting ()
virtual void | donePainting ()
virtual void | draw (QCPPainter *painter) const
void | clear (const QColor &color)
Public Functions inherited from QCPAbstractPaintBuffer
| QCPAbstractPaintBuffer (const QSize &size, double devicePixelRatio)
QSize | size () const
bool | invalidated () const
double | devicePixelRatio () const
void | setSize (const QSize &size)
void | setInvalidated (bool invalidated=true)
void | setDevicePixelRatio (double ratio)
virtual QCPPainter * | startPainting ()=0
virtual void | donePainting ()
virtual void | draw (QCPPainter *painter) const =0
virtual void | clear (const QColor &color)=0

## Protected Functions
virtual void | reallocateBuffer ()
virtual void | reallocateBuffer ()=0

## Detailed Description

A paint buffer based on OpenGL frame buffers objects, using hardware accelerated rendering.

This paint buffer is one of the OpenGL paint buffers which facilitate hardware accelerated plot rendering. It is based on OpenGL frame buffer objects (fbo) and is used in Qt versions 5.0 and higher. (See QCPPaintBufferGlPbuffer used in older Qt versions.)

The OpenGL paint buffers are used if QCustomPlot::setOpenGl is set to true, and if they are supported by the system.

## Constructor & Destructor Documentation

## ◆ QCPPaintBufferGlFbo()

QCPPaintBufferGlFbo::QCPPaintBufferGlFbo | ( | const QSize & | size,
|  | double | devicePixelRatio,
|  | QWeakPointer< QOpenGLContext > | glContext,
|  | QWeakPointer< QOpenGLPaintDevice > | glPaintDevice
| ) |  |
| explicit

Creates a QCPPaintBufferGlFbo instance with the specified size and devicePixelRatio, if applicable.

All frame buffer objects shall share one OpenGL context and paint device, which need to be set up externally and passed via glContext and glPaintDevice. The set-up is done in QCustomPlot::setupOpenGl and the context and paint device are managed by the parent QCustomPlot instance.

## Member Function Documentation

## ◆ startPainting()

QCPPainter * QCPPaintBufferGlFbo::startPainting | ( |  | ) |
| virtual

Returns a QCPPainter which is ready to draw to this buffer. The ownership and thus the responsibility to delete the painter after the painting operations are complete is given to the caller of this method.

Once you are done using the painter, delete the painter and call donePainting.

While a painter generated with this method is active, you must not call setSize, setDevicePixelRatio or clear.

This method may return 0, if a painter couldn't be activated on the buffer. This usually indicates a problem with the respective painting backend.

Implements QCPAbstractPaintBuffer.

## ◆ donePainting()

void QCPPaintBufferGlFbo::donePainting | ( |  | ) |
| virtual

If you have acquired a QCPPainter to paint onto this paint buffer via startPainting, call this method as soon as you are done with the painting operations and have deleted the painter.

paint buffer subclasses may use this method to perform any type of cleanup that is necessary. The default implementation does nothing.

Reimplemented from QCPAbstractPaintBuffer.

## ◆ draw()

void QCPPaintBufferGlFbo::draw | ( | QCPPainter * | painter | ) | const
| virtual

Draws the contents of this buffer with the provided painter. This is the method that is used to finally join all paint buffers and draw them onto the screen.

Implements QCPAbstractPaintBuffer.

## ◆ clear()

void QCPPaintBufferGlFbo::clear | ( | const QColor & | color | ) |
| virtual

Fills the entire buffer with the provided color. To have an empty transparent buffer, use the named color `Qt::transparent`.

This method must not be called if there is currently a painter (acquired with startPainting) active.

Implements QCPAbstractPaintBuffer.

## ◆ reallocateBuffer()

void QCPPaintBufferGlFbo::reallocateBuffer | ( |  | ) |
| protectedvirtual

Reallocates the internal buffer with the currently configured size (setSize) and device pixel ratio, if applicable (setDevicePixelRatio). It is called as soon as any of those properties are changed on this paint buffer.

Note
  Subclasses of QCPAbstractPaintBuffer must call their reimplementation of this method in their constructor, to perform the first allocation (this can not be done by the base class because calling pure virtual methods in base class constructors is not possible).

Implements QCPAbstractPaintBuffer.

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

- src/paintbuffer.h
- src/paintbuffer.cpp