Skip to main content

drawing_api/common/
texture.rs

1use core::marker::Sized;
2
3use crate::ColorFormat;
4
5/// Represents an image whose data is resident in GPU memory.
6/// Reference counted, thread safe, immutable object.
7pub trait Texture: Sized + Sync + Send + Clone + 'static {
8    /// Returns descriptor of the texture.
9    fn get_descriptor(&self) -> TextureDescriptor;
10
11    /// Gets the native OpenGL handle associated with this texture.
12    fn get_gl_handle(&self) -> usize;
13}
14
15#[derive(Clone)]
16pub struct TextureDescriptor {
17    pub width: u32,
18    pub height: u32,
19    pub color_format: ColorFormat,
20    pub mip_count: u32,
21}
22
23impl Default for TextureDescriptor {
24    fn default() -> Self {
25        Self {
26            width: Default::default(),
27            height: Default::default(),
28            color_format: Default::default(),
29            mip_count: Default::default(),
30        }
31    }
32}