1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
use crate::bindings::*;
pub struct OwnedGfxTexture {
pub resource_id: GfxResourceID,
}
impl OwnedGfxTexture {
pub fn new(bmp: &mut Bitmap, managed_pool: bool, mipmaps: bool) -> Self {
let resource_id = unsafe {
Gfx_CreateTexture(
bmp,
if managed_pool { 1 } else { 0 },
if mipmaps { 1 } else { 0 },
)
};
assert!(resource_id as usize != 0);
Self { resource_id }
}
}
impl Drop for OwnedGfxTexture {
fn drop(&mut self) {
unsafe {
Gfx_DeleteTexture(&mut self.resource_id);
}
}
}