pub trait GenericTexture: Debug {
Show 21 methods
// Required methods
fn get_glcore(&self) -> &GLCore;
fn get_name(&self) -> u32;
fn get_dim(&self) -> TextureDimension;
fn get_width(&self) -> u32;
fn get_height(&self) -> u32;
fn get_depth(&self) -> u32;
fn get_format(&self) -> TextureFormat;
fn get_bytes_of_face(&self) -> usize;
fn get_bytes_of_texture(&self) -> usize;
fn has_mipmap(&self) -> bool;
fn get_pixel_buffer(&self) -> Option<&dyn GenericPixelBuffer>;
fn create_pixel_buffer(
&mut self,
buffer_channel_type: ChannelType,
buffer_component_type: ComponentType,
initial_data: Option<*const c_void>,
) -> Result<(), TextureError>;
fn drop_pixel_buffer(&mut self);
fn bind<'a>(&'a self) -> Result<TextureBind<'a>, TextureError>;
fn bind_face<'a>(
&'a self,
face: CubeMapFaces,
) -> Result<TextureBind<'a>, TextureError>;
// Provided methods
fn map_buffer<'a>(
&'a mut self,
access: MapAccess,
) -> Result<Option<(BufferBind<'a>, BufferMapping<'a>, *mut c_void)>, TextureError> { ... }
unsafe fn download_texture(
&self,
data: *mut c_void,
buffer_channel_type: ChannelType,
buffer_component_type: ComponentType,
) -> Result<(), TextureError> { ... }
unsafe fn upload_texture(
&self,
data: *const c_void,
buffer_channel_type: ChannelType,
buffer_component_type: ComponentType,
regen_mipmap: bool,
) -> Result<(), TextureError> { ... }
fn pack_pixel_buffer(&self) -> Result<(), TextureError> { ... }
fn unpack_pixel_buffer(
&self,
regen_mipmap: bool,
) -> Result<(), TextureError> { ... }
fn set_active_unit(&self, unit: u32) -> Result<(), TextureError> { ... }
}
Expand description
The GenericTexture
trait helps the Texture
struct to be able to turn into an object
Required Methods§
Sourcefn get_glcore(&self) -> &GLCore
fn get_glcore(&self) -> &GLCore
Get the OpenGL core
Sourcefn get_dim(&self) -> TextureDimension
fn get_dim(&self) -> TextureDimension
Get the dimension of the texture
Sourcefn get_height(&self) -> u32
fn get_height(&self) -> u32
Get height
Sourcefn get_format(&self) -> TextureFormat
fn get_format(&self) -> TextureFormat
Get the texture internal format
Sourcefn get_bytes_of_face(&self) -> usize
fn get_bytes_of_face(&self) -> usize
Get byte of face
Sourcefn get_bytes_of_texture(&self) -> usize
fn get_bytes_of_texture(&self) -> usize
Get byte of texture level 0
Sourcefn has_mipmap(&self) -> bool
fn has_mipmap(&self) -> bool
Get if have mipmap
Sourcefn get_pixel_buffer(&self) -> Option<&dyn GenericPixelBuffer>
fn get_pixel_buffer(&self) -> Option<&dyn GenericPixelBuffer>
Get the pixel buffer
Sourcefn create_pixel_buffer(
&mut self,
buffer_channel_type: ChannelType,
buffer_component_type: ComponentType,
initial_data: Option<*const c_void>,
) -> Result<(), TextureError>
fn create_pixel_buffer( &mut self, buffer_channel_type: ChannelType, buffer_component_type: ComponentType, initial_data: Option<*const c_void>, ) -> Result<(), TextureError>
Create the PBO if not been created earlier
Sourcefn drop_pixel_buffer(&mut self)
fn drop_pixel_buffer(&mut self)
Discard the PBO if not necessarily need it
Sourcefn bind<'a>(&'a self) -> Result<TextureBind<'a>, TextureError>
fn bind<'a>(&'a self) -> Result<TextureBind<'a>, TextureError>
Bind the texture, using the RAII system to manage the binding state
Sourcefn bind_face<'a>(
&'a self,
face: CubeMapFaces,
) -> Result<TextureBind<'a>, TextureError>
fn bind_face<'a>( &'a self, face: CubeMapFaces, ) -> Result<TextureBind<'a>, TextureError>
Bind a cubemap face, using the RAII system to manage the binding state
Provided Methods§
Sourcefn map_buffer<'a>(
&'a mut self,
access: MapAccess,
) -> Result<Option<(BufferBind<'a>, BufferMapping<'a>, *mut c_void)>, TextureError>
fn map_buffer<'a>( &'a mut self, access: MapAccess, ) -> Result<Option<(BufferBind<'a>, BufferMapping<'a>, *mut c_void)>, TextureError>
Map the pixel buffer for the specified access
Sourceunsafe fn download_texture(
&self,
data: *mut c_void,
buffer_channel_type: ChannelType,
buffer_component_type: ComponentType,
) -> Result<(), TextureError>
unsafe fn download_texture( &self, data: *mut c_void, buffer_channel_type: ChannelType, buffer_component_type: ComponentType, ) -> Result<(), TextureError>
Retrieve the pixels from the texture to the specified data pointer regardless of is currently using a PBO or not
§Safety
When binding a pixel pack buffer, the pointer data
refers to the offset of the buffer in bytes.
When not bound to any pixel pack buffers, the pointer data
is the pointer to your image buffer in the system memory.
Sourceunsafe fn upload_texture(
&self,
data: *const c_void,
buffer_channel_type: ChannelType,
buffer_component_type: ComponentType,
regen_mipmap: bool,
) -> Result<(), TextureError>
unsafe fn upload_texture( &self, data: *const c_void, buffer_channel_type: ChannelType, buffer_component_type: ComponentType, regen_mipmap: bool, ) -> Result<(), TextureError>
Load the texture with the specified data pointer regardless of is currently using a PBO or not
§Safety
When binding a pixel unpack buffer, the pointer data
refers to the offset of the buffer in bytes.
When not bound to any pixel unpack buffers, the pointer data
is the pointer to your image buffer in the system memory.
Sourcefn pack_pixel_buffer(&self) -> Result<(), TextureError>
fn pack_pixel_buffer(&self) -> Result<(), TextureError>
Read the pixels from the texture to the pixel buffer
Sourcefn unpack_pixel_buffer(&self, regen_mipmap: bool) -> Result<(), TextureError>
fn unpack_pixel_buffer(&self, regen_mipmap: bool) -> Result<(), TextureError>
Apply the change to the pixel buffer of the texture
Sourcefn set_active_unit(&self, unit: u32) -> Result<(), TextureError>
fn set_active_unit(&self, unit: u32) -> Result<(), TextureError>
Set the active texture unit