tirbofish/dropbear
main / crates / eucalyptus-exports / src / asset / texture.rs · 1654 bytes
crates/eucalyptus-exports/src/asset/texture.rs
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
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
use dropbear_engine::asset::Handle;
use eucalyptus_core::ptr::{AssetRegistryPtr, AssetRegistryUnwrapped};
use eucalyptus_core::scripting::native::DropbearNativeError;
use eucalyptus_core::scripting::result::DropbearNativeResult;
#[dropbear_macro::export(
kotlin(class = "com.dropbear.asset.TextureNative", func = "getLabel"),
c(name = "dropbear_asset_texture_get_label")
)]
fn get_texture_label(
#[dropbear_macro::define(AssetRegistryPtr)] asset_manager: &AssetRegistryUnwrapped,
texture_handle: u64,
) -> DropbearNativeResult<Option<String>> {
Ok(asset_manager
.read()
.get_label_from_texture_handle(Handle::new(texture_handle)))
}
#[dropbear_macro::export(
kotlin(class = "com.dropbear.asset.TextureNative", func = "getWidth"),
c(name = "dropbear_asset_texture_get_width")
)]
fn get_texture_width(
#[dropbear_macro::define(AssetRegistryPtr)] asset_manager: &AssetRegistryUnwrapped,
texture_handle: u64,
) -> DropbearNativeResult<u32> {
asset_manager
.read()
.get_texture(Handle::new(texture_handle))
.map(|v| v.size.width)
.ok_or(DropbearNativeError::AssetNotFound)
}
#[dropbear_macro::export(
kotlin(class = "com.dropbear.asset.TextureNative", func = "getHeight"),
c(name = "dropbear_asset_texture_get_height")
)]
fn get_texture_height(
#[dropbear_macro::define(AssetRegistryPtr)] asset_manager: &AssetRegistryUnwrapped,
texture_handle: u64,
) -> DropbearNativeResult<u32> {
asset_manager
.read()
.get_texture(Handle::new(texture_handle))
.map(|v| v.size.height)
.ok_or(DropbearNativeError::AssetNotFound)
}