Skip to main content

Texture

Struct Texture 

Source
pub struct Texture {
    pub format: u32,
    /* private fields */
}

Fields§

§format: u32

Implementations§

Source§

impl Texture

Source

pub fn from_font_atlas_data( gl: &Context, format: u32, atlas: &FontAtlasData, ) -> Result<Self, Error>

Source

pub fn for_dynamic_font_atlas( gl: &Context, format: u32, cell_size: (i32, i32), initial_layers: i32, ) -> Result<Self, Error>

Creates an empty texture array for dynamic glyph rasterization.

Allocates a fixed-size 2D texture array and initializes all layers to transparent black (RGBA 0,0,0,0).

LRU eviction: When the glyph cache evicts old entries, the texture slots are reused. The new glyph completely overwrites the slot, so no explicit clearing is needed on eviction.

§Arguments
  • gl - GL context
  • format - Texture format
  • cell_size - (width, height) of each glyph cell in pixels
  • initial_layers - Number of texture layers to allocate initially
Source

pub fn upload_glyph( &self, gl: &Context, glyph_id: u16, padded_cell_size: (i32, i32), rasterized: &RasterizedGlyph, ) -> Result<(), Error>

Uploads a rasterized glyph to the texture at the position determined by its ID.

Glyph positions follow the layout: layer = id / 32, y = (id % 32) * cell_height

Source

pub fn dimensions(&self) -> (i32, i32, i32)

Returns the texture dimensions (width, height, layers)

Source

pub fn bind(&self, gl: &Context)

Source

pub fn delete(&self, gl: &Context)

Trait Implementations§

Source§

impl Debug for Texture

Source§

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

Formats the value using the given formatter. 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.