i_slint_core::graphics

Struct BorrowedOpenGLTextureBuilder

Source
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§

Source§

impl BorrowedOpenGLTextureBuilder

Source

pub unsafe fn new_gl_2d_rgba_texture( texture_id: NonZeroU32, size: IntSize, ) -> Self

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.

Source

pub fn origin(self, origin: BorrowedOpenGLTextureOrigin) -> Self

Configures the texture to be rendered vertically mirrored.

Source

pub fn build(self) -> Image

Completes the process of building a slint::Image that holds a borrowed OpenGL texture.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

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

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.