summaryrefslogtreecommitdiff
path: root/bindgen
diff options
context:
space:
mode:
authoromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-07-26 18:58:43 +1000
committeromniscient <17525998+omnisci3nce@users.noreply.github.com>2024-07-26 18:58:43 +1000
commitf5e5a6fdf58f3135f3211135bfbcb6e70630309f (patch)
tree0d58ffe229df9ed907219537b78d2a88d10b331d /bindgen
parentaa1eeebb1c05edc22335cbb48af5d42be20750c0 (diff)
fix glfw get key range so it doesnt panic on mac
Diffstat (limited to 'bindgen')
-rw-r--r--bindgen/rust/celeritas-sys/Cargo.lock2
-rw-r--r--bindgen/rust/celeritas-sys/Cargo.toml5
-rw-r--r--bindgen/rust/celeritas-sys/build.rs2
-rw-r--r--bindgen/rust/celeritas-sys/examples/glfw.rs13
-rw-r--r--bindgen/rust/src/lib.rs6
-rw-r--r--bindgen/rust/src/main.rs3
6 files changed, 22 insertions, 9 deletions
diff --git a/bindgen/rust/celeritas-sys/Cargo.lock b/bindgen/rust/celeritas-sys/Cargo.lock
index de49f83..56df9ac 100644
--- a/bindgen/rust/celeritas-sys/Cargo.lock
+++ b/bindgen/rust/celeritas-sys/Cargo.lock
@@ -93,7 +93,7 @@ source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f"
[[package]]
-name = "celeritas"
+name = "celeritas-sys"
version = "0.1.0"
dependencies = [
"bindgen",
diff --git a/bindgen/rust/celeritas-sys/Cargo.toml b/bindgen/rust/celeritas-sys/Cargo.toml
index 6755fb2..bb5d692 100644
--- a/bindgen/rust/celeritas-sys/Cargo.toml
+++ b/bindgen/rust/celeritas-sys/Cargo.toml
@@ -7,3 +7,8 @@ edition = "2021"
[build-dependencies]
bindgen = "0.69.4"
+
+[dev-dependencies]
+egui = "0.27.1"
+egui_glfw = { git = "https://github.com/omnisci3nce/egui_glfw.git", rev = "67b432695433feb59761f3ae984b966ca3da31db" }
+gl = "0.14.0" \ No newline at end of file
diff --git a/bindgen/rust/celeritas-sys/build.rs b/bindgen/rust/celeritas-sys/build.rs
index 4f85bc6..097e26b 100644
--- a/bindgen/rust/celeritas-sys/build.rs
+++ b/bindgen/rust/celeritas-sys/build.rs
@@ -3,6 +3,7 @@ use std::path::PathBuf;
fn main() {
// Tell cargo to look for shared libraries in the specified directory
+ // TODO: we need to look based on OS
println!("cargo:rustc-link-search=../../../build/macosx/arm64/debug");
// println!("cargo:rustc-link-search=../../build/windows/x64/debug");
@@ -10,6 +11,7 @@ fn main() {
// shared library.
println!("cargo:rustc-link-lib=core_static");
println!("cargo:rustc-link-lib=glfw3");
+ // TODO: ^ use our locally compiled glfw
// The bindgen::Builder is the main entry point
// to bindgen, and lets you build up options for
diff --git a/bindgen/rust/celeritas-sys/examples/glfw.rs b/bindgen/rust/celeritas-sys/examples/glfw.rs
index 0514032..36abd8f 100644
--- a/bindgen/rust/celeritas-sys/examples/glfw.rs
+++ b/bindgen/rust/celeritas-sys/examples/glfw.rs
@@ -1,7 +1,7 @@
use std::ffi::CString;
use std::ptr::addr_of_mut;
-use celeritas::*;
+use celeritas_sys::*;
use egui_backend::egui::{vec2, Pos2, Rect};
use egui_glfw as egui_backend;
use egui_glfw::glfw::{fail_on_errors, Context};
@@ -41,7 +41,7 @@ fn main() {
let window_ptr = window.window_ptr();
unsafe {
// Cast the window pointer to the expected type
- let window_ptr = window_ptr as *mut celeritas::GLFWwindow;
+ let window_ptr = window_ptr as *mut celeritas_sys::GLFWwindow;
Core_Bringup(window_ptr);
};
@@ -50,8 +50,8 @@ fn main() {
let (width, height) = window.get_framebuffer_size();
let native_pixels_per_point = window.get_content_scale().0;
- let native_pixels_per_point = 1.0;
- // egui_ctx.set_pixels_per_point(2.0);
+ let native_pixels_per_point = 2.0;
+ egui_ctx.set_pixels_per_point(2.0);
let mut egui_input_state = egui_backend::EguiInputState::new(egui::RawInput {
screen_rect: Some(Rect::from_min_size(
@@ -77,7 +77,7 @@ fn main() {
y: -0.2,
z: -0.7,
};
- let camera = Camera_Create(
+ let mut camera = Camera_Create(
camera_pos,
camera_front,
Vec3 {
@@ -159,6 +159,9 @@ fn main() {
gl::Enable(gl::DEPTH_TEST);
gl::Enable(gl::CULL_FACE);
+ Camera_Update(addr_of_mut!(camera));
+ SetCamera(camera);
+
Skybox_Draw(addr_of_mut!(skybox), camera);
Render_RenderEntities(render_ents.as_mut_ptr(), render_ents.len());
diff --git a/bindgen/rust/src/lib.rs b/bindgen/rust/src/lib.rs
new file mode 100644
index 0000000..f9e77b0
--- /dev/null
+++ b/bindgen/rust/src/lib.rs
@@ -0,0 +1,6 @@
+//! Celeritas bindings wrapper library
+
+#![warn(missing_docs)]
+#![cfg_attr(docsrs, feature(doc_cfg))]
+
+pub use celeritas_sys as ffi;
diff --git a/bindgen/rust/src/main.rs b/bindgen/rust/src/main.rs
deleted file mode 100644
index e7a11a9..0000000
--- a/bindgen/rust/src/main.rs
+++ /dev/null
@@ -1,3 +0,0 @@
-fn main() {
- println!("Hello, world!");
-}