use crate::sys;
use crate::{BorderMode, DataType, EdgeFilterMode, FaceInfo, MeshType};
pub struct Texture(pub(crate) *mut sys::PtexTexture);
impl Drop for Texture {
fn drop(&mut self) {
unsafe {
sys::ptextexture_release(self.0);
}
}
}
impl Texture {
pub fn is_null(&self) -> bool {
self.0.is_null()
}
pub fn has_edits(&self) -> bool {
unsafe { sys::ptextexture_has_edits(self.0) }
}
pub fn has_mip_maps(&self) -> bool {
unsafe { sys::ptextexture_has_mipmaps(self.0) }
}
pub fn alpha_channel(&self) -> i32 {
unsafe { sys::ptextexture_get_alpha_channel(self.0) }
}
pub fn num_channels(&self) -> i32 {
unsafe { sys::ptextexture_get_num_channels(self.0) }
}
pub fn num_faces(&self) -> i32 {
unsafe { sys::ptextexture_get_num_faces(self.0) }
}
pub fn filename(&self) -> std::path::PathBuf {
let path_string = unsafe { sys::ptextexture_get_path(self.0) };
std::path::PathBuf::from(&path_string)
}
pub fn mesh_type(&self) -> MeshType {
MeshType::from(unsafe { sys::ptextexture_get_meshtype(self.0) })
}
pub fn data_type(&self) -> DataType {
DataType::from(unsafe { sys::ptextexture_get_datatype(self.0) })
}
pub fn border_mode_u(&self) -> BorderMode {
BorderMode::from(unsafe { sys::ptextexture_get_border_mode_u(self.0) })
}
pub fn border_mode_v(&self) -> BorderMode {
BorderMode::from(unsafe { sys::ptextexture_get_border_mode_v(self.0) })
}
pub fn edge_filter_mode(&self) -> EdgeFilterMode {
EdgeFilterMode::from(unsafe { sys::ptextexture_get_edge_filter_mode(self.0) })
}
pub fn face_info(&self, face_id: i32) -> &FaceInfo {
unsafe { sys::ptextexture_get_face_info(self.0, face_id) }
}
pub fn pixel_f32(
&self,
face_id: i32,
u: i32,
v: i32,
first_channel: i32,
num_channels: i32,
) -> f32 {
unsafe { sys::ptextexture_get_pixel(self.0, face_id, u, v, first_channel, num_channels) }
}
}