Struct gust_render::texture::Texture
source · pub struct Texture {
pub id: u32,
/* private fields */
}
Expand description
Texture structure
A texture is an id inside openGL that can contain a array of byte this array can be spreaded to drawable object
use gust::window::Window;
use gust::sprite::Sprite;
use gust::texture::Texture;
use std::rc::Rc;
let window = Window::new(1080, 1920, "Test");
let leave = Rc::new(Texture::new("path/to/test"));
let sprite = Sprite::from(&leave);
Fields
id: u32
Implementations
sourceimpl Texture
impl Texture
sourcepub unsafe fn from_data(
data: *mut c_void,
mode: RgbMode,
width: u32,
height: u32
) -> Texture
pub unsafe fn from_data(
data: *mut c_void,
mode: RgbMode,
width: u32,
height: u32
) -> Texture
Create a texture from a raw data pointer needed for Font handling unsafe version of from slice
sourcepub fn from_slice(
data: &mut [u8],
mode: RgbMode,
width: u32,
height: u32
) -> Texture
pub fn from_slice(
data: &mut [u8],
mode: RgbMode,
width: u32,
height: u32
) -> Texture
Create a texture from a slice
pub fn from_color(color: Color, sizes: Vector<u32>) -> Texture
sourcepub fn from_image(img: DynamicImage) -> Result<Texture, TextureError>
pub fn from_image(img: DynamicImage) -> Result<Texture, TextureError>
Create a texture from an image
sourcepub fn from_path<P: AsRef<Path>>(
path_to_file: P
) -> Result<Texture, TextureError>
pub fn from_path<P: AsRef<Path>>(
path_to_file: P
) -> Result<Texture, TextureError>
Create new texture from file path
pub fn to_file<P: AsRef<Path>>(&self, path: P) -> Result<(), Box<dyn Error>>
sourcepub fn update_block<T, U>(
&mut self,
data: &[u8],
sizes: Vector<u32>,
pos: T,
rgb_mode: U
) -> Result<(), TextureError>where
T: Into<Option<Vector<u32>>>,
U: Into<Option<RgbMode>>,
pub fn update_block<T, U>(
&mut self,
data: &[u8],
sizes: Vector<u32>,
pos: T,
rgb_mode: U
) -> Result<(), TextureError>where
T: Into<Option<Vector<u32>>>,
U: Into<Option<RgbMode>>,
Update a block of a texture with an offset and a size return TextureError if the sizes are not correct.
pub fn get_rawsize(&self) -> usize
sourcepub fn update_from_texture(
&mut self,
texture: &Texture,
pos: Vector<u32>
) -> Result<(), TextureError>
pub fn update_from_texture(
&mut self,
texture: &Texture,
pos: Vector<u32>
) -> Result<(), TextureError>
Nicely working efficiently legacy fb deleted
sourcepub fn update<T>(&mut self, data: &[u8], mode: T) -> Result<(), TextureError>where
T: Into<Option<RgbMode>>,
pub fn update<T>(&mut self, data: &[u8], mode: T) -> Result<(), TextureError>where
T: Into<Option<RgbMode>>,
Update the data of the texture
sourcepub fn repeat_mode(&self)
pub fn repeat_mode(&self)
Repeat mode texture wrap
sourcepub fn linear_mode(&self)
pub fn linear_mode(&self)
Linear mode for filter
Trait Implementations
impl Eq for Texture
impl StructuralEq for Texture
impl StructuralPartialEq for Texture
Auto Trait Implementations
impl RefUnwindSafe for Texture
impl Send for Texture
impl Sync for Texture
impl Unpin for Texture
impl UnwindSafe for Texture
Blanket Implementations
sourceimpl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
impl<T> Pointable for T
impl<T> Pointable for T
impl<T> SetParameter for T
impl<T> SetParameter for T
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Resultwhere
T: Parameter<Self>,
fn set<T>(&mut self, value: T) -> <T as Parameter<Self>>::Resultwhere
T: Parameter<Self>,
Sets
value
as a parameter of self
.sourceimpl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
sourcefn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct
self
from the equivalent element of its
superset. Read moresourcefn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if
self
is actually part of its subset T
(and can be converted to it).sourceunsafe fn to_subset_unchecked(&self) -> SS
unsafe fn to_subset_unchecked(&self) -> SS
Use with care! Same as
self.to_subset
but without any property checks. Always succeeds.sourcefn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts
self
to the equivalent element of its superset.