summaryrefslogtreecommitdiff
path: root/bindgen/rust/src/lib.rs
diff options
context:
space:
mode:
Diffstat (limited to 'bindgen/rust/src/lib.rs')
-rw-r--r--bindgen/rust/src/lib.rs50
1 files changed, 48 insertions, 2 deletions
diff --git a/bindgen/rust/src/lib.rs b/bindgen/rust/src/lib.rs
index f2e177f..dd83293 100644
--- a/bindgen/rust/src/lib.rs
+++ b/bindgen/rust/src/lib.rs
@@ -4,6 +4,7 @@
#![cfg_attr(docsrs, feature(doc_cfg))]
pub use celeritas_sys as ffi;
+use glam::Vec3;
/// Commonly used types
pub mod prelude;
@@ -17,14 +18,20 @@ use std::{
fs::{self, File},
io::Write,
path::Path,
+ ptr::addr_of_mut,
};
use celeritas_sys::{
- Camera, Camera_Create, Core_Bringup, Core_Shutdown, DirectionalLight, PointLight, RenderEnt,
- Transform, Vec3,
+ Core_Bringup, Core_Shutdown, DirectionalLight, Material, Material_Insert, Model, PointLight,
+ TextureHandle, Transform,
};
use serde::{Deserialize, Serialize};
+pub trait IntoFFI {
+ type FFIType;
+ unsafe fn into_ffi(self) -> Self::FFIType;
+}
+
/// Wrapper around a string that is the path to a gltf model **relative** to the configured
/// `ASSETS` folder
#[derive(Debug, Clone, Serialize, Deserialize)]
@@ -103,3 +110,42 @@ bitflags::bitflags! {
}
}
+
+type M = Material;
+/*
+pub name: [::std::os::raw::c_char; 64usize],
+pub kind: MaterialKind,
+pub base_colour: Vec3,
+pub metallic: f32_,
+pub roughness: f32_,
+pub ambient_occlusion: f32_,
+pub albedo_map: TextureHandle,
+pub normal_map: TextureHandle,
+pub metallic_roughness_map: TextureHandle,
+pub ambient_occlusion_map: TextureHandle, */
+
+#[derive(Debug, Clone, Default, PartialEq)]
+pub struct PBRMaterial {
+ pub name: String,
+ pub base_colour: glam::Vec3,
+ pub metallic: f32,
+ pub roughness: f32,
+ pub ambient_occlusion: f32,
+ pub albedo_map: Option<TextureHandle>,
+ pub normal_map: Option<TextureHandle>,
+ pub metallic_roughness_map: Option<TextureHandle>,
+ pub ambient_occlusion_map: Option<TextureHandle>,
+}
+impl PBRMaterial {
+ /// Creates the material in the C core returning a handle to it
+ pub fn create(mat: Self) -> ffi::MaterialHandle {
+ let mut ffi_mat = ffi::Material::from(mat);
+ unsafe { Material_Insert(addr_of_mut!(ffi_mat)) }
+ }
+}
+
+impl From<PBRMaterial> for ffi::Material {
+ fn from(value: PBRMaterial) -> Self {
+ todo!("impl conv for materials")
+ }
+}