pub struct Texture2DRef {
pub texture: Arc<Texture2D>,
pub transformation: Mat3,
}Expand description
A reference to a 2D texture and a texture transformation.
Fields§
§texture: Arc<Texture2D>A reference to the texture.
transformation: Mat3A transformation applied to the uv coordinates before reading a texel value at those uv coordinates. This is primarily used in relation to texture atlasing.
Implementations§
Source§impl Texture2DRef
impl Texture2DRef
Sourcepub fn from_cpu_texture(context: &Context, cpu_texture: &CpuTexture) -> Self
pub fn from_cpu_texture(context: &Context, cpu_texture: &CpuTexture) -> Self
Creates a new Texture2DRef with an identity transformation from a CpuTexture.
Sourcepub fn from_texture(texture: Texture2D) -> Self
pub fn from_texture(texture: Texture2D) -> Self
Creates a new Texture2DRef with an identity transformation from a Texture2D.
Methods from Deref<Target = Texture2D>§
Sourcepub fn fill<T: TextureDataType>(&self, data: &[T])
pub fn fill<T: TextureDataType>(&self, data: &[T])
Fills this texture with the given data and generate mip maps if specified at construction.
§Panic
Will panic if the length of the data does not correspond to the width, height and format specified at construction. It is therefore necessary to create a new texture if the texture size or format has changed.
Sourcepub fn as_color_target(&self, mip_level: Option<u32>) -> ColorTarget<'_>
pub fn as_color_target(&self, mip_level: Option<u32>) -> ColorTarget<'_>
Returns a ColorTarget which can be used to clear, write to and read from the given mip level of this texture.
Combine this together with a DepthTarget with RenderTarget::new to be able to write to both a depth and color target at the same time.
If None is specified as the mip level, the 0 level mip level is used and mip maps are generated after a write operation if a mip map filter is specified.
Otherwise, the given mip level is used and no mip maps are generated.
Note: DepthTest is disabled if not also writing to a depth texture.
Sourcepub fn number_of_mip_maps(&self) -> u32
pub fn number_of_mip_maps(&self) -> u32
The number of mip maps of this texture.
Trait Implementations§
Source§impl Clone for Texture2DRef
impl Clone for Texture2DRef
Source§fn clone(&self) -> Texture2DRef
fn clone(&self) -> Texture2DRef
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more