summaryrefslogtreecommitdiff
path: root/bindgen/rust/examples/main_loop.rs
diff options
context:
space:
mode:
Diffstat (limited to 'bindgen/rust/examples/main_loop.rs')
-rw-r--r--bindgen/rust/examples/main_loop.rs99
1 files changed, 51 insertions, 48 deletions
diff --git a/bindgen/rust/examples/main_loop.rs b/bindgen/rust/examples/main_loop.rs
index 6fce5cf..2b4919a 100644
--- a/bindgen/rust/examples/main_loop.rs
+++ b/bindgen/rust/examples/main_loop.rs
@@ -1,4 +1,7 @@
-use std::{ffi::{ CString}, ptr::{self, addr_of_mut}};
+use std::{
+ ffi::CString,
+ ptr::{self, addr_of_mut},
+};
use celeritas::*;
@@ -10,58 +13,64 @@ unsafe fn run_game() {
let core = get_global_core();
let glfw_window_ptr = Core_GetGlfwWindowPtr(core);
+ // cam pos: 18.871811 10.658584 11.643305 cam frontL -0.644326 -0.209243 -0.735569
let camera_pos = Vec3 {
- x: 0.0,
- y: 2.0,
- z: -3.0,
+ x: 18.9,
+ y: 10.6,
+ z: 11.6,
+ };
+ let camera_front = Vec3 {
+ x: -0.6,
+ y: -0.2,
+ z: -0.7,
};
let camera = Camera_Create(
camera_pos,
- vec3_normalise(vec3_negate(camera_pos)),
- VEC3_Y,
+ camera_front,
+ Vec3 {
+ x: 0.0,
+ y: 1.0,
+ z: 0.0,
+ },
45.0,
);
SetCamera(camera);
- let whatever = Vec3 {
- x: 1.0,
- y: 1.0,
- z: 1.0,
- };
- let sun = DirectionalLight {
- direction: whatever,
- ambient: whatever,
- diffuse: whatever,
- specular: whatever,
- };
- SetMainLight(sun);
-
-// Geometry cube_geo = Geo_CreateCuboid(f32x3(2.0, 2.0, 2.0));
-// Mesh crate_mesh = Mesh_Create(&cube_geo, false); // dont free as we may use later
-// TextureHandle albedo_map = TextureLoadFromFile("assets/demo/crate/Wood_Crate_001_basecolor.jpg");
-// TextureHandle roughness_map =
-// TextureLoadFromFile("assets/demo/crate/Wood_Crate_001_roughness.jpg");
-// TextureHandle normal_map = TextureLoadFromFile("assets/demo/crate/Wood_Crate_001_normal.jpg");
-// TextureHandle ao_map =
-// TextureLoadFromFile("assets/demo/crate/Wood_Crate_001_ambientOcclusion.jpg");
-// Material crate_mat = { .name = "Wood_Crate",
-// .kind = MAT_PBR,
-// .metal_roughness_combined = true,
-// .pbr_albedo_map = albedo_map,
-// .pbr_metallic_map = roughness_map,
-// .pbr_normal_map = normal_map,
-// .pbr_ao_map = ao_map };
- let mut cube_geo = Geo_CreateCuboid(f32x3 { x: 2.0, y: 2.0, z: 2.0 });
+ let mut cube_geo = Geo_CreateCuboid(f32x3 {
+ x: 2.0,
+ y: 2.0,
+ z: 2.0,
+ });
let mut crate_mesh = Mesh_Create(addr_of_mut!(cube_geo), false);
- let albedo_map = TextureLoadFromFile(CString::new("assets/demo/crate/Wood_Crate_001_basecolor.jpg").unwrap().as_ptr() as *const i8);
- let roughness_map = TextureLoadFromFile(CString::new("assets/demo/crate/Wood_Crate_001_roughness.jpg").unwrap().as_ptr() as *const i8);
- let normal_map = TextureLoadFromFile(CString::new("assets/demo/crate/Wood_Crate_001_normal.jpg").unwrap().as_ptr() as *const i8);
- let ao_map = TextureLoadFromFile(CString::new("assets/demo/crate/Wood_Crate_001_ambientOcclusion.jpg").unwrap().as_ptr() as *const i8);
+ let albedo_map = TextureLoadFromFile(
+ CString::new("assets/demo/crate/Wood_Crate_001_basecolor.jpg")
+ .unwrap()
+ .as_ptr() as *const i8,
+ );
+ let roughness_map = TextureLoadFromFile(
+ CString::new("assets/demo/crate/Wood_Crate_001_roughness.jpg")
+ .unwrap()
+ .as_ptr() as *const i8,
+ );
+ let normal_map = TextureLoadFromFile(
+ CString::new("assets/demo/crate/Wood_Crate_001_normal.jpg")
+ .unwrap()
+ .as_ptr() as *const i8,
+ );
+ let ao_map = TextureLoadFromFile(
+ CString::new("assets/demo/crate/Wood_Crate_001_ambientOcclusion.jpg")
+ .unwrap()
+ .as_ptr() as *const i8,
+ );
let name: [i8; 64] = [0; 64];
let mut crate_mat = Material {
name: name,
kind: 0,
- param_albedo: VEC3_ZERO,
+ param_albedo: Vec3 {
+ x: 0.0,
+ y: 0.0,
+ z: 0.0,
+ },
param_metallic: 0.0,
param_roughness: 0.0,
param_ao: 0.0,
@@ -70,7 +79,7 @@ unsafe fn run_game() {
metal_roughness_combined: true,
pbr_metallic_map: TextureHandle { raw: 99999 },
pbr_roughness_map: roughness_map,
- pbr_ao_map: ao_map
+ pbr_ao_map: ao_map,
};
let crate_renderent = RenderEnt {
mesh: addr_of_mut!(crate_mesh),
@@ -78,14 +87,8 @@ unsafe fn run_game() {
affine: mat4_ident(),
casts_shadows: true,
};
- let mut render_entities: [RenderEnt; 1] = [crate_renderent];
-
- // RenderEnt crate_renderable = {
- // .mesh = &crate_mesh, .material = &crate_mat, .affine = mat4_scale(3.0), .casts_shadows = true
- // };
+ let mut render_entities: [RenderEnt; 1] = [crate_renderent];
- // RenderEnt entities[] = { cube_r, crate_renderable };
- // size_t entity_count = 1;
// main loop
while !ShouldExit() {