6.0.0-rc4Source

QOffscreenSurface Class

The QOffscreenSurface class represents an offscreen surface in the underlying platform. More…

Header#include <QOffscreenSurface>
CMaketarget_link_libraries(app PRIVATE Nt::Gui)
ModuleNt GUI C++ Classes
Since6.0
InheritsQObject, QSurface

List of all members, including inherited members

Public Functions

QOffscreenSurface(QScreen *screen = nullptr, QObject *parent = nullptr)
~QOffscreenSurface()
voidcreate()
voiddestroy()
boolisValid() const
voidsetFormat(const QSurfaceFormat &format)
QSurfaceFormatrequestedFormat() const
QScreen *screen() const
voidsetScreen(QScreen *screen)

Reimplemented Public Functions

SurfaceTypesurfaceType() const
QSurfaceFormatformat() const
QSizesize() const

Signals

voidscreenChanged(QScreen *screen)

Detailed Description

An offscreen surface lets a QOpenGLContext be current without a window, to create textures or render into a framebuffer object:

QOffscreenSurface surface;
surface.create();
QOpenGLContext context;
context.create();
context.makeCurrent(&surface);

See also QOpenGLContext.

Differences from Qt

The surface is a surfaceless EGL context where EGL allows that, and otherwise a pbuffer of one pixel. There is no native handle.

Member Function Documentation

[explicit] QOffscreenSurface::QOffscreenSurface(QScreen *screen = nullptr, QObject *parent = nullptr)

Constructs an offscreen surface for screen, or for the primary screen if it is nullptr, with the given parent. Call create() before using it.

[override] QOffscreenSurface::~QOffscreenSurface()

Destroys the surface.

void QOffscreenSurface::create()

Creates the surface. It is valid if OpenGL is available.

See also isValid() and destroy().

void QOffscreenSurface::destroy()

Releases what OpenGL made for the surface.

See also create().

[override] QSurfaceFormat QOffscreenSurface::format() const

Reimplements QSurface::format().

Returns the format of the surface.

bool QOffscreenSurface::isValid() const

Returns true if create() made the surface.

QSurfaceFormat QOffscreenSurface::requestedFormat() const

Returns the format set with setFormat(), or QSurfaceFormat::defaultFormat().

QScreen * QOffscreenSurface::screen() const

Returns the screen of the surface.

[signal] void QOffscreenSurface::screenChanged(QScreen *screen)

This signal is emitted when the screen of the surface changes to screen.

void QOffscreenSurface::setFormat(const QSurfaceFormat &format)

Sets the requested format.

void QOffscreenSurface::setScreen(QScreen *screen)

Sets the screen of the surface to screen, or to the primary screen if it is nullptr.

[override] QSize QOffscreenSurface::size() const

Reimplements QSurface::size().

Returns the size of the surface, which is one by one pixel.

[override] SurfaceType QOffscreenSurface::surfaceType() const

Reimplements QSurface::surfaceType().

Returns QSurface::OpenGLSurface.