[−][src]Struct qt_gui::QOpenGLTextureBlitter
The QOpenGLTextureBlitter class provides a convenient way to draw textured quads via OpenGL.
C++ class: QOpenGLTextureBlitter
.
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(&mut 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 = …)
.
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
.
pub unsafe fn bind_0a(&mut 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()
.
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
.
pub unsafe fn blit(
&mut self,
texture: u32,
target_transform: impl CastInto<Ref<QMatrix4X4>>,
source_origin: Origin
)
[src]
&mut self,
texture: u32,
target_transform: impl CastInto<Ref<QMatrix4X4>>,
source_origin: Origin
)
Performs the blit with the source texture texture.
Calls C++ function: void QOpenGLTextureBlitter::blit(GLuint texture, const QMatrix4x4& targetTransform, QOpenGLTextureBlitter::Origin sourceOrigin)
.
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(&mut self) -> bool
[src]
Initializes the graphics resources used by the blitter.
Calls C++ function: bool QOpenGLTextureBlitter::create()
.
pub unsafe fn destroy(&mut 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()
.
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
.
pub unsafe fn new() -> CppBox<QOpenGLTextureBlitter>
[src]
Constructs a new QOpenGLTextureBlitter instance.
Calls C++ function: [constructor] void QOpenGLTextureBlitter::QOpenGLTextureBlitter()
.
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(&mut self)
[src]
Unbinds the graphics resources used by the blitter.
Calls C++ function: void QOpenGLTextureBlitter::release()
.
Unbinds the graphics resources used by the blitter.
See also bind().
pub unsafe fn set_opacity(&mut self, opacity: c_float)
[src]
Changes the opacity to opacity. The default opacity is 1.0.
Calls C++ function: void QOpenGLTextureBlitter::setOpacity(float opacity)
.
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(&mut 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)
.
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
.
pub unsafe fn target_transform(
target: impl CastInto<Ref<QRectF>>,
viewport: impl CastInto<Ref<QRect>>
) -> CppBox<QMatrix4X4>
[src]
target: impl CastInto<Ref<QRectF>>,
viewport: impl CastInto<Ref<QRect>>
) -> CppBox<QMatrix4X4>
Calculates a target transform suitable for blit().
Calls C++ function: static QMatrix4x4 QOpenGLTextureBlitter::targetTransform(const QRectF& target, const QRect& viewport)
.
Trait Implementations
impl CppDeletable for QOpenGLTextureBlitter
[src]
unsafe fn delete(&mut self)
[src]
Destructs the instance.
Calls C++ function: [destructor] void QOpenGLTextureBlitter::~QOpenGLTextureBlitter()
.
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
impl RefUnwindSafe for QOpenGLTextureBlitter
impl Send for QOpenGLTextureBlitter
impl Sync for QOpenGLTextureBlitter
impl Unpin for QOpenGLTextureBlitter
impl UnwindSafe for QOpenGLTextureBlitter
Blanket Implementations
impl<T> Any for T where
T: 'static + ?Sized,
[src]
T: 'static + ?Sized,
impl<T> Borrow<T> for T where
T: ?Sized,
[src]
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
[src]
T: ?Sized,
fn borrow_mut(&mut self) -> &mut T
[src]
impl<T, U> CastInto<U> for T where
U: CastFrom<T>,
[src]
U: CastFrom<T>,
impl<T> From<T> for T
[src]
impl<T, U> Into<U> for T where
U: From<T>,
[src]
U: From<T>,
impl<T> StaticUpcast<T> for T
[src]
unsafe fn static_upcast(ptr: Ptr<T>) -> Ptr<T>
[src]
unsafe fn static_upcast_mut(ptr: MutPtr<T>) -> MutPtr<T>
[src]
impl<T, U> TryFrom<U> for T where
U: Into<T>,
[src]
U: Into<T>,
type Error = Infallible
The type returned in the event of a conversion error.
fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>
[src]
impl<T, U> TryInto<U> for T where
U: TryFrom<T>,
[src]
U: TryFrom<T>,