summaryrefslogtreecommitdiff
path: root/bindgen/rust/celeritas-sys
diff options
context:
space:
mode:
authoromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-08-10 23:18:22 +1000
committeromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-08-10 23:18:22 +1000
commitee1b7fd3bc66501b252ce9e3e5ba89ac9aa54632 (patch)
tree47b9b1916933d76bfcc327ad2f39370833bd3712 /bindgen/rust/celeritas-sys
parent8dc076e714fad6ee6fb493360e094c4002b1584a (diff)
more work on bindings and ral
Diffstat (limited to 'bindgen/rust/celeritas-sys')
-rw-r--r--bindgen/rust/celeritas-sys/Cargo.lock29
-rw-r--r--bindgen/rust/celeritas-sys/build.rs27
-rw-r--r--bindgen/rust/celeritas-sys/src/lib.rs26
3 files changed, 75 insertions, 7 deletions
diff --git a/bindgen/rust/celeritas-sys/Cargo.lock b/bindgen/rust/celeritas-sys/Cargo.lock
index 89c7407..43ae7fb 100644
--- a/bindgen/rust/celeritas-sys/Cargo.lock
+++ b/bindgen/rust/celeritas-sys/Cargo.lock
@@ -40,6 +40,15 @@ dependencies = [
]
[[package]]
+name = "approx"
+version = "0.5.1"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "cab112f0a86d568ea0e627cc1d6be74a1e9cd55214684db5561995f6dad897c6"
+dependencies = [
+ "num-traits",
+]
+
+[[package]]
name = "autocfg"
version = "1.3.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -100,6 +109,7 @@ dependencies = [
"egui",
"egui_glfw",
"gl",
+ "glam",
"serde",
"serde_json",
]
@@ -310,6 +320,16 @@ dependencies = [
]
[[package]]
+name = "glam"
+version = "0.28.0"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "779ae4bf7e8421cf91c0b3b64e7e8b40b862fba4d393f59150042de7c4965a94"
+dependencies = [
+ "approx",
+ "serde",
+]
+
+[[package]]
name = "glfw"
version = "0.55.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
@@ -493,6 +513,15 @@ dependencies = [
]
[[package]]
+name = "num-traits"
+version = "0.2.19"
+source = "registry+https://github.com/rust-lang/crates.io-index"
+checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841"
+dependencies = [
+ "autocfg",
+]
+
+[[package]]
name = "objc"
version = "0.2.7"
source = "registry+https://github.com/rust-lang/crates.io-index"
diff --git a/bindgen/rust/celeritas-sys/build.rs b/bindgen/rust/celeritas-sys/build.rs
index 9e97034..b356bb0 100644
--- a/bindgen/rust/celeritas-sys/build.rs
+++ b/bindgen/rust/celeritas-sys/build.rs
@@ -13,16 +13,26 @@ const SERIALIZABLE_TYPES: &[&'static str] = &[
"DirectionalLight",
"PointLight",
];
+const EQ_TYPES: &[&'static str] = &[
+ "BufferHandle",
+ "TextureHandle",
+ "MeshHandle",
+ "MaterialHandle",
+ "ModelHandle",
+];
#[derive(Debug)]
-struct DeriveSerialize;
-impl ParseCallbacks for DeriveSerialize {
+struct AdditionalDerives;
+impl ParseCallbacks for AdditionalDerives {
fn add_derives(&self, info: &bindgen::callbacks::DeriveInfo<'_>) -> Vec<String> {
+ let mut derives = vec![];
if SERIALIZABLE_TYPES.contains(&info.name) {
- vec!["Serialize".to_string(), "Deserialize".to_string()]
- } else {
- vec![]
+ derives.extend_from_slice(&["Serialize".to_string(), "Deserialize".to_string()]);
+ }
+ if EQ_TYPES.contains(&info.name) {
+ derives.extend_from_slice(&["PartialEq".to_string()]);
}
+ derives
}
}
@@ -34,7 +44,8 @@ fn main() {
// println!("cargo:rustc-link-search=../../build/windows/x64/debug");
let static_lib_path =
- "/Users/josh/code/CodenameVentus/deps/celeritas-core/build/macosx/arm64/debug".to_string();
+ "/Users/josh/code/CodenameVentus/deps/celeritas-core/build/macosx/arm64/release"
+ .to_string();
// let static_lib_path = std::env::var("CELERITAS_CORE_LIB")
// .unwrap_or("../../../build/macosx/arm64/debug".to_string());
@@ -75,8 +86,10 @@ fn main() {
.generate_inline_functions(true)
// Tell cargo to invalidate the built crate whenever any of the
// included header files changed.
+ .rustified_enum("GPU_TextureType")
+ .rustified_enum("GPU_TextureFormat")
.parse_callbacks(Box::new(bindgen::CargoCallbacks::new()))
- .parse_callbacks(Box::new(DeriveSerialize))
+ .parse_callbacks(Box::new(AdditionalDerives))
// Finish the builder and generate the bindings.
.generate()
// Unwrap the Result and panic on failure.
diff --git a/bindgen/rust/celeritas-sys/src/lib.rs b/bindgen/rust/celeritas-sys/src/lib.rs
index 780ceff..90a5914 100644
--- a/bindgen/rust/celeritas-sys/src/lib.rs
+++ b/bindgen/rust/celeritas-sys/src/lib.rs
@@ -87,6 +87,19 @@ impl Transform {
}
}
+impl Vec3 {
+ pub const ZERO: Self = Vec3 {
+ x: 0.,
+ y: 0.,
+ z: 0.,
+ };
+ pub const ONE: Self = Vec3 {
+ x: 1.,
+ y: 1.,
+ z: 1.,
+ };
+}
+
impl Default for ShaderBinding {
fn default() -> Self {
Self {
@@ -139,3 +152,16 @@ impl Default for Camera {
camera
}
}
+
+// -- fat pointer string type
+
+impl Str8 {
+ pub fn from_str(s: &str) -> Self {
+ let s = s.to_owned();
+ let s = s.leak(); // TODO: a better way than just leaking string memory :P
+ Self {
+ buf: s.as_mut_ptr(),
+ len: 0,
+ }
+ }
+}