Struct Texture2D

Source
pub struct Texture2D {
    pub id: u32,
    pub width: u32,
    pub height: u32,
    pub config: Option<TextureConfig>,
}
Expand description

A abstract representation of a 2D texture

§Example

let mut texture1 = Texture2D::new();
texture1.load_from_file("./src/a.png", TextureConfig::new());
texture1.send_data(30, 30, 1, 1, 0xFF000000 as ptr); // Set a red pixel on x: 30, y: 30

let data = vec![...];
let texture2 = Texture2D::new();
texture2.gen_texture(TextureConfig::new());
texture2.send_data(0, 0, 100, 200, data as ptr);

let texture3 = Texture2D::new();
texture3.load_from_memory(data as ptr, TextureConfig::new());

Fields§

§id: u32§width: u32§height: u32§config: Option<TextureConfig>

Implementations§

Source§

impl Texture2D

Source

pub fn new() -> Self

Source

pub fn gen_texture(&mut self, config: TextureConfig)

Source

pub fn send_data( &self, xoffset: u32, yoffset: u32, width: u32, height: u32, data: *const c_void, )

Source

pub fn load_from_memory( &mut self, width: u32, height: u32, data: *const c_void, config: TextureConfig, )

Source

pub fn load_from_file(&mut self, filepath: &str, config: TextureConfig)

Source

pub fn bind(&self)

Trait Implementations§

Source§

impl Drop for Texture2D

Source§

fn drop(&mut self)

Executes the destructor for this type. Read more

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.