Struct Texture

Source
pub struct Texture {
    pub width: u32,
    pub height: u32,
    pub slot: u32,
    /* private fields */
}
Expand description

A Texture stores an Image that can be used while rendering, or to store data.

Fields§

§width: u32

Width of the Texture.

§height: u32

Height of the Texture.

§slot: u32

Slot the Texture will occupy.

Implementations§

Source§

impl Texture

Source

pub fn new(gl: &GL, image: &HtmlImageElement) -> Self

Create a new Texture using an HtmlImageElement.

Source

pub fn new_with_element_id(gl: &GL, image_src: &str) -> Self

Create a new Texture from an HtmlImageElement with an given element ID.

Source

pub fn new_with_texture_id(gl: &GL, count: u32) -> Self

Create a new Texture from an HtmlImageElement with an element ID in the format textureXX where XX is a number.

Source

pub fn new_from_pixels(gl: &GL, width: u32, height: u32, pixels: &[u8]) -> Self

Create a new Texture using a slice of u8s.

Source

pub fn colored(gl: &GL, color: Color32) -> Self

A colored Texture.

Create a single pixel sized Texture with the specified Color32.

Source

pub fn white(gl: &GL) -> Self

A fully-white Texture.

Source

pub fn checkerboard(gl: &GL) -> Self

A black and white checkerboard Texture.

Source

pub fn checkerboard_colored(gl: &GL, color1: Color32, color2: Color32) -> Self

A checkerboard Texture with two Color32s.

Trait Implementations§

Source§

impl Bind for Texture

Source§

fn bind(&self, gl: &GL)

Binds a struct implementing the Bind trait. This is up to the implementation to decide.
Source§

fn unbind(&self, gl: &GL)

Optionally unbinds a struct implementing the Bind trait. This effectively resets the WebGL state.
Source§

impl Debug for Texture

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for Texture

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl Drop for Texture

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> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<SS, SP> SupersetOf<SS> for SP
where SS: SubsetOf<SP>,

Source§

fn to_subset(&self) -> Option<SS>

The inverse inclusion map: attempts to construct self from the equivalent element of its superset. Read more
Source§

fn is_in_subset(&self) -> bool

Checks if self is actually part of its subset T (and can be converted to it).
Source§

fn to_subset_unchecked(&self) -> SS

Use with care! Same as self.to_subset but without any property checks. Always succeeds.
Source§

fn from_subset(element: &SS) -> SP

The inclusion map: converts self to the equivalent element of its superset.
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.