[][src]Struct qt_gui::QOpenGLTextureBlitter

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

The QOpenGLTextureBlitter class provides a convenient way to draw textured quads via OpenGL.

C++ class: QOpenGLTextureBlitter.

C++ documentation:

The QOpenGLTextureBlitter class provides a convenient way to draw textured quads via OpenGL.

Drawing textured quads, in order to get the contents of a texture onto the screen, is a common operation when developing 2D user interfaces. QOpenGLTextureBlitter provides a convenience class to avoid repeating vertex data, shader sources, buffer and program management and matrix calculations.

For example, a QOpenGLWidget subclass can do the following to draw the contents rendered into a framebuffer at the pixel position (x, y):

void OpenGLWidget::initializeGL() { m_blitter.create(); m_fbo = new QOpenGLFramebufferObject(size); }

void OpenGLWidget::paintGL() { m_fbo->bind(); // update offscreen content m_fbo->release();

m_blitter.bind(); const QRect targetRect(QPoint(x, y), m_fbo->size()); const QMatrix4x4 target = QOpenGLTextureBlitter::targetTransform(targetRect, QRect(QPoint(0, 0), m_fbo->size())); m_blitter.blit(m_fbo->texture(), target, QOpenGLTextureBlitter::OriginBottomLeft); m_blitter.release(); }

The blitter implements GLSL shaders both for GLSL 1.00 (suitable for OpenGL (ES) 2.x and compatibility profiles of newer OpenGL versions) and version 150 (suitable for core profile contexts with OpenGL 3.2 and newer).

Methods

impl QOpenGLTextureBlitter[src]

pub unsafe fn bind_1a(&self, target: c_uint)[src]

Binds the graphics resources used by the blitter. This must be called before calling blit(). Code modifying the OpenGL state should be avoided between the call to bind() and blit() because otherwise conflicts may arise.

Calls C++ function: void QOpenGLTextureBlitter::bind(unsigned int target = …).

C++ documentation:

Binds the graphics resources used by the blitter. This must be called before calling blit(). Code modifying the OpenGL state should be avoided between the call to bind() and blit() because otherwise conflicts may arise.

target is the texture target for the source texture and must be either GL_TEXTURE_2D or GL_OES_EGL_image_external.

See also release() and blit().

pub unsafe fn bind_0a(&self)[src]

Binds the graphics resources used by the blitter. This must be called before calling blit(). Code modifying the OpenGL state should be avoided between the call to bind() and blit() because otherwise conflicts may arise.

Calls C++ function: void QOpenGLTextureBlitter::bind().

C++ documentation:

Binds the graphics resources used by the blitter. This must be called before calling blit(). Code modifying the OpenGL state should be avoided between the call to bind() and blit() because otherwise conflicts may arise.

target is the texture target for the source texture and must be either GL_TEXTURE_2D or GL_OES_EGL_image_external.

See also release() and blit().

pub unsafe fn blit(
    &self,
    texture: u32,
    target_transform: impl CastInto<Ref<QMatrix4X4>>,
    source_origin: Origin
)
[src]

Performs the blit with the source texture texture.

Calls C++ function: void QOpenGLTextureBlitter::blit(GLuint texture, const QMatrix4x4& targetTransform, QOpenGLTextureBlitter::Origin sourceOrigin).

C++ documentation:

Performs the blit with the source texture texture.

targetTransform specifies the transformation applied. This is usually generated by the targetTransform() helper function.

sourceOrigin specifies if the image data needs flipping. When texture corresponds to a texture attached to an FBO pass OriginBottomLeft. On the other hand, when texture is based on unflipped image data, pass OriginTopLeft. This is more efficient than using QImage::mirrored().

See also targetTransform(), Origin, and bind().

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

Initializes the graphics resources used by the blitter.

Calls C++ function: bool QOpenGLTextureBlitter::create().

C++ documentation:

Initializes the graphics resources used by the blitter.

Returns true if successful, false if there was a failure. Failures can occur when there is no OpenGL context current on the current thread, or when shader compilation fails for some reason.

See also isCreated() and destroy().

