pub struct Texture { /* private fields */ }
Expand description
A texture to draw or draw to.
Textures serve as drawing targets for userdefined Postprocessors
or custom Programs
. A texture can also be drawn with
Renderer::rect()
.
Implementations§
Source§impl Texture
impl Texture
Sourcepub fn builder(context: &RenderContext) -> TextureBuilder<'_>
pub fn builder(context: &RenderContext) -> TextureBuilder<'_>
Returns a texture builder for texture construction.
§Examples
let tex = Texture::builder(&rendercontext)
.dimensions((640, 480))
.magnify(TextureFilter::Nearest)
.minify(TextureFilter::Linear)
.build()
.unwrap();
Sourcepub fn new(context: &RenderContext, width: u32, height: u32) -> Self
pub fn new(context: &RenderContext, width: u32, height: u32) -> Self
Creates a new texture with given dimensions. The texture will use linear interpolation
for magnification or minification and internally use the F16F16F16F16
format.
Sourcepub fn from_file(context: &RenderContext, file: &str) -> Result<Self>
pub fn from_file(context: &RenderContext, file: &str) -> Result<Self>
Creates a new texture from given file.
Sourcepub fn filtered(
context: &RenderContext,
width: u32,
height: u32,
minify: TextureFilter,
magnify: TextureFilter,
) -> Self
pub fn filtered( context: &RenderContext, width: u32, height: u32, minify: TextureFilter, magnify: TextureFilter, ) -> Self
Creates a new texture with given dimensions and filters. It will internally use the F16F16F16F16
format.
Sourcepub fn clone_with_options(
&self,
minify: TextureFilter,
magnify: TextureFilter,
wrap: TextureWrap,
) -> Self
pub fn clone_with_options( &self, minify: TextureFilter, magnify: TextureFilter, wrap: TextureWrap, ) -> Self
Clones texture with new filters and wrapping function. Both source and clone reference the same texture data.
Sourcepub fn dimensions(&self) -> (u32, u32)
pub fn dimensions(&self) -> (u32, u32)
Returns the dimensions of the texture.
Trait Implementations§
Source§impl AsRenderTarget for Texture
impl AsRenderTarget for Texture
Source§fn as_render_target(&self) -> RenderTarget
fn as_render_target(&self) -> RenderTarget
Returns a RenderTarget representing a texture or a frame.
Auto Trait Implementations§
impl Freeze for Texture
impl !RefUnwindSafe for Texture
impl !Send for Texture
impl !Sync for Texture
impl Unpin for Texture
impl !UnwindSafe for Texture
Blanket Implementations§
Source§impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
impl<S, D, Swp, Dwp, T> AdaptInto<D, Swp, Dwp, T> for S
Source§fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
fn adapt_into_using<M>(self, method: M) -> Dwhere
M: TransformMatrix<Swp, Dwp, T>,
Convert the source color to the destination color using the specified method
Source§fn adapt_into(self) -> D
fn adapt_into(self) -> D
Convert the source color to the destination color using the bradford method by default
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
Mutably borrows from an owned value. Read more
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§unsafe fn clone_to_uninit(&self, dst: *mut T)
unsafe fn clone_to_uninit(&self, dst: *mut T)
🔬This is a nightly-only experimental API. (
clone_to_uninit
)Source§impl<T> Downcast for Twhere
T: Any,
impl<T> Downcast for Twhere
T: Any,
Source§fn into_any(self: Box<T>) -> Box<dyn Any>
fn into_any(self: Box<T>) -> Box<dyn Any>
Convert
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
.Source§fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
fn into_any_rc(self: Rc<T>) -> Rc<dyn Any>
Convert
Rc<Trait>
(where Trait: Downcast
) to Rc<Any>
. Rc<Any>
can then be
further downcast
into Rc<ConcreteType>
where ConcreteType
implements Trait
.Source§fn as_any(&self) -> &(dyn Any + 'static)
fn as_any(&self) -> &(dyn Any + 'static)
Convert
&Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &Any
’s vtable from &Trait
’s.Source§fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
fn as_any_mut(&mut self) -> &mut (dyn Any + 'static)
Convert
&mut Trait
(where Trait: Downcast
) to &Any
. This is needed since Rust cannot
generate &mut Any
’s vtable from &mut Trait
’s.Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left
is true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self
into a Left
variant of Either<Self, Self>
if into_left(&self)
returns true
.
Converts self
into a Right
variant of Either<Self, Self>
otherwise. Read more