Skip to main content

Texture

Trait Texture 

Source
pub unsafe trait Texture<D, P>: TextureBase
where D: Dimensionable, P: Pixel,
{ // Required methods unsafe fn new_texture( &mut self, size: D::Size, sampler: Sampler, texels: TexelUpload<'_, [P::Encoding]>, ) -> Result<Self::TextureRepr, TextureError>; unsafe fn new_texture_raw( &mut self, size: D::Size, sampler: Sampler, texels: TexelUpload<'_, [P::RawEncoding]>, ) -> Result<Self::TextureRepr, TextureError>; unsafe fn mipmaps(texture: &Self::TextureRepr) -> usize; unsafe fn upload_part( texture: &mut Self::TextureRepr, offset: D::Offset, size: D::Size, texels: TexelUpload<'_, [P::Encoding]>, ) -> Result<(), TextureError>; unsafe fn upload( texture: &mut Self::TextureRepr, size: D::Size, texels: TexelUpload<'_, [P::Encoding]>, ) -> Result<(), TextureError>; unsafe fn upload_part_raw( texture: &mut Self::TextureRepr, offset: D::Offset, size: D::Size, texels: TexelUpload<'_, [P::RawEncoding]>, ) -> Result<(), TextureError>; unsafe fn upload_raw( texture: &mut Self::TextureRepr, size: D::Size, texels: TexelUpload<'_, [P::RawEncoding]>, ) -> Result<(), TextureError>; unsafe fn get_raw_texels( texture: &Self::TextureRepr, size: D::Size, ) -> Result<Vec<P::RawEncoding>, TextureError> where P::RawEncoding: Copy + Default; unsafe fn resize( texture: &mut Self::TextureRepr, size: D::Size, texel: TexelUpload<'_, [P::Encoding]>, ) -> Result<(), TextureError>; unsafe fn resize_raw( texture: &mut Self::TextureRepr, size: D::Size, texel: TexelUpload<'_, [P::RawEncoding]>, ) -> Result<(), TextureError>; }
Expand description

Texture interface.

Implementing this trait requires implementing TextureBase.

D is the dimension of the texture, and must then implement Dimensionable. P is the format of the carried pixels and must then implement Pixel.

Required Methods§

Source

unsafe fn new_texture( &mut self, size: D::Size, sampler: Sampler, texels: TexelUpload<'_, [P::Encoding]>, ) -> Result<Self::TextureRepr, TextureError>

Create a new texture.

Source

unsafe fn new_texture_raw( &mut self, size: D::Size, sampler: Sampler, texels: TexelUpload<'_, [P::RawEncoding]>, ) -> Result<Self::TextureRepr, TextureError>

Create a new texture from raw texels.

Source

unsafe fn mipmaps(texture: &Self::TextureRepr) -> usize

Get the number of mimaps associated with the texture.

Source

unsafe fn upload_part( texture: &mut Self::TextureRepr, offset: D::Offset, size: D::Size, texels: TexelUpload<'_, [P::Encoding]>, ) -> Result<(), TextureError>

Upload texels to a part of a texture.

This method will use the input texels and will copy them everywhere in the part formed with offset and size. For instance, for 2D textures, offset and size form a rectangle: that rectangle of pixels will be filled with the provided input texels.

Source

unsafe fn upload( texture: &mut Self::TextureRepr, size: D::Size, texels: TexelUpload<'_, [P::Encoding]>, ) -> Result<(), TextureError>

Upload texels to a whole texture.

This method is similar to Texture::upload_part but instead of uploading a part of it, it will upload to the whole texture at once. The size will match the size of the texture so you do not have to cache it and simply can use the input size value.

Source

unsafe fn upload_part_raw( texture: &mut Self::TextureRepr, offset: D::Offset, size: D::Size, texels: TexelUpload<'_, [P::RawEncoding]>, ) -> Result<(), TextureError>

Upload texels to a part of a texture.

This method will use the input texels and will copy them everywhere in the part formed with offset and size. For instance, for 2D textures, offset and size form a rectangle: that rectangle of pixels will be filled with the provided input texels.

This is very similar to Texture::upload_part_raw, but the key difference is that this method works with the raw encoding of the texels, which is often the case with crates that provide you with a contiguous array of raw data instead of rich texels.

Source

unsafe fn upload_raw( texture: &mut Self::TextureRepr, size: D::Size, texels: TexelUpload<'_, [P::RawEncoding]>, ) -> Result<(), TextureError>

Upload texels to a whole texture.

This method is similar to Texture::upload_part but instead of uploading a part of it, it will upload to the whole texture at once. The size will match the size of the texture so you do not have to cache it and simply can use the input size value.

This is very similar to Texture::upload, but the key difference is that this method works with the raw encoding of the texels, which is often the case with crates that provide you with a contiguous array of raw data instead of rich texels.

Source

unsafe fn get_raw_texels( texture: &Self::TextureRepr, size: D::Size, ) -> Result<Vec<P::RawEncoding>, TextureError>
where P::RawEncoding: Copy + Default,

Get a copy of the raw texels stored in the texture.

size will match the actual size of the texture, you do not need to cache it.

Source

unsafe fn resize( texture: &mut Self::TextureRepr, size: D::Size, texel: TexelUpload<'_, [P::Encoding]>, ) -> Result<(), TextureError>

Resize the texture.

Once the texture is resized, pixels are left in an unknown state. Depending on the implementation of the backend, it is likely that texels will either be old ones, or completely random data.

Source

unsafe fn resize_raw( texture: &mut Self::TextureRepr, size: D::Size, texel: TexelUpload<'_, [P::RawEncoding]>, ) -> Result<(), TextureError>

Resize the texture with raw texels.

Once the texture is resized, pixels are left in an unknown state. Depending on the implementation of the backend, it is likely that texels will either be old ones, or completely random data.

Dyn Compatibility§

This trait is not dyn compatible.

In older versions of Rust, dyn compatibility was called "object safety".

Implementors§