Struct slint::BorrowedOpenGLTextureBuilder
pub struct BorrowedOpenGLTextureBuilder(/* private fields */);
Expand description
Factory to create slint::Image
from an existing OpenGL texture.
Methods can be chained on it in order to configure it.
origin
: Change the texture’s origin when rendering (default: TopLeft).
Complete the builder by calling Self::build()
to create a slint::Image
:
let builder = unsafe { BorrowedOpenGLTextureBuilder::new_gl_2d_rgba_texture(texture_id, size) }
.origin(BorrowedOpenGLTextureOrigin::TopLeft);
let image: slint::Image = builder.build();
Implementations§
§impl BorrowedOpenGLTextureBuilder
impl BorrowedOpenGLTextureBuilder
pub unsafe fn new_gl_2d_rgba_texture(
texture_id: NonZeroU32,
size: Size2D<u32, UnknownUnit>
) -> BorrowedOpenGLTextureBuilder
pub unsafe fn new_gl_2d_rgba_texture( texture_id: NonZeroU32, size: Size2D<u32, UnknownUnit> ) -> BorrowedOpenGLTextureBuilder
Generates the base configuration for a borrowed OpenGL texture.
The texture must be bindable against the GL_TEXTURE_2D
target, have GL_RGBA
as format
for the pixel data.
By default, when Slint renders the texture, it assumes that the origin of the texture is at the top-left.
This is different from the default OpenGL coordinate system. Use the mirror_vertically
function
to reconfigure this.
Safety
This function is unsafe because invalid texture ids may lead to undefined behavior in OpenGL
drivers. A valid texture id is one that was created by the same OpenGL context that is
current during any of the invocations of the callback set on Window::set_rendering_notifier()
.
OpenGL contexts between instances of slint::Window
are not sharing resources. Consequently
slint::Image
objects created from borrowed OpenGL textures cannot be shared between
different windows.
pub fn origin(
self,
origin: BorrowedOpenGLTextureOrigin
) -> BorrowedOpenGLTextureBuilder
pub fn origin( self, origin: BorrowedOpenGLTextureOrigin ) -> BorrowedOpenGLTextureBuilder
Configures the texture to be rendered vertically mirrored.
Auto Trait Implementations§
impl RefUnwindSafe for BorrowedOpenGLTextureBuilder
impl Send for BorrowedOpenGLTextureBuilder
impl Sync for BorrowedOpenGLTextureBuilder
impl Unpin for BorrowedOpenGLTextureBuilder
impl UnwindSafe for BorrowedOpenGLTextureBuilder
Blanket Implementations§
source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere T: ?Sized,
source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere T: Any,
§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Box<dyn Trait>
(where Trait: Downcast
) to Box<dyn Any>
. Box<dyn Any>
can
then be further downcast
into Box<ConcreteType>
where ConcreteType
implements Trait
.§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.