pub unsafe fn destroy(&self)[src]

Frees all graphics resources held by the blitter. Assumes that the OpenGL context, or another context sharing resources with it, that was current on the thread when invoking create() is current.

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

C++ documentation:

Frees all graphics resources held by the blitter. Assumes that the OpenGL context, or another context sharing resources with it, that was current on the thread when invoking create() is current.

The function has no effect when the blitter is not in created state.

See also create().

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

Returns true if create() was called and succeeded. false otherwise.

Calls C++ function: bool QOpenGLTextureBlitter::isCreated() const.

C++ documentation:

Returns true if create() was called and succeeded. false otherwise.

See also create() and destroy().

pub unsafe fn new() -> CppBox<QOpenGLTextureBlitter>[src]

Constructs a new QOpenGLTextureBlitter instance.

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

C++ documentation:

Constructs a new QOpenGLTextureBlitter instance.

Note: no graphics resources are initialized in the constructor. This makes it safe to place plain QOpenGLTextureBlitter members into classes because the actual initialization that depends on the OpenGL context happens only in create().

pub unsafe fn release(&self)[src]

Unbinds the graphics resources used by the blitter.

Calls C++ function: void QOpenGLTextureBlitter::release().

C++ documentation:

Unbinds the graphics resources used by the blitter.

See also bind().

pub unsafe fn set_opacity(&self, opacity: c_float)[src]

Changes the opacity to opacity. The default opacity is 1.0.

Calls C++ function: void QOpenGLTextureBlitter::setOpacity(float opacity).

C++ documentation:

Changes the opacity to opacity. The default opacity is 1.0.

Note: the blitter does not alter the blend state. It is up to the caller of blit() to ensure the correct blend settings are active.

pub unsafe fn set_red_blue_swizzle(&self, swizzle: bool)[src]

Sets whether swizzling is enabled for the red and blue color channels to swizzle. An BGRA to RGBA conversion (occurring in the shader on the GPU, instead of a slow CPU-side transformation) can be useful when the source texture contains data from a QImage with a format like QImage::Format_ARGB32 which maps to BGRA on little endian systems.

Calls C++ function: void QOpenGLTextureBlitter::setRedBlueSwizzle(bool swizzle).

C++ documentation:

Sets whether swizzling is enabled for the red and blue color channels to swizzle. An BGRA to RGBA conversion (occurring in the shader on the GPU, instead of a slow CPU-side transformation) can be useful when the source texture contains data from a QImage with a format like QImage::Format_ARGB32 which maps to BGRA on little endian systems.

By default the red-blue swizzle is disabled since this is what a texture attached to an framebuffer object or a texture based on a byte ordered QImage format (like QImage::Format_RGBA8888) needs.

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

Returns true when bind() accepts GL_TEXTURE_EXTERNAL_OES as its target argument.

Calls C++ function: bool QOpenGLTextureBlitter::supportsExternalOESTarget() const.

C++ documentation:

Returns true when bind() accepts GL_TEXTURE_EXTERNAL_OES as its target argument.

See also bind() and blit().

pub unsafe fn target_transform(
    target: impl CastInto<Ref<QRectF>>,
    viewport: impl CastInto<Ref<QRect>>
) -> CppBox<QMatrix4X4>
[src]

Calculates a target transform suitable for blit().

Calls C++ function: static QMatrix4x4 QOpenGLTextureBlitter::targetTransform(const QRectF& target, const QRect& viewport).

C++ documentation:

Calculates a target transform suitable for blit().

target is the target rectangle in pixels. viewport describes the source dimensions and will in most cases be set to (0, 0, image width, image height).

For unscaled output the size of target and viewport should match.

See also blit().

Trait Implementations

impl CppDeletable for QOpenGLTextureBlitter[src]

unsafe fn delete(&self)[src]

Destructs the instance.

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

C++ documentation:

Destructs the instance.

Note: When the OpenGL context - or a context sharing resources with it - that was current when calling create() is not current, graphics resources will not be released. Therefore, it is recommended to call destroy() manually instead of relying on the destructor to perform OpenGL resource cleanup.

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.