classicube_sys\graphics/
owned_gfx_texture.rs1use crate::bindings::*;
2
3pub struct OwnedGfxTexture {
4 pub resource_id: GfxResourceID,
5}
6
7impl OwnedGfxTexture {
8 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}