Struct luminance::texture::Texture [−][src]
pub struct Texture<B: ?Sized, D, P> where
B: TextureBackend<D, P>,
D: Dimensionable,
P: Pixel, { /* fields omitted */ }
Expand description
GPU textures.
Implementations
impl<B: ?Sized, D, P> Texture<B, D, P> where
B: TextureBackend<D, P>,
D: Dimensionable,
P: Pixel,
impl<B: ?Sized, D, P> Texture<B, D, P> where
B: TextureBackend<D, P>,
D: Dimensionable,
P: Pixel,
pub fn new<C>(
ctx: &mut C,
size: D::Size,
mipmaps: usize,
sampler: Sampler,
gen_mipmaps: GenMipmaps,
texels: &[P::Encoding]
) -> Result<Self, TextureError> where
C: GraphicsContext<Backend = B>,
pub fn new<C>(
ctx: &mut C,
size: D::Size,
mipmaps: usize,
sampler: Sampler,
gen_mipmaps: GenMipmaps,
texels: &[P::Encoding]
) -> Result<Self, TextureError> where
C: GraphicsContext<Backend = B>,
Create a new Texture
.
size
is the wished size of the Texture
.
mipmaps
is the number of extra mipmaps to allocate with the texture. 0
means that the
texture will only be made of a base level.
sampler
is a Sampler
object that will be used when sampling the texture from inside a
shader, for instance.
gen_mipmaps
determines whether mipmaps should be generated automatically.
texels
is a slice of raw texels to put into the texture store.
Notes
Feel free to have a look at the documentation of GraphicsContext::new_texture
for a
simpler interface.
pub fn new_raw<C>(
ctx: &mut C,
size: D::Size,
mipmaps: usize,
sampler: Sampler,
gen_mipmaps: GenMipmaps,
texels: &[P::RawEncoding]
) -> Result<Self, TextureError> where
C: GraphicsContext<Backend = B>,
pub fn new_raw<C>(
ctx: &mut C,
size: D::Size,
mipmaps: usize,
sampler: Sampler,
gen_mipmaps: GenMipmaps,
texels: &[P::RawEncoding]
) -> Result<Self, TextureError> where
C: GraphicsContext<Backend = B>,
Create a new Texture
with raw texels.
size
is the wished size of the Texture
.
mipmaps
is the number of extra mipmaps to allocate with the texture. 0
means that the
texture will only be made of a base level.
sampler
is a Sampler
object that will be used when sampling the texture from inside a
shader, for instance.
gen_mipmaps
determines whether mipmaps should be generated automatically.
texels
is a slice of raw texels to put into the texture store.
Notes
Feel free to have a look at the documentation of GraphicsContext::new_texture_raw
for a
simpler interface.
Resize the texture by providing a new size and texels by reusing its GPU resources.
This function works similarly to Texture::new
but instead of creating a brand new texture, reuses the texture
resources on the GPU.
pub fn resize_raw(
&mut self,
size: D::Size,
mipmaps: usize,
gen_mipmaps: GenMipmaps,
texels: &[P::RawEncoding]
) -> Result<(), TextureError>
pub fn resize_raw(
&mut self,
size: D::Size,
mipmaps: usize,
gen_mipmaps: GenMipmaps,
texels: &[P::RawEncoding]
) -> Result<(), TextureError>
Resize the texture by providing a new size and raw texels by reusing its GPU resources.
This function works similarly to Texture::new_raw
but instead of creating a brand new texture, reuses the texture
resources on the GPU.
pub fn clear_part(
&mut self,
gen_mipmaps: GenMipmaps,
offset: D::Offset,
size: D::Size,
pixel: P::Encoding
) -> Result<(), TextureError>
pub fn clear_part(
&mut self,
gen_mipmaps: GenMipmaps,
offset: D::Offset,
size: D::Size,
pixel: P::Encoding
) -> Result<(), TextureError>
Clear the texture with a single pixel value.
This function will assign the input pixel value to all the pixels in the rectangle described
by size
and offset
in the texture.
pub fn clear(
&mut self,
gen_mipmaps: GenMipmaps,
pixel: P::Encoding
) -> Result<(), TextureError>
pub fn clear(
&mut self,
gen_mipmaps: GenMipmaps,
pixel: P::Encoding
) -> Result<(), TextureError>
Clear the texture with a single pixel value.
This function will assign the input pixel value to all the pixels in the texture.
pub fn upload_part(
&mut self,
gen_mipmaps: GenMipmaps,
offset: D::Offset,
size: D::Size,
texels: &[P::Encoding]
) -> Result<(), TextureError>
pub fn upload_part(
&mut self,
gen_mipmaps: GenMipmaps,
offset: D::Offset,
size: D::Size,
texels: &[P::Encoding]
) -> Result<(), TextureError>
Upload pixels to a region of the texture described by the rectangle made with size
and
offset
.
pub fn upload(
&mut self,
gen_mipmaps: GenMipmaps,
texels: &[P::Encoding]
) -> Result<(), TextureError>
pub fn upload(
&mut self,
gen_mipmaps: GenMipmaps,
texels: &[P::Encoding]
) -> Result<(), TextureError>
Upload pixels to the whole texture.
pub fn upload_part_raw(
&mut self,
gen_mipmaps: GenMipmaps,
offset: D::Offset,
size: D::Size,
texels: &[P::RawEncoding]
) -> Result<(), TextureError>
pub fn upload_part_raw(
&mut self,
gen_mipmaps: GenMipmaps,
offset: D::Offset,
size: D::Size,
texels: &[P::RawEncoding]
) -> Result<(), TextureError>
Upload raw data to a region of the texture described by the rectangle made with size
and
offset
.
pub fn upload_raw(
&mut self,
gen_mipmaps: GenMipmaps,
texels: &[P::RawEncoding]
) -> Result<(), TextureError>
pub fn upload_raw(
&mut self,
gen_mipmaps: GenMipmaps,
texels: &[P::RawEncoding]
) -> Result<(), TextureError>
Upload raw data to the whole texture.
pub fn get_raw_texels(&self) -> Result<Vec<P::RawEncoding>, TextureError> where
P::RawEncoding: Copy + Default,
pub fn get_raw_texels(&self) -> Result<Vec<P::RawEncoding>, TextureError> where
P::RawEncoding: Copy + Default,
Get a copy of all the pixels from the texture.
Auto Trait Implementations
impl<B: ?Sized, D, P> RefUnwindSafe for Texture<B, D, P> where
P: RefUnwindSafe,
<D as Dimensionable>::Size: RefUnwindSafe,
<B as TextureBase>::TextureRepr: RefUnwindSafe,
impl<B: ?Sized, D, P> Unpin for Texture<B, D, P> where
<D as Dimensionable>::Size: Unpin,
<B as TextureBase>::TextureRepr: Unpin,
impl<B: ?Sized, D, P> UnwindSafe for Texture<B, D, P> where
P: RefUnwindSafe,
<D as Dimensionable>::Size: UnwindSafe,
<B as TextureBase>::TextureRepr: UnwindSafe,