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
impl BorrowedOpenGLTextureBuilder
Sourcepub unsafe fn new_gl_2d_rgba_texture(
texture_id: NonZeroU32,
size: IntSize,
) -> Self
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.
Sourcepub fn origin(self, origin: BorrowedOpenGLTextureOrigin) -> Self
pub fn origin(self, origin: BorrowedOpenGLTextureOrigin) -> Self
Configures the texture to be rendered vertically mirrored.