classicube_sys\graphics/
owned_gfx_texture.rs

1use crate::bindings::*;
2
3pub struct OwnedGfxTexture {
4    pub resource_id: GfxResourceID,
5}
6
7impl OwnedGfxTexture {
8    /// # Panics
9    ///
10    /// Will panic if `bmp` doesn't have a power of two dimensions.
11    pub fn new(bmp: &mut Bitmap, managed_pool: bool, mipmaps: bool) -> Self {
12        let resource_id =
13            unsafe { Gfx_CreateTexture(bmp, u8::from(managed_pool), u8::from(mipmaps)) };
14
15        assert!(resource_id as usize != 0);
16
17        Self { resource_id }
18    }
19}
20
21impl Drop for OwnedGfxTexture {
22    fn drop(&mut self) {
23        unsafe {
24            Gfx_DeleteTexture(&mut self.resource_id);
25        }
26    }
27}