pub struct Texture { /* private fields */ }
Expand description
Texture is wrapper for opengl texture object its just an unsafe pointer with useful methods
Implementations§
Source§impl Texture
impl Texture
pub const NONE: Self
Sourcepub fn default(path: &str) -> Result<Texture, ImageError>
pub fn default(path: &str) -> Result<Texture, ImageError>
default creates what i consider default texture from provided path (no interpolation, alfa channel)
Sourcepub fn empty_texture(size: TextureSize, config: TextureConfig) -> Self
pub fn empty_texture(size: TextureSize, config: TextureConfig) -> Self
empty texture creates texture with all pixels set to 0. its useful mainly for canvas.
Sourcepub fn new<P: AsRef<Path>>(
path: P,
config: TextureConfig,
) -> Result<Texture, ImageError>
pub fn new<P: AsRef<Path>>( path: P, config: TextureConfig, ) -> Result<Texture, ImageError>
new creates new texture. for mode you have two options:
- gl::NEAREST - it makes pixels visible
- gl::LINEAR - it linearly interpolates between pixels and generally looks little ugly
Sourcepub fn from_img(img: &DynamicImage, config: TextureConfig) -> Texture
pub fn from_img(img: &DynamicImage, config: TextureConfig) -> Texture
from_img returns texture from provided DynamicImage in case you want to do some pre processing on texture
Sourcepub fn from_raw_data(
size: TextureSize,
bytes: *const u8,
config: TextureConfig,
mipmap: bool,
) -> Texture
pub fn from_raw_data( size: TextureSize, bytes: *const u8, config: TextureConfig, mipmap: bool, ) -> Texture
its just lower level function, it may come handy
Sourcepub fn resize_and_clear(&mut self, size: TextureSize)
pub fn resize_and_clear(&mut self, size: TextureSize)
resize_and_clear si here purely for resizing canvas textures, otherwise not very useful because it also erases the content of a texture.
Sourcepub fn to_image<P: Pixel<Subpixel = u8> + 'static>(
&self,
) -> Option<ImageBuffer<P, Vec<u8>>>
pub fn to_image<P: Pixel<Subpixel = u8> + 'static>( &self, ) -> Option<ImageBuffer<P, Vec<u8>>>
to image takes texture from gpu memory to back to you so you can save texture
pub fn size(&self) -> Vect
pub fn unbind()
Trait Implementations§
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<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§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