[][src]Struct qt_gui::QOffscreenSurface

#[repr(C)]pub struct QOffscreenSurface { /* fields omitted */ }

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

C++ class: QOffscreenSurface.

C++ documentation:

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

QOffscreenSurface is intended to be used with QOpenGLContext to allow rendering with OpenGL in an arbitrary thread without the need to create a QWindow.

Even though the surface is typically renderable, the surface's pixels are not accessible. QOffscreenSurface should only be used to create OpenGL resources such as textures or framebuffer objects.

An application will typically use QOffscreenSurface to perform some time-consuming tasks in a separate thread in order to avoid stalling the main rendering thread. Resources created in the QOffscreenSurface's context can be shared with the main OpenGL context. Some common use cases are asynchronous texture uploads or rendering into a QOpenGLFramebufferObject.

How the offscreen surface is implemented depends on the underlying platform, but it will typically use a pixel buffer (pbuffer). If the platform doesn't implement or support offscreen surfaces, QOffscreenSurface will use an invisible QWindow internally.

Note: Due to the fact that QOffscreenSurface is backed by a QWindow on some platforms, cross-platform applications must ensure that create() is only called on the main (GUI) thread. The QOffscreenSurface is then safe to be used with makeCurrent() on other threads, but the initialization and destruction must always happen on the main (GUI) thread.

Note: In order to create an offscreen surface that is guaranteed to be compatible with a given context and window, make sure to set the format to the context's or the window's actual format, that is, the QSurfaceFormat returned from QOpenGLContext::format() or QWindow::format() after the context or window has been created. Passing the format returned from QWindow::requestedFormat() to setFormat() may result in an incompatible offscreen surface since the underlying windowing system interface may offer a different set of configurations for window and pbuffer surfaces.

Note: Some platforms may utilize a surfaceless context extension (for example EGL_KHR_surfaceless_context) when available. In this case there will be no underlying native surface. For the use cases of QOffscreenSurface (rendering to FBOs, texture upload) this is not a problem.

Methods

impl QOffscreenSurface[src]

pub fn screen_changed(&self) -> Signal<(*mut QScreen,)>[src]

This signal is emitted when an offscreen surface's screen changes, either by being set explicitly with setScreen(), or automatically when the window's screen is removed.

Returns a built-in Qt signal QOffscreenSurface::screenChanged that can be passed to qt_core::Signal::connect.

C++ documentation:

This signal is emitted when an offscreen surface's screen changes, either by being set explicitly with setScreen(), or automatically when the window's screen is removed.

pub fn slot_screen_destroyed(&self) -> Receiver<(*mut QObject,)>[src]

Returns a built-in Qt slot QOffscreenSurface::screenDestroyed that can be passed to qt_core::Signal::connect.

pub unsafe fn create(&self)[src]

Allocates the platform resources associated with the offscreen surface.

Calls C++ function: void QOffscreenSurface::create().

C++ documentation:

Allocates the platform resources associated with the offscreen surface.

It is at this point that the surface format set using setFormat() gets resolved into an actual native surface.

Call destroy() to free the platform resources if necessary.

Note: Some platforms require this function to be called on the main (GUI) thread.

See also destroy().

pub unsafe fn destroy(&self)[src]

Releases the native platform resources associated with this offscreen surface.

Calls C++ function: void QOffscreenSurface::destroy().

C++ documentation:

Releases the native platform resources associated with this offscreen surface.

See also create().

pub unsafe fn format(&self) -> CppBox<QSurfaceFormat>[src]

Reimplemented from QSurface::format().

Calls C++ function: virtual QSurfaceFormat QOffscreenSurface::format() const.

C++ documentation:

Reimplemented from QSurface::format().

Returns the actual format of this offscreen surface.

After the offscreen surface has been created, this function will return the actual surface format of the surface. It might differ from the requested format if the requested format could not be fulfilled by the platform.

See also setFormat(), create(), and requestedFormat().

pub unsafe fn is_valid(&self) -> bool[src]

Returns true if this offscreen surface is valid; otherwise returns false.

Calls C++ function: bool QOffscreenSurface::isValid() const.

C++ documentation:

Returns true if this offscreen surface is valid; otherwise returns false.

The offscreen surface is valid if the platform resources have been successfuly allocated.

See also create().

pub unsafe fn meta_object(&self) -> Ptr<QMetaObject>[src]

Calls C++ function: virtual const QMetaObject* QOffscreenSurface::metaObject() const.

pub unsafe fn native_handle(&self) -> *mut c_void[src]

Returns an optional native handle to which the offscreen surface is connected.

Calls C++ function: void* QOffscreenSurface::nativeHandle() const.

C++ documentation:

Returns an optional native handle to which the offscreen surface is connected.

This function was introduced in Qt 5.9.

See also setNativeHandle().

pub unsafe fn new_1a(
    screen: impl CastInto<Ptr<QScreen>>
) -> QBox<QOffscreenSurface>
[src]

Creates an offscreen surface for the targetScreen.

Calls C++ function: [constructor] void QOffscreenSurface::QOffscreenSurface(QScreen* screen = …).

C++ documentation:

Creates an offscreen surface for the targetScreen.

The underlying platform surface is not created until create() is called.

See also setScreen() and create().

pub unsafe fn new_0a() -> QBox<QOffscreenSurface>[src]

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

Calls C++ function: [constructor] void QOffscreenSurface::QOffscreenSurface().

C++ documentation:

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

QOffscreenSurface is intended to be used with QOpenGLContext to allow rendering with OpenGL in an arbitrary thread without the need to create a QWindow.

Even though the surface is typically renderable, the surface's pixels are not accessible. QOffscreenSurface should only be used to create OpenGL resources such as textures or framebuffer objects.

An application will typically use QOffscreenSurface to perform some time-consuming tasks in a separate thread in order to avoid stalling the main rendering thread. Resources created in the QOffscreenSurface's context can be shared with the main OpenGL context. Some common use cases are asynchronous texture uploads or rendering into a QOpenGLFramebufferObject.

How the offscreen surface is implemented depends on the underlying platform, but it will typically use a pixel buffer (pbuffer). If the platform doesn't implement or support offscreen surfaces, QOffscreenSurface will use an invisible QWindow internally.

Note: Due to the fact that QOffscreenSurface is backed by a QWindow on some platforms, cross-platform applications must ensure that create() is only called on the main (GUI) thread. The QOffscreenSurface is then safe to be used with makeCurrent() on other threads, but the initialization and destruction must always happen on the main (GUI) thread.

Note: In order to create an offscreen surface that is guaranteed to be compatible with a given context and window, make sure to set the format to the context's or the window's actual format, that is, the QSurfaceFormat returned from QOpenGLContext::format() or QWindow::format() after the context or window has been created. Passing the format returned from QWindow::requestedFormat() to setFormat() may result in an incompatible offscreen surface since the underlying windowing system interface may offer a different set of configurations for window and pbuffer surfaces.

Note: Some platforms may utilize a surfaceless context extension (for example EGL_KHR_surfaceless_context) when available. In this case there will be no underlying native surface. For the use cases of QOffscreenSurface (rendering to FBOs, texture upload) this is not a problem.

pub unsafe fn new_2a(
    screen: impl CastInto<Ptr<QScreen>>,
    parent: impl CastInto<Ptr<QObject>>
) -> QBox<QOffscreenSurface>
[src]

This is supported on cpp_lib_version="5.11.3" or cpp_lib_version="5.12.2" or cpp_lib_version="5.13.0" or cpp_lib_version="5.14.0" only.

Creates an offscreen surface for the targetScreen with the given parent.

Calls C++ function: [constructor] void QOffscreenSurface::QOffscreenSurface(QScreen* screen, QObject* parent).

C++ documentation:

Creates an offscreen surface for the targetScreen with the given parent.

The underlying platform surface is not created until create() is called.

This function was introduced in Qt 5.10.

See also setScreen() and create().

pub unsafe fn qt_metacall(
    &self,
    arg1: Call,
    arg2: c_int,
    arg3: *mut *mut c_void
) -> c_int
[src]

Calls C++ function: virtual int QOffscreenSurface::qt_metacall(QMetaObject::Call arg1, int arg2, void** arg3).

pub unsafe fn qt_metacast(&self, arg1: *const c_char) -> *mut c_void[src]

Calls C++ function: virtual void* QOffscreenSurface::qt_metacast(const char* arg1).

pub unsafe fn requested_format(&self) -> CppBox<QSurfaceFormat>[src]

Returns the requested surfaceformat of this offscreen surface.

Calls C++ function: QSurfaceFormat QOffscreenSurface::requestedFormat() const.

C++ documentation:

Returns the requested surfaceformat of this offscreen surface.

If the requested format was not supported by the platform implementation, the requestedFormat will differ from the actual offscreen surface format.

This is the value set with setFormat().

See also setFormat() and format().

pub unsafe fn screen(&self) -> QPtr<QScreen>[src]

Returns the screen to which the offscreen surface is connected.

Calls C++ function: QScreen* QOffscreenSurface::screen() const.

C++ documentation:

Returns the screen to which the offscreen surface is connected.

See also setScreen().

pub unsafe fn set_format(&self, format: impl CastInto<Ref<QSurfaceFormat>>)[src]

Sets the offscreen surface format.

Calls C++ function: void QOffscreenSurface::setFormat(const QSurfaceFormat& format).

C++ documentation:

Sets the offscreen surface format.

The surface format will be resolved in the create() function. Calling this function after create() will not re-resolve the surface format of the native surface.

See also format(), create(), and destroy().

pub unsafe fn set_native_handle(&self, handle: *mut c_void)[src]

Sets the native handle to which the offscreen surface is connected to handle.

Calls C++ function: void QOffscreenSurface::setNativeHandle(void* handle).

C++ documentation:

Sets the native handle to which the offscreen surface is connected to handle.

The native handle will be resolved in the create() function. Calling this function after create() will not re-create a native surface.

Note: The interpretation of the native handle is platform specific. Only some platforms will support adopting native handles of offscreen surfaces and platforms that do not implement this support will ignore the handle.

This function was introduced in Qt 5.9.

See also nativeHandle().

pub unsafe fn set_screen(&self, screen: impl CastInto<Ptr<QScreen>>)[src]

Sets the screen to which the offscreen surface is connected.

Calls C++ function: void QOffscreenSurface::setScreen(QScreen* screen).

C++ documentation:

Sets the screen to which the offscreen surface is connected.

If the offscreen surface has been created, it will be recreated on the newScreen.

See also screen().

pub unsafe fn size(&self) -> CppBox<QSize>[src]

Reimplemented from QSurface::size().

Calls C++ function: virtual QSize QOffscreenSurface::size() const.

C++ documentation:

Reimplemented from QSurface::size().

Returns the size of the offscreen surface.

pub unsafe fn static_meta_object() -> Ref<QMetaObject>[src]

Returns a reference to the staticMetaObject field.

pub unsafe fn surface_type(&self) -> SurfaceType[src]

Reimplemented from QSurface::surfaceType().

Calls C++ function: virtual QSurface::SurfaceType QOffscreenSurface::surfaceType() const.

C++ documentation:

Reimplemented from QSurface::surfaceType().

Returns the surface type of the offscreen surface.

The surface type of an offscreen surface is always QSurface::OpenGLSurface.

pub unsafe fn tr(
    s: *const c_char,
    c: *const c_char,
    n: c_int
) -> CppBox<QString>
[src]

Calls C++ function: static QString QOffscreenSurface::tr(const char* s, const char* c, int n).

pub unsafe fn tr_utf8(
    s: *const c_char,
    c: *const c_char,
    n: c_int
) -> CppBox<QString>
[src]

Calls C++ function: static QString QOffscreenSurface::trUtf8(const char* s, const char* c, int n).

Trait Implementations

impl CppDeletable for QOffscreenSurface[src]

unsafe fn delete(&self)[src]

Destroys the offscreen surface.

Calls C++ function: virtual [destructor] void QOffscreenSurface::~QOffscreenSurface().

C++ documentation:

Destroys the offscreen surface.

impl Deref for QOffscreenSurface[src]

type Target = QObject

The resulting type after dereferencing.

fn deref(&self) -> &QObject[src]

Calls C++ function: QObject* static_cast<QObject*>(QOffscreenSurface* ptr).

impl DynamicCast<QOffscreenSurface> for QObject[src]

unsafe fn dynamic_cast(ptr: Ptr<QObject>) -> Ptr<QOffscreenSurface>[src]

Calls C++ function: QOffscreenSurface* dynamic_cast<QOffscreenSurface*>(QObject* ptr).

impl DynamicCast<QOffscreenSurface> for QSurface[src]

unsafe fn dynamic_cast(ptr: Ptr<QSurface>) -> Ptr<QOffscreenSurface>[src]

Calls C++ function: QOffscreenSurface* dynamic_cast<QOffscreenSurface*>(QSurface* ptr).

impl Size for QOffscreenSurface[src]

unsafe fn size(&self) -> usize[src]

Reimplemented from QSurface::size().

Calls C++ function: virtual QSize QOffscreenSurface::size() const.

C++ documentation:

Reimplemented from QSurface::size().

Returns the size of the offscreen surface.

impl StaticDowncast<QOffscreenSurface> for QObject[src]

unsafe fn static_downcast(ptr: Ptr<QObject>) -> Ptr<QOffscreenSurface>[src]

Calls C++ function: QOffscreenSurface* static_cast<QOffscreenSurface*>(QObject* ptr).

impl StaticDowncast<QOffscreenSurface> for QSurface[src]

unsafe fn static_downcast(ptr: Ptr<QSurface>) -> Ptr<QOffscreenSurface>[src]

Calls C++ function: QOffscreenSurface* static_cast<QOffscreenSurface*>(QSurface* ptr).

impl StaticUpcast<QObject> for QOffscreenSurface[src]

unsafe fn static_upcast(ptr: Ptr<QOffscreenSurface>) -> Ptr<QObject>[src]

Calls C++ function: QObject* static_cast<QObject*>(QOffscreenSurface* ptr).

impl StaticUpcast<QSurface> for QOffscreenSurface[src]

unsafe fn static_upcast(ptr: Ptr<QOffscreenSurface>) -> Ptr<QSurface>[src]

Calls C++ function: QSurface* static_cast<QSurface*>(QOffscreenSurface* ptr).

Auto Trait Implementations

Blanket Implementations

impl<T> Any for T where
    T: 'static + ?Sized
[src]

impl<T> Borrow<T> for T where
    T: ?Sized
[src]

impl<T> BorrowMut<T> for T where
    T: ?Sized
[src]

impl<T, U> CastInto<U> for T where
    U: CastFrom<T>, 
[src]

impl<T> From<T> for T[src]

impl<T, U> Into<U> for T where
    U: From<T>, 
[src]

impl<T> StaticUpcast<T> for T[src]

impl<T, U> TryFrom<U> for T where
    U: Into<T>, 
[src]

type Error = Infallible

The type returned in the event of a conversion error.

impl<T, U> TryInto<U> for T where
    U: TryFrom<T>, 
[src]

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.