QOffscreenSurface Class
The QOffscreenSurface class represents an offscreen surface in the underlying platform. More…
| Header | #include <QOffscreenSurface> |
|---|---|
| CMake | target_link_libraries(app PRIVATE Nt::Gui) |
| Module | Nt GUI C++ Classes |
| Since | 6.0 |
| Inherits | QObject, QSurface |
List of all members, including inherited members
Public Functions
| QOffscreenSurface(QScreen *screen = nullptr, QObject *parent = nullptr) | |
| ~QOffscreenSurface() | |
| void | create() |
| void | destroy() |
| bool | isValid() const |
| void | setFormat(const QSurfaceFormat &format) |
| QSurfaceFormat | requestedFormat() const |
| QScreen * | screen() const |
| void | setScreen(QScreen *screen) |
Reimplemented Public Functions
| SurfaceType | surfaceType() const |
| QSurfaceFormat | format() const |
| QSize | size() const |
Signals
| void | screenChanged(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
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.
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().
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.
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.
QSize QOffscreenSurface::size() const
Reimplements QSurface::size().
Returns the size of the surface, which is one by one pixel.
SurfaceType QOffscreenSurface::surfaceType() const
Reimplements QSurface::surfaceType().
Returns QSurface::OpenGLSurface.