From e0a047ac1e2cf18c3b0f23f31f869eeda767503e Mon Sep 17 00:00:00 2001 From: omniscient <17525998+omnisci3nce@users.noreply.github.com> Date: Fri, 26 Jul 2024 13:40:31 +1000 Subject: try getting glfw passthrough and egui to work --- README.md | 3 +- assets/shaders/terrain.frag | 6 +- assets/shaders/terrain.vert | 9 +- bindgen/rust/Cargo.lock | 1577 ++++++++++++++++++++++++++++++++---- bindgen/rust/Cargo.toml | 5 + bindgen/rust/examples/gui_test.rs | 135 +++ bindgen/rust/examples/main_loop.rs | 7 +- bindgen/rust/src/egui_utils.rs | 72 ++ bindgen/rust/src/lib.rs | 2 + examples/game_demo/game_demo.c | 4 +- src/core/core.c | 9 +- src/core/core.h | 9 +- src/new_render/render.c | 60 +- src/new_render/render.h | 2 +- src/systems/terrain.c | 45 +- src/systems/terrain.h | 5 + 16 files changed, 1753 insertions(+), 197 deletions(-) create mode 100644 bindgen/rust/examples/gui_test.rs create mode 100644 bindgen/rust/src/egui_utils.rs diff --git a/README.md b/README.md index c0950bc..98c42d0 100644 --- a/README.md +++ b/README.md @@ -66,6 +66,7 @@ All third-party dependencies are licensed under their own license. - [ ] Cone - [ ] Torus - [ ] Prism +- Load sponza & bistro scenes - [ ] Bindings generation (targets: rust, odin, zig, ocaml) (future) #### Memory @@ -77,7 +78,7 @@ All third-party dependencies are licensed under their own license. - [ ] SoA hot/cold pool allocator (pool for all entities of same type, split into two structs in SoA so we can have hot ,(`VkHandle`and cold `size`, `format` data separated)) (future) #### Scene -- [ ] Transform hierarchy / Scene tree +- [1/2] Transform hierarchy / Scene tree - [ ] Transform propagation - [ ] Asset streaming diff --git a/assets/shaders/terrain.frag b/assets/shaders/terrain.frag index 739ff83..0cc76c8 100644 --- a/assets/shaders/terrain.frag +++ b/assets/shaders/terrain.frag @@ -3,7 +3,11 @@ out vec4 FragColor; in vec4 Color; +in vec2 TexCoord; + +uniform sampler2D TextureSlot1; void main() { - FragColor = Color; + vec4 tex_color = texture(TextureSlot1, TexCoord); + FragColor = Color * tex_color; } \ No newline at end of file diff --git a/assets/shaders/terrain.vert b/assets/shaders/terrain.vert index d21cbe6..40f2b3e 100644 --- a/assets/shaders/terrain.vert +++ b/assets/shaders/terrain.vert @@ -1,6 +1,8 @@ #version 410 core layout(location = 0) in vec3 inPosition; +layout(location = 1) in vec3 inNormal; +layout(location = 2) in vec2 inTexCoords; uniform Camera { mat4 view; @@ -9,9 +11,12 @@ uniform Camera { } cam; out vec4 Color; +out vec2 TexCoord; void main() { - gl_Position = cam.proj * cam.view * vec4(inPosition, 1.0); + vec3 position = vec3(inPosition.x, inPosition.y / 2.0, inPosition.z); + gl_Position = cam.proj * cam.view * vec4(position, 1.0); - Color = vec4(inPosition.y / 126.0); + Color = vec4(inPosition.y / 100.0); + TexCoord = inTexCoords; } \ No newline at end of file diff --git a/bindgen/rust/Cargo.lock b/bindgen/rust/Cargo.lock index 63f3b6b..6f466c4 100644 --- a/bindgen/rust/Cargo.lock +++ b/bindgen/rust/Cargo.lock @@ -2,294 +2,1518 @@ # It is not intended for manual editing. version = 3 +[[package]] +name = "ab_glyph" +version = "0.2.28" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79faae4620f45232f599d9bc7b290f88247a0834162c4495ab2f02d60004adfb" +dependencies = [ + "ab_glyph_rasterizer", + "owned_ttf_parser", +] + +[[package]] +name = "ab_glyph_rasterizer" +version = "0.1.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c71b1793ee61086797f5c80b6efa2b8ffa6d5dd703f118545808a7f2e27f7046" + +[[package]] +name = "ahash" +version = "0.8.11" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e89da841a80418a9b391ebaea17f5c112ffaaa96f621d2c285b5174da76b9011" +dependencies = [ + "cfg-if", + "once_cell", + "version_check", + "zerocopy 0.7.35", +] + [[package]] name = "aho-corasick" version = "1.1.3" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +checksum = "8e60d3430d3a69478ad0993f19238d2df97c507009a52b3c10addcd7f6bcb916" +dependencies = [ + "memchr", +] + +[[package]] +name = "allocator-api2" +version = "0.2.18" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5c6cb57a04249c6480766f7f7cef5467412af1490f8d1e243141daddada3264f" + +[[package]] +name = "android_system_properties" +version = "0.1.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "819e7219dbd41043ac279b19830f2efc897156490d7fd6ea916720117ee66311" +dependencies = [ + "libc", +] + +[[package]] +name = "approx" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3f2a05fd1bd10b2527e20a2cd32d8873d115b8b39fe219ee25f42a8aca6ba278" +dependencies = [ + "num-traits", +] + +[[package]] +name = "arrayvec" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "96d30a06541fbafbc7f82ed10c06164cfbd2c401138f6addd8404629c4b16711" + +[[package]] +name = "ash" +version = "0.37.3+1.3.251" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39e9c3835d686b0a6084ab4234fcd1b07dbf6e4767dce60874b12356a25ecd4a" +dependencies = [ + "libloading 0.7.4", +] + +[[package]] +name = "autocfg" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0c4b4d0bd25bd0b74681c0ad21497610ce1b7c91b1022cd21c80c6fbdd9476b0" + +[[package]] +name = "bindgen" +version = "0.69.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" +dependencies = [ + "bitflags 2.6.0", + "cexpr", + "clang-sys", + "itertools", + "lazy_static", + "lazycell", + "log", + "prettyplease", + "proc-macro2", + "quote", + "regex", + "rustc-hash", + "shlex", + "syn 2.0.71", + "which", +] + +[[package]] +name = "bit-set" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0700ddab506f33b20a03b13996eccd309a48e5ff77d0d95926aa0210fb4e95f1" +dependencies = [ + "bit-vec", +] + +[[package]] +name = "bit-vec" +version = "0.6.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "349f9b6a179ed607305526ca489b34ad0a41aed5f7980fa90eb03160b69598fb" + +[[package]] +name = "bitflags" +version = "1.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bef38d45163c2f1dde094a7dfd33ccf595c92905c8f8f4fdc18d06fb1037718a" + +[[package]] +name = "bitflags" +version = "2.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" + +[[package]] +name = "block" +version = "0.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0d8c1fef690941d3e7788d328517591fecc684c084084702d6ff1641e993699a" + +[[package]] +name = "bumpalo" +version = "3.16.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "79296716171880943b8470b5f8d03aa55eb2e645a4874bdbb28adb49162e012c" + +[[package]] +name = "bytemuck" +version = "1.16.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b236fc92302c97ed75b38da1f4917b5cdda4984745740f153a5d3059e48d725e" +dependencies = [ + "bytemuck_derive", +] + +[[package]] +name = "bytemuck_derive" +version = "1.7.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ee891b04274a59bd38b412188e24b849617b2e45a0fd8d057deb63e7403761b" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.71", +] + +[[package]] +name = "byteorder" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1fd0f2584146f6f2ef48085050886acf353beff7305ebd1ae69500e27c67f64b" + +[[package]] +name = "cc" +version = "1.1.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2aba8f4e9906c7ce3c73463f62a7f0c65183ada1a2d47e397cc8810827f9694f" + +[[package]] +name = "celeritas" +version = "0.1.0" +dependencies = [ + "bindgen", + "egui", + "egui_overlay", + "egui_render_three_d", + "egui_render_wgpu", + "egui_window_glfw_passthrough", +] + +[[package]] +name = "cexpr" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +dependencies = [ + "nom", +] + +[[package]] +name = "cfg-if" +version = "1.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" + +[[package]] +name = "cfg_aliases" +version = "0.1.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fd16c4719339c4530435d38e511904438d07cce7950afa3718a84ac36c10e89e" + +[[package]] +name = "cgmath" +version = "0.18.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a98d30140e3296250832bbaaff83b27dcd6fa3cc70fb6f1f3e5c9c0023b5317" +dependencies = [ + "approx", + "num-traits", +] + +[[package]] +name = "clang-sys" +version = "1.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" +dependencies = [ + "glob", + "libc", + "libloading 0.8.5", +] + +[[package]] +name = "cmake" +version = "0.1.50" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a31c789563b815f77f4250caee12365734369f942439b7defd71e18a48197130" +dependencies = [ + "cc", +] + +[[package]] +name = "codespan-reporting" +version = "0.11.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3538270d33cc669650c4b093848450d380def10c331d38c768e34cac80576e6e" +dependencies = [ + "termcolor", + "unicode-width", +] + +[[package]] +name = "com" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7e17887fd17353b65b1b2ef1c526c83e26cd72e74f598a8dc1bee13a48f3d9f6" +dependencies = [ + "com_macros", +] + +[[package]] +name = "com_macros" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d375883580a668c7481ea6631fc1a8863e33cc335bf56bfad8d7e6d4b04b13a5" +dependencies = [ + "com_macros_support", + "proc-macro2", + "syn 1.0.109", +] + +[[package]] +name = "com_macros_support" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad899a1087a9296d5644792d7cb72b8e34c1bec8e7d4fbc002230169a6e8710c" +dependencies = [ + "proc-macro2", + "quote", + "syn 1.0.109", +] + +[[package]] +name = "core-foundation" +version = "0.9.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "91e195e091a93c46f7102ec7818a2aa394e1e1771c3ab4825963fa03e45afb8f" +dependencies = [ + "core-foundation-sys", + "libc", +] + +[[package]] +name = "core-foundation-sys" +version = "0.8.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "06ea2b9bc92be3c2baa9334a323ebca2d6f074ff852cd1d7b11064035cd3868f" + +[[package]] +name = "core-graphics-types" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "45390e6114f68f718cc7a830514a96f903cccd70d02a8f6d9f643ac4ba45afaf" +dependencies = [ + "bitflags 1.3.2", + "core-foundation", + "libc", +] + +[[package]] +name = "crunchy" +version = "0.2.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a81dae078cea95a014a339291cec439d2f232ebe854a9d672b796c6afafa9b7" + +[[package]] +name = "d3d12" +version = "0.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3e3d747f100290a1ca24b752186f61f6637e1deffe3bf6320de6fcb29510a307" +dependencies = [ + "bitflags 2.6.0", + "libloading 0.8.5", + "winapi", +] + +[[package]] +name = "ecolor" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "03cfe80b1890e1a8cdbffc6044d6872e814aaf6011835a2a5e2db0e5c5c4ef4e" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "egui" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "180f595432a5b615fc6b74afef3955249b86cfea72607b40740a4cd60d5297d0" +dependencies = [ + "ahash", + "epaint", + "nohash-hasher", +] + +[[package]] +name = "egui_overlay" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38117d60c6f04f55813294c261e1e7729290a33c1b3f182c618a115608ffcfe0" +dependencies = [ + "egui", + "egui_render_three_d", + "egui_window_glfw_passthrough", + "raw-window-handle 0.6.2", + "tracing", +] + +[[package]] +name = "egui_render_glow" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "21691a0388394a02b9352fb31edc7a008645ef1af13bc6eace5da06c2f599e60" +dependencies = [ + "bytemuck", + "egui", + "getrandom", + "glow 0.12.3", + "js-sys", + "raw-window-handle 0.6.2", + "tracing", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "egui_render_three_d" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "39bc7f5aab85ad422c53b2a1753a94a08bdca4b701346edc226ba015a0b2a7a8" +dependencies = [ + "egui", + "egui_render_glow", + "raw-window-handle 0.6.2", + "three-d", +] + +[[package]] +name = "egui_render_wgpu" +version = "0.8.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1618115f6f9a899be03d9b835944ebc362126f2682a17272ed2b31a2b6d0931b" +dependencies = [ + "bytemuck", + "egui", + "pollster", + "raw-window-handle 0.6.2", + "tracing", + "wgpu", +] + +[[package]] +name = "egui_window_glfw_passthrough" +version = "0.8.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1ce8cd7260410f069d82b31b188f66900336e054f839bbe24112dc2bb29acfc4" +dependencies = [ + "egui", + "glfw-passthrough", + "tracing", +] + +[[package]] +name = "either" +version = "1.13.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" + +[[package]] +name = "emath" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6916301ecf80448f786cdf3eb51d9dbdd831538732229d49119e2d4312eaaf09" +dependencies = [ + "bytemuck", +] + +[[package]] +name = "epaint" +version = "0.26.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77b9fdf617dd7f58b0c8e6e9e4a1281f730cde0831d40547da446b2bb76a47af" +dependencies = [ + "ab_glyph", + "ahash", + "bytemuck", + "ecolor", + "emath", + "nohash-hasher", + "parking_lot", +] + +[[package]] +name = "equivalent" +version = "1.0.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5443807d6dff69373d433ab9ef5378ad8df50ca6298caf15de6e52e24aaf54d5" + +[[package]] +name = "errno" +version = "0.3.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +dependencies = [ + "libc", + "windows-sys", +] + +[[package]] +name = "foreign-types" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d737d9aa519fb7b749cbc3b962edcf310a8dd1f4b67c91c4f83975dbdd17d965" +dependencies = [ + "foreign-types-macros", + "foreign-types-shared", +] + +[[package]] +name = "foreign-types-macros" +version = "0.2.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a5c6c585bc94aaf2c7b51dd4c2ba22680844aba4c687be581871a6f518c5742" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.71", +] + +[[package]] +name = "foreign-types-shared" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "aa9a19cbb55df58761df49b23516a86d432839add4af60fc256da840f66ed35b" + +[[package]] +name = "getrandom" +version = "0.2.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c4567c8db10ae91089c99af84c68c38da3ec2f087c3f82960bcdbf3656b6f4d7" +dependencies = [ + "cfg-if", + "js-sys", + "libc", + "wasi", + "wasm-bindgen", +] + +[[package]] +name = "gl_generator" +version = "0.14.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1a95dfc23a2b4a9a2f5ab41d194f8bfda3cabec42af4e39f08c339eb2a0c124d" +dependencies = [ + "khronos_api", + "log", + "xml-rs", +] + +[[package]] +name = "glfw-passthrough" +version = "0.55.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "17e0ee79341d32b6c490876d36f5e815bb10be943452cd3fff67d509d3143fb5" +dependencies = [ + "bitflags 1.3.2", + "glfw-sys-passthrough", + "objc", + "raw-window-handle 0.5.2", + "raw-window-handle 0.6.2", + "winapi", +] + +[[package]] +name = "glfw-sys-passthrough" +version = "4.0.3+3.3.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "09b2db4d361b9ebe743c3a542ddef5d605269bd1f93e1090440fff075e666ddf" +dependencies = [ + "cmake", +] + +[[package]] +name = "glob" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" + +[[package]] +name = "glow" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ca0fe580e4b60a8ab24a868bc08e2f03cbcb20d3d676601fa909386713333728" +dependencies = [ + "js-sys", + "slotmap", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "glow" +version = "0.13.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bd348e04c43b32574f2de31c8bb397d96c9fcfa1371bd4ca6d8bdc464ab121b1" +dependencies = [ + "js-sys", + "slotmap", + "wasm-bindgen", + "web-sys", +] + +[[package]] +name = "glutin_wgl_sys" +version = "0.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6c8098adac955faa2d31079b65dc48841251f69efd3ac25477903fc424362ead" +dependencies = [ + "gl_generator", +] + +[[package]] +name = "gpu-alloc" +version = "0.6.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fbcd2dba93594b227a1f57ee09b8b9da8892c34d55aa332e034a228d0fe6a171" +dependencies = [ + "bitflags 2.6.0", + "gpu-alloc-types", +] + +[[package]] +name = "gpu-alloc-types" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "98ff03b468aa837d70984d55f5d3f846f6ec31fe34bbb97c4f85219caeee1ca4" +dependencies = [ + "bitflags 2.6.0", +] + +[[package]] +name = "gpu-allocator" +version = "0.25.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6f56f6318968d03c18e1bcf4857ff88c61157e9da8e47c5f29055d60e1228884" +dependencies = [ + "log", + "presser", + "thiserror", + "winapi", + "windows", +] + +[[package]] +name = "gpu-descriptor" +version = "0.2.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "cc11df1ace8e7e564511f53af41f3e42ddc95b56fd07b3f4445d2a6048bc682c" +dependencies = [ + "bitflags 2.6.0", + "gpu-descriptor-types", + "hashbrown", +] + +[[package]] +name = "gpu-descriptor-types" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6bf0b36e6f090b7e1d8a4b49c0cb81c1f8376f72198c65dd3ad9ff3556b8b78c" +dependencies = [ + "bitflags 2.6.0", +] + +[[package]] +name = "half" +version = "2.4.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6dd08c532ae367adf81c312a4580bc67f1d0fe8bc9c460520283f4c0ff277888" +dependencies = [ + "cfg-if", + "crunchy", + "num-traits", + "zerocopy 0.6.6", +] + +[[package]] +name = "hashbrown" +version = "0.14.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e5274423e17b7c9fc20b6e7e208532f9b19825d82dfd615708b70edd83df41f1" +dependencies = [ + "ahash", + "allocator-api2", +] + +[[package]] +name = "hassle-rs" +version = "0.11.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "af2a7e73e1f34c48da31fb668a907f250794837e08faa144fd24f0b8b741e890" +dependencies = [ + "bitflags 2.6.0", + "com", + "libc", + "libloading 0.8.5", + "thiserror", + "widestring", + "winapi", +] + +[[package]] +name = "hexf-parse" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dfa686283ad6dd069f105e5ab091b04c62850d3e4cf5d67debad1933f55023df" + +[[package]] +name = "home" +version = "0.5.9" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +dependencies = [ + "windows-sys", +] + +[[package]] +name = "indexmap" +version = "2.2.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "168fb715dda47215e360912c096649d23d58bf392ac62f73919e831745e40f26" +dependencies = [ + "equivalent", + "hashbrown", +] + +[[package]] +name = "instant" +version = "0.1.13" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e0242819d153cba4b4b05a5a8f2a7e9bbf97b6055b2a002b395c96b5ff3c0222" +dependencies = [ + "cfg-if", +] + +[[package]] +name = "itertools" +version = "0.12.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" +dependencies = [ + "either", +] + +[[package]] +name = "jni-sys" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8eaf4bc02d17cbdd7ff4c7438cafcdf7fb9a4613313ad11b4f8fefe7d3fa0130" + +[[package]] +name = "js-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "29c15563dc2726973df627357ce0c9ddddbea194836909d655df6a75d2cf296d" +dependencies = [ + "wasm-bindgen", +] + +[[package]] +name = "khronos-egl" +version = "6.0.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "6aae1df220ece3c0ada96b8153459b67eebe9ae9212258bb0134ae60416fdf76" +dependencies = [ + "libc", + "libloading 0.8.5", + "pkg-config", +] + +[[package]] +name = "khronos_api" +version = "3.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e2db585e1d738fc771bf08a151420d3ed193d9d895a36df7f6f8a9456b911ddc" + +[[package]] +name = "lazy_static" +version = "1.5.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" + +[[package]] +name = "lazycell" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" + +[[package]] +name = "libc" +version = "0.2.155" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" + +[[package]] +name = "libloading" +version = "0.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b67380fd3b2fbe7527a606e18729d21c6f3951633d0500574c4dc22d2d638b9f" +dependencies = [ + "cfg-if", + "winapi", +] + +[[package]] +name = "libloading" +version = "0.8.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" +dependencies = [ + "cfg-if", + "windows-targets", +] + +[[package]] +name = "libm" +version = "0.2.8" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "4ec2a862134d2a7d32d7983ddcdd1c4923530833c9f2ea1a44fc5fa473989058" + +[[package]] +name = "linux-raw-sys" +version = "0.4.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" + +[[package]] +name = "lock_api" +version = "0.4.12" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "07af8b9cdd281b7915f413fa73f29ebd5d55d0d3f0155584dade1ff18cea1b17" +dependencies = [ + "autocfg", + "scopeguard", +] + +[[package]] +name = "log" +version = "0.4.22" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" + +[[package]] +name = "malloc_buf" +version = "0.0.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "62bb907fe88d54d8d9ce32a3cceab4218ed2f6b7d35617cafe9adf84e43919cb" +dependencies = [ + "libc", +] + +[[package]] +name = "memchr" +version = "2.7.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" + +[[package]] +name = "metal" +version = "0.27.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "c43f73953f8cbe511f021b58f18c3ce1c3d1ae13fe953293e13345bf83217f25" +dependencies = [ + "bitflags 2.6.0", + "block", + "core-graphics-types", + "foreign-types", + "log", + "objc", + "paste", +] + +[[package]] +name = "minimal-lexical" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" + +[[package]] +name = "naga" +version = "0.19.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "50e3524642f53d9af419ab5e8dd29d3ba155708267667c2f3f06c88c9e130843" +dependencies = [ + "bit-set", + "bitflags 2.6.0", + "codespan-reporting", + "hexf-parse", + "indexmap", + "log", + "num-traits", + "rustc-hash", + "spirv", + "termcolor", + "thiserror", + "unicode-xid", +] + +[[package]] +name = "ndk-sys" +version = "0.5.0+25.2.9519653" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "8c196769dd60fd4f363e11d948139556a344e79d451aeb2fa2fd040738ef7691" +dependencies = [ + "jni-sys", +] + +[[package]] +name = "nohash-hasher" +version = "0.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2bf50223579dc7cdcfb3bfcacf7069ff68243f8c363f62ffa99cf000a6b9c451" + +[[package]] +name = "nom" +version = "7.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +dependencies = [ + "memchr", + "minimal-lexical", +] + +[[package]] +name = "num-traits" +version = "0.2.19" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "071dfc062690e90b734c0b2273ce72ad0ffa95f0c74596bc250dcfd960262841" +dependencies = [ + "autocfg", + "libm", +] + +[[package]] +name = "objc" +version = "0.2.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "915b1b472bc21c53464d6c8461c9d3af805ba1ef837e1cac254428f4a77177b1" +dependencies = [ + "malloc_buf", + "objc_exception", +] + +[[package]] +name = "objc_exception" +version = "0.1.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "ad970fb455818ad6cba4c122ad012fae53ae8b4795f86378bce65e4f6bab2ca4" +dependencies = [ + "cc", +] + +[[package]] +name = "once_cell" +version = "1.19.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" + +[[package]] +name = "owned_ttf_parser" +version = "0.24.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "490d3a563d3122bf7c911a59b0add9389e5ec0f5f0c3ac6b91ff235a0e6a7f90" +dependencies = [ + "ttf-parser", +] + +[[package]] +name = "parking_lot" +version = "0.12.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f1bf18183cf54e8d6059647fc3063646a1801cf30896933ec2311622cc4b9a27" +dependencies = [ + "lock_api", + "parking_lot_core", +] + +[[package]] +name = "parking_lot_core" +version = "0.9.10" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1e401f977ab385c9e4e3ab30627d6f26d00e2c73eef317493c4ec6d468726cf8" +dependencies = [ + "cfg-if", + "libc", + "redox_syscall", + "smallvec", + "windows-targets", +] + +[[package]] +name = "paste" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "57c0d7b74b563b49d38dae00a0c37d4d6de9b432382b2892f0574ddcae73fd0a" + +[[package]] +name = "pin-project-lite" +version = "0.2.14" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "bda66fc9667c18cb2758a2ac84d1167245054bcf85d5d1aaa6923f45801bdd02" + +[[package]] +name = "pkg-config" +version = "0.3.30" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "d231b230927b5e4ad203db57bbcbee2802f6bce620b1e4a9024a07d94e2907ec" + +[[package]] +name = "pollster" +version = "0.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "22686f4785f02a4fcc856d3b3bb19bf6c8160d103f7a99cc258bddd0251dc7f2" + +[[package]] +name = "presser" +version = "0.3.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "e8cf8e6a8aa66ce33f63993ffc4ea4271eb5b0530a9002db8455ea6050c77bfa" + +[[package]] +name = "prettyplease" +version = "0.2.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" +dependencies = [ + "proc-macro2", + "syn 2.0.71", +] + +[[package]] +name = "proc-macro2" +version = "1.0.86" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +dependencies = [ + "unicode-ident", +] + +[[package]] +name = "profiling" +version = "1.0.15" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "43d84d1d7a6ac92673717f9f6d1518374ef257669c24ebc5ac25d5033828be58" + +[[package]] +name = "quote" +version = "1.0.36" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +dependencies = [ + "proc-macro2", +] + +[[package]] +name = "range-alloc" +version = "0.1.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "9c8a99fddc9f0ba0a85884b8d14e3592853e787d581ca1816c91349b10e4eeab" + +[[package]] +name = "raw-window-handle" +version = "0.5.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "f2ff9a1f06a88b01621b7ae906ef0211290d1c8a168a15542486a8f61c0833b9" + +[[package]] +name = "raw-window-handle" +version = "0.6.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "20675572f6f24e9e76ef639bc5552774ed45f1c30e2951e1e99c59888861c539" + +[[package]] +name = "redox_syscall" +version = "0.5.3" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "2a908a6e00f1fdd0dfd9c0eb08ce85126f6d8bbda50017e74bc4a4b7d4a926a4" +dependencies = [ + "bitflags 2.6.0", +] + +[[package]] +name = "regex" +version = "1.10.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +dependencies = [ + "aho-corasick", + "memchr", + "regex-automata", + "regex-syntax", +] + +[[package]] +name = "regex-automata" +version = "0.4.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +dependencies = [ + "aho-corasick", + "memchr", + "regex-syntax", +] + +[[package]] +name = "regex-syntax" +version = "0.8.4" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" + +[[package]] +name = "renderdoc-sys" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "19b30a45b0cd0bcca8037f3d0dc3421eaf95327a17cad11964fb8179b4fc4832" + +[[package]] +name = "rustc-hash" +version = "1.1.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" + +[[package]] +name = "rustix" +version = "0.38.34" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +dependencies = [ + "bitflags 2.6.0", + "errno", + "libc", + "linux-raw-sys", + "windows-sys", +] + +[[package]] +name = "scopeguard" +version = "1.2.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "94143f37725109f92c262ed2cf5e59bce7498c01bcc1502d7b9afe439a4e9f49" + +[[package]] +name = "shlex" +version = "1.3.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" + +[[package]] +name = "slotmap" +version = "1.0.7" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dbff4acf519f630b3a3ddcfaea6c06b42174d9a44bc70c620e9ed1649d58b82a" dependencies = [ - "memchr", + "version_check", ] [[package]] -name = "bindgen" -version = "0.69.4" +name = "smallvec" +version = "1.13.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a00dc851838a2120612785d195287475a3ac45514741da670b735818822129a0" +checksum = "3c5e1a9a646d36c3599cd173a41282daf47c44583ad367b8e6837255952e5c67" + +[[package]] +name = "spirv" +version = "0.3.0+sdk-1.3.268.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "eda41003dc44290527a59b13432d4a0379379fa074b70174882adfbdfd917844" dependencies = [ - "bitflags", - "cexpr", - "clang-sys", - "itertools", - "lazy_static", - "lazycell", - "log", - "prettyplease", - "proc-macro2", - "quote", - "regex", - "rustc-hash", - "shlex", - "syn", - "which", + "bitflags 2.6.0", ] [[package]] -name = "bitflags" -version = "2.6.0" +name = "static_assertions" +version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b048fb63fd8b5923fc5aa7b340d8e156aec7ec02f0c78fa8a6ddc2613f6f71de" +checksum = "a2eb9349b6444b326872e140eb1cf5e7c522154d69e7a0ffb0fb81c06b37543f" [[package]] -name = "celeritas" -version = "0.1.0" +name = "syn" +version = "1.0.109" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "72b64191b275b66ffe2469e8af2c1cfe3bafa67b529ead792a6d0160888b4237" dependencies = [ - "bindgen", + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] -name = "cexpr" -version = "0.6.0" +name = "syn" +version = "2.0.71" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "6fac387a98bb7c37292057cffc56d62ecb629900026402633ae9160df93a8766" +checksum = "b146dcf730474b4bcd16c311627b31ede9ab149045db4d6088b3becaea046462" dependencies = [ - "nom", + "proc-macro2", + "quote", + "unicode-ident", ] [[package]] -name = "cfg-if" -version = "1.0.0" +name = "termcolor" +version = "1.4.1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "baf1de4339761588bc0619e3cbc0120ee582ebb74b53b4efbf79117bd2da40fd" +checksum = "06794f8f6c5c898b3275aebefa6b8a1cb24cd2c6c79397ab15774837a0bc5755" +dependencies = [ + "winapi-util", +] [[package]] -name = "clang-sys" -version = "1.8.1" +name = "thiserror" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0b023947811758c97c59bf9d1c188fd619ad4718dcaa767947df1cadb14f39f4" +checksum = "c0342370b38b6a11b6cc11d6a805569958d54cfa061a29969c3b5ce2ea405724" dependencies = [ - "glob", - "libc", - "libloading", + "thiserror-impl", ] [[package]] -name = "either" -version = "1.13.0" +name = "thiserror-impl" +version = "1.0.63" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "60b1af1c220855b6ceac025d3f6ecdd2b7c4894bfe9cd9bda4fbb4bc7c0d4cf0" +checksum = "a4558b58466b9ad7ca0f102865eccc95938dca1a74a856f2b57b6629050da261" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.71", +] [[package]] -name = "errno" -version = "0.3.9" +name = "three-d" +version = "0.16.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "534c5cf6194dfab3db3242765c03bbe257cf92f22b38f6bc0c58d59108a820ba" +checksum = "0aecff785797175a2e56dca49da9836948eee41fab48b7b01dfcb64cae256ecb" dependencies = [ - "libc", - "windows-sys", + "cgmath", + "glow 0.12.3", + "instant", + "thiserror", + "three-d-asset", ] [[package]] -name = "glob" -version = "0.3.1" +name = "three-d-asset" +version = "0.6.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d2fabcfbdc87f4758337ca535fb41a6d701b65693ce38287d856d1674551ec9b" +checksum = "e9959d4427b63958661828008f7470d6a8d2c0945b3df0dc7377d6aca38fb694" +dependencies = [ + "cgmath", + "half", + "thiserror", + "web-sys", +] [[package]] -name = "home" -version = "0.5.9" +name = "tracing" +version = "0.1.40" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "e3d1354bf6b7235cb4a0576c2619fd4ed18183f689b12b006a0ee7329eeff9a5" +checksum = "c3523ab5a71916ccf420eebdf5521fcef02141234bbc0b8a49f2fdc4544364ef" dependencies = [ - "windows-sys", + "pin-project-lite", + "tracing-core", ] [[package]] -name = "itertools" -version = "0.12.1" +name = "tracing-core" +version = "0.1.32" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "ba291022dbbd398a455acf126c1e341954079855bc60dfdda641363bd6922569" -dependencies = [ - "either", -] +checksum = "c06d3da6113f116aaee68e4d601191614c9053067f9ab7f6edbcb161237daa54" [[package]] -name = "lazy_static" -version = "1.5.0" +name = "ttf-parser" +version = "0.24.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "bbd2bcb4c963f2ddae06a2efc7e9f3591312473c50c6685e1f298068316e66fe" +checksum = "8686b91785aff82828ed725225925b33b4fde44c4bb15876e5f7c832724c420a" [[package]] -name = "lazycell" -version = "1.3.0" +name = "unicode-ident" +version = "1.0.12" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "830d08ce1d1d941e6b30645f1a0eb5643013d835ce3779a5fc208261dbe10f55" +checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" [[package]] -name = "libc" -version = "0.2.155" +name = "unicode-width" +version = "0.1.13" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "97b3888a4aecf77e811145cadf6eef5901f4782c53886191b2f693f24761847c" +checksum = "0336d538f7abc86d282a4189614dfaa90810dfc2c6f6427eaf88e16311dd225d" [[package]] -name = "libloading" -version = "0.8.5" +name = "unicode-xid" +version = "0.2.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "4979f22fdb869068da03c9f7528f8297c6fd2606bc3a4affe42e6a823fdb8da4" -dependencies = [ - "cfg-if", - "windows-targets", -] +checksum = "f962df74c8c05a667b5ee8bcf162993134c104e96440b663c8daa176dc772d8c" [[package]] -name = "linux-raw-sys" -version = "0.4.14" +name = "version_check" +version = "0.9.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78b3ae25bc7c8c38cec158d1f2757ee79e9b3740fbc7ccf0e59e4b08d793fa89" +checksum = "0b928f33d975fc6ad9f86c8f283853ad26bdd5b10b7f1542aa2fa15e2289105a" [[package]] -name = "log" -version = "0.4.22" +name = "wasi" +version = "0.11.0+wasi-snapshot-preview1" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "a7a70ba024b9dc04c27ea2f0c0548feb474ec5c54bba33a7f72f873a39d07b24" +checksum = "9c8d87e72b64a3b4db28d11ce29237c246188f4f51057d65a7eab63b7987e423" [[package]] -name = "memchr" -version = "2.7.4" +name = "wasm-bindgen" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "78ca9ab1a0babb1e7d5695e3530886289c18cf2f87ec19a575a0abdce112e3a3" +checksum = "4be2531df63900aeb2bca0daaaddec08491ee64ceecbee5076636a3b026795a8" +dependencies = [ + "cfg-if", + "wasm-bindgen-macro", +] [[package]] -name = "minimal-lexical" -version = "0.2.1" +name = "wasm-bindgen-backend" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "68354c5c6bd36d73ff3feceb05efa59b6acb7626617f4962be322a825e61f79a" +checksum = "614d787b966d3989fa7bb98a654e369c762374fd3213d212cfc0251257e747da" +dependencies = [ + "bumpalo", + "log", + "once_cell", + "proc-macro2", + "quote", + "syn 2.0.71", + "wasm-bindgen-shared", +] [[package]] -name = "nom" -version = "7.1.3" +name = "wasm-bindgen-futures" +version = "0.4.42" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "d273983c5a657a70a3e8f2a01329822f3b8c8172b73826411a55751e404a0a4a" +checksum = "76bc14366121efc8dbb487ab05bcc9d346b3b5ec0eaa76e46594cabbe51762c0" dependencies = [ - "memchr", - "minimal-lexical", + "cfg-if", + "js-sys", + "wasm-bindgen", + "web-sys", ] [[package]] -name = "once_cell" -version = "1.19.0" +name = "wasm-bindgen-macro" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3fdb12b2476b595f9358c5161aa467c2438859caa136dec86c26fdd2efe17b92" +checksum = "a1f8823de937b71b9460c0c34e25f3da88250760bec0ebac694b49997550d726" +dependencies = [ + "quote", + "wasm-bindgen-macro-support", +] [[package]] -name = "prettyplease" -version = "0.2.20" +name = "wasm-bindgen-macro-support" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5f12335488a2f3b0a83b14edad48dca9879ce89b2edd10e80237e4e852dd645e" +checksum = "e94f17b526d0a461a191c78ea52bbce64071ed5c04c9ffe424dcb38f74171bb7" dependencies = [ "proc-macro2", - "syn", + "quote", + "syn 2.0.71", + "wasm-bindgen-backend", + "wasm-bindgen-shared", ] [[package]] -name = "proc-macro2" -version = "1.0.86" +name = "wasm-bindgen-shared" +version = "0.2.92" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "5e719e8df665df0d1c8fbfd238015744736151d4445ec0836b8e628aae103b77" +checksum = "af190c94f2773fdb3729c55b007a722abb5384da03bc0986df4c289bf5567e96" + +[[package]] +name = "web-sys" +version = "0.3.69" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "77afa9a11836342370f4817622a2f0f418b134426d91a82dfb48f532d2ec13ef" dependencies = [ - "unicode-ident", + "js-sys", + "wasm-bindgen", ] [[package]] -name = "quote" -version = "1.0.36" +name = "wgpu" +version = "0.19.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fa76aaf39101c457836aec0ce2316dbdc3ab723cdda1c6bd4e6ad4208acaca7" +checksum = "cbd7311dbd2abcfebaabf1841a2824ed7c8be443a0f29166e5d3c6a53a762c01" dependencies = [ - "proc-macro2", + "arrayvec", + "cfg-if", + "cfg_aliases", + "js-sys", + "log", + "naga", + "parking_lot", + "profiling", + "raw-window-handle 0.6.2", + "smallvec", + "static_assertions", + "wasm-bindgen", + "wasm-bindgen-futures", + "web-sys", + "wgpu-core", + "wgpu-hal", + "wgpu-types", ] [[package]] -name = "regex" -version = "1.10.5" +name = "wgpu-core" +version = "0.19.4" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b91213439dad192326a0d7c6ee3955910425f441d7038e0d6933b0aec5c4517f" +checksum = "28b94525fc99ba9e5c9a9e24764f2bc29bad0911a7446c12f446a8277369bf3a" dependencies = [ - "aho-corasick", - "memchr", - "regex-automata", - "regex-syntax", + "arrayvec", + "bit-vec", + "bitflags 2.6.0", + "cfg_aliases", + "codespan-reporting", + "indexmap", + "log", + "naga", + "once_cell", + "parking_lot", + "profiling", + "raw-window-handle 0.6.2", + "rustc-hash", + "smallvec", + "thiserror", + "web-sys", + "wgpu-hal", + "wgpu-types", ] [[package]] -name = "regex-automata" -version = "0.4.7" +name = "wgpu-hal" +version = "0.19.5" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "38caf58cc5ef2fed281f89292ef23f6365465ed9a41b7a7754eb4e26496c92df" +checksum = "bfabcfc55fd86611a855816326b2d54c3b2fd7972c27ce414291562650552703" dependencies = [ - "aho-corasick", - "memchr", - "regex-syntax", + "android_system_properties", + "arrayvec", + "ash", + "bit-set", + "bitflags 2.6.0", + "block", + "cfg_aliases", + "core-graphics-types", + "d3d12", + "glow 0.13.1", + "glutin_wgl_sys", + "gpu-alloc", + "gpu-allocator", + "gpu-descriptor", + "hassle-rs", + "js-sys", + "khronos-egl", + "libc", + "libloading 0.8.5", + "log", + "metal", + "naga", + "ndk-sys", + "objc", + "once_cell", + "parking_lot", + "profiling", + "range-alloc", + "raw-window-handle 0.6.2", + "renderdoc-sys", + "rustc-hash", + "smallvec", + "thiserror", + "wasm-bindgen", + "web-sys", + "wgpu-types", + "winapi", ] [[package]] -name = "regex-syntax" -version = "0.8.4" +name = "wgpu-types" +version = "0.19.2" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "7a66a03ae7c801facd77a29370b4faec201768915ac14a721ba36f20bc9c209b" +checksum = "b671ff9fb03f78b46ff176494ee1ebe7d603393f42664be55b64dc8d53969805" +dependencies = [ + "bitflags 2.6.0", + "js-sys", + "web-sys", +] [[package]] -name = "rustc-hash" +name = "which" +version = "4.4.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +dependencies = [ + "either", + "home", + "once_cell", + "rustix", +] + +[[package]] +name = "widestring" version = "1.1.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "08d43f7aa6b08d49f382cde6a7982047c3426db949b1424bc4b7ec9ae12c6ce2" +checksum = "7219d36b6eac893fa81e84ebe06485e7dcbb616177469b142df14f1f4deb1311" [[package]] -name = "rustix" -version = "0.38.34" +name = "winapi" +version = "0.3.9" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "70dc5ec042f7a43c4a73241207cecc9873a06d45debb38b329f8541d85c2730f" +checksum = "5c839a674fcd7a98952e593242ea400abe93992746761e38641405d28b00f419" dependencies = [ - "bitflags", - "errno", - "libc", - "linux-raw-sys", - "windows-sys", + "winapi-i686-pc-windows-gnu", + "winapi-x86_64-pc-windows-gnu", ] [[package]] -name = "shlex" -version = "1.3.0" +name = "winapi-i686-pc-windows-gnu" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "0fda2ff0d084019ba4d7c6f371c95d8fd75ce3524c3cb8fb653a3023f6323e64" +checksum = "ac3b87c63620426dd9b991e5ce0329eff545bccbbb34f3be09ff6fb6ab51b7b6" [[package]] -name = "syn" -version = "2.0.71" +name = "winapi-util" +version = "0.1.8" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "b146dcf730474b4bcd16c311627b31ede9ab149045db4d6088b3becaea046462" +checksum = "4d4cc384e1e73b93bafa6fb4f1df8c41695c8a91cf9c4c64358067d15a7b6c6b" dependencies = [ - "proc-macro2", - "quote", - "unicode-ident", + "windows-sys", ] [[package]] -name = "unicode-ident" -version = "1.0.12" +name = "winapi-x86_64-pc-windows-gnu" +version = "0.4.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "3354b9ac3fae1ff6755cb6db53683adb661634f67557942dea4facebec0fee4b" +checksum = "712e227841d057c1ee1cd2fb22fa7e5a5461ae8e48fa2ca79ec42cfc1931183f" [[package]] -name = "which" -version = "4.4.2" +name = "windows" +version = "0.52.0" source = "registry+https://github.com/rust-lang/crates.io-index" -checksum = "87ba24419a2078cd2b0f2ede2691b6c66d8e47836da3b6db8265ebad47afbfc7" +checksum = "e48a53791691ab099e5e2ad123536d0fff50652600abaf43bbf952894110d0be" dependencies = [ - "either", - "home", - "once_cell", - "rustix", + "windows-core", + "windows-targets", +] + +[[package]] +name = "windows-core" +version = "0.52.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "33ab640c8d7e35bf8ba19b884ba838ceb4fba93a4e8c65a9059d08afcfc683d9" +dependencies = [ + "windows-targets", ] [[package]] @@ -364,3 +1588,50 @@ name = "windows_x86_64_msvc" version = "0.52.6" source = "registry+https://github.com/rust-lang/crates.io-index" checksum = "589f6da84c646204747d1270a2a5661ea66ed1cced2631d546fdfb155959f9ec" + +[[package]] +name = "xml-rs" +version = "0.8.20" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "791978798f0597cfc70478424c2b4fdc2b7a8024aaff78497ef00f24ef674193" + +[[package]] +name = "zerocopy" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "854e949ac82d619ee9a14c66a1b674ac730422372ccb759ce0c39cabcf2bf8e6" +dependencies = [ + "byteorder", + "zerocopy-derive 0.6.6", +] + +[[package]] +name = "zerocopy" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "1b9b4fd18abc82b8136838da5d50bae7bdea537c574d8dc1a34ed098d6c166f0" +dependencies = [ + "zerocopy-derive 0.7.35", +] + +[[package]] +name = "zerocopy-derive" +version = "0.6.6" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "125139de3f6b9d625c39e2efdd73d41bdac468ccd556556440e322be0e1bbd91" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.71", +] + +[[package]] +name = "zerocopy-derive" +version = "0.7.35" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "fa4f8080344d4671fb4e831a13ad1e68092748387dfc4f55e356242fae12ce3e" +dependencies = [ + "proc-macro2", + "quote", + "syn 2.0.71", +] diff --git a/bindgen/rust/Cargo.toml b/bindgen/rust/Cargo.toml index 879e669..a523e3e 100644 --- a/bindgen/rust/Cargo.toml +++ b/bindgen/rust/Cargo.toml @@ -4,6 +4,11 @@ version = "0.1.0" edition = "2021" [dependencies] +egui = "0.26" +egui_overlay = {version = "0.8.1", default-features = false, features = ["three_d"] } +egui_render_three_d = "0.8.0" +egui_render_wgpu = "0.8.0" +egui_window_glfw_passthrough = "0.8.1" [build-dependencies] bindgen = "0.69.4" diff --git a/bindgen/rust/examples/gui_test.rs b/bindgen/rust/examples/gui_test.rs new file mode 100644 index 0000000..891b698 --- /dev/null +++ b/bindgen/rust/examples/gui_test.rs @@ -0,0 +1,135 @@ +#![windows_subsystem = "windows"] // to turn off console. + +use celeritas::{Frame_Begin, Frame_End}; +use egui::DragValue; +use egui_overlay::EguiOverlay; +use egui_render_three_d::ThreeDBackend; +use egui_render_wgpu::WgpuBackend; + +fn main() { + // use tracing_subscriber::{fmt, prelude::*, EnvFilter}; + // if RUST_LOG is not set, we will use the following filters + // tracing_subscriber::registry() + // .with(fmt::layer()) + // .with( + // EnvFilter::try_from_default_env() + // .unwrap_or(EnvFilter::new("debug,wgpu=warn,naga=warn")), + // ) + // .init(); + + celeritas::egui_utils::start(HelloWorld { frame: 0}); +} + +pub struct HelloWorld { + pub frame: u64, +} +impl EguiOverlay for HelloWorld { + fn gui_run( + &mut self, + egui_context: &egui::Context, + _default_gfx_backend: &mut ThreeDBackend, + glfw_backend: &mut egui_window_glfw_passthrough::GlfwBackend, + ) { + // unsafe { + // Frame_Begin(); + // Frame_End(); + // } + + // just some controls to show how you can use glfw_backend + egui::Window::new("controls").show(egui_context, |ui| { + ui.set_width(300.0); + self.frame += 1; + ui.label(format!("current frame number: {}", self.frame)); + // sometimes, you want to see the borders to understand where the overlay is. + let mut borders = glfw_backend.window.is_decorated(); + if ui.checkbox(&mut borders, "window borders").changed() { + glfw_backend.window.set_decorated(borders); + } + + ui.label(format!( + "pixels_per_virtual_unit: {}", + glfw_backend.physical_pixels_per_virtual_unit + )); + ui.label(format!("window scale: {}", glfw_backend.scale)); + ui.label(format!("cursor pos x: {}", glfw_backend.cursor_pos[0])); + ui.label(format!("cursor pos y: {}", glfw_backend.cursor_pos[1])); + + ui.label(format!( + "passthrough: {}", + glfw_backend.window.is_mouse_passthrough() + )); + // how to change size. + // WARNING: don't use drag value, because window size changing while dragging ui messes things up. + let mut size = glfw_backend.window_size_logical; + let mut changed = false; + ui.horizontal(|ui| { + ui.label("width: "); + ui.add_enabled(false, DragValue::new(&mut size[0])); + if ui.button("inc").clicked() { + size[0] += 10.0; + changed = true; + } + if ui.button("dec").clicked() { + size[0] -= 10.0; + changed = true; + } + }); + ui.horizontal(|ui| { + ui.label("height: "); + ui.add_enabled(false, DragValue::new(&mut size[1])); + if ui.button("inc").clicked() { + size[1] += 10.0; + changed = true; + } + if ui.button("dec").clicked() { + size[1] -= 10.0; + changed = true; + } + }); + if changed { + glfw_backend.set_window_size(size); + } + // how to change size. + // WARNING: don't use drag value, because window size changing while dragging ui messes things up. + let mut pos = glfw_backend.window_position; + let mut changed = false; + ui.horizontal(|ui| { + ui.label("x: "); + ui.add_enabled(false, DragValue::new(&mut pos[0])); + if ui.button("inc").clicked() { + pos[0] += 10; + changed = true; + } + if ui.button("dec").clicked() { + pos[0] -= 10; + changed = true; + } + }); + ui.horizontal(|ui| { + ui.label("y: "); + ui.add_enabled(false, DragValue::new(&mut pos[1])); + if ui.button("inc").clicked() { + pos[1] += 10; + changed = true; + } + if ui.button("dec").clicked() { + pos[1] -= 10; + changed = true; + } + }); + if changed { + glfw_backend.window.set_pos(pos[0], pos[1]); + } + }); + + // here you decide if you want to be passthrough or not. + if egui_context.wants_pointer_input() || egui_context.wants_keyboard_input() { + // we need input, so we need the window to be NOT passthrough + glfw_backend.set_passthrough(false); + } else { + // we don't care about input, so the window can be passthrough now + glfw_backend.set_passthrough(true) + } + egui_context.request_repaint(); + } +} \ No newline at end of file diff --git a/bindgen/rust/examples/main_loop.rs b/bindgen/rust/examples/main_loop.rs index 8da3e9a..4c54f8c 100644 --- a/bindgen/rust/examples/main_loop.rs +++ b/bindgen/rust/examples/main_loop.rs @@ -4,6 +4,9 @@ unsafe fn run_game() { // init Core_Bringup(); + let core = get_global_core(); + let glfw_window_ptr = Core_GetGlfwWindowPtr(core); + let camera_pos = Vec3 { x: 0.0, y: 2.0, @@ -30,13 +33,13 @@ unsafe fn run_game() { }; SetMainLight(sun); - let skybox = Skybox_Create(face_paths, 6); + // let skybox = Skybox_Create(face_paths, 6); // main loop while !ShouldExit() { Frame_Begin(); - Skybox_Draw(&mut skybox, camera); + // Skybox_Draw(&mut skybox, camera); Frame_End(); } diff --git a/bindgen/rust/src/egui_utils.rs b/bindgen/rust/src/egui_utils.rs new file mode 100644 index 0000000..b29e271 --- /dev/null +++ b/bindgen/rust/src/egui_utils.rs @@ -0,0 +1,72 @@ +use egui_overlay::{EguiOverlay, OverlayApp}; +use egui_render_three_d::ThreeDBackend; +use egui_window_glfw_passthrough::glfw::Context; +use egui_window_glfw_passthrough::{GlfwBackend, GlfwConfig}; + +use crate::Core_Bringup; + +// struct CustomEguiOverlay { +// backend: +// } + +fn init() { + let mut glfw_backend = GlfwBackend::new(GlfwConfig::default()); + let mut glfw_window_ptr = glfw_backend.window.window_ptr(); + + unsafe { + // Cast the window pointer to the expected type + let window_ptr = glfw_window_ptr as *mut crate::GLFWwindow; + Core_Bringup(window_ptr); + }; +} + +/// After implementing [`EguiOverlay`], just call this function with your app data +pub fn start(user_data: T) { + let mut glfw_backend = GlfwBackend::new(GlfwConfig { + // this closure will be called before creating a window + glfw_callback: Box::new(|gtx| { + // some defualt hints. it is empty atm, but in future we might add some convenience hints to it. + (egui_window_glfw_passthrough::GlfwConfig::default().glfw_callback)(gtx); + // scale the window size based on monitor scale. as 800x600 looks too small on a 4k screen, compared to a hd screen in absolute pixel sizes. + gtx.window_hint(egui_window_glfw_passthrough::glfw::WindowHint::ScaleToMonitor(true)); + }), + opengl_window: Some(true), // macos doesn't support opengl. + transparent_window: Some(false), + window_title: "Celeritas egui".into(), + ..Default::default() + }); + + // always on top + // glfw_backend.window.set_floating(true); + // disable borders/titlebar + // glfw_backend.window.set_decorated(false); + + let latest_size = glfw_backend.window.get_framebuffer_size(); + let latest_size = [latest_size.0 as _, latest_size.1 as _]; + + let default_gfx_backend = { + ThreeDBackend::new( + egui_render_three_d::ThreeDConfig { + ..Default::default() + }, + |s| glfw_backend.get_proc_address(s), + latest_size, + ) + }; + + let glfw_window_ptr = glfw_backend.window.window_ptr(); + unsafe { + // Cast the window pointer to the expected type + let window_ptr = glfw_window_ptr as *mut crate::GLFWwindow; + Core_Bringup(window_ptr); + }; + + let overlap_app = OverlayApp { + user_data, + egui_context: Default::default(), + default_gfx_backend, + glfw_backend, + }; + + overlap_app.enter_event_loop(); +} diff --git a/bindgen/rust/src/lib.rs b/bindgen/rust/src/lib.rs index a38a13a..6f110c0 100644 --- a/bindgen/rust/src/lib.rs +++ b/bindgen/rust/src/lib.rs @@ -3,3 +3,5 @@ #![allow(non_snake_case)] include!(concat!(env!("OUT_DIR"), "/bindings.rs")); + +pub mod egui_utils; diff --git a/examples/game_demo/game_demo.c b/examples/game_demo/game_demo.c index 9688808..73c22ae 100644 --- a/examples/game_demo/game_demo.c +++ b/examples/game_demo/game_demo.c @@ -24,7 +24,7 @@ static const char* faces[6] = { "assets/demo/skybox/right.jpg", "assets/demo/sky "assets/demo/skybox/front.jpg", "assets/demo/skybox/back.jpg" }; int main() { - Core_Bringup(); + Core_Bringup(NULL); // TODO: Load humanoid model + weapon // TODO: Animate it with WASD keys @@ -33,7 +33,7 @@ int main() { // TODO: Move camera with model // --- Render Scene - Vec3 camera_pos = vec3(0.0, 1.3, 3.0); + Vec3 camera_pos = vec3(0.0, 3.0, 3.0); Camera cam = Camera_Create(camera_pos, VEC3_NEG_Z, VEC3_Y, 45.0); SetCamera(cam); // update the camera in RenderScene diff --git a/src/core/core.c b/src/core/core.c index 38777ba..d508de8 100644 --- a/src/core/core.c +++ b/src/core/core.c @@ -20,7 +20,7 @@ Core g_core; /** @brief global `Core` that other files can use */ /** @brief Gets the global `Core` singleton */ inline Core* GetCore() { return &g_core; } -void Core_Bringup() { +void Core_Bringup(struct GLFWwindow* optional_window) { INFO("Initiate Core bringup"); memset(&g_core, 0, sizeof(Core)); @@ -31,10 +31,15 @@ void Core_Bringup() { g_core.renderer = malloc(Renderer_GetMemReqs()); // initialise all subsystems - if (!Renderer_Init(conf, g_core.renderer, &g_core.window)) { + // renderer config, renderer ptr, ptr to store a window, and optional preexisting glfw window + if (!Renderer_Init(conf, g_core.renderer, &g_core.window, optional_window)) { // FATAL("Failed to start renderer"); ERROR_EXIT("Failed to start renderer\n"); } + if (optional_window != NULL) { + g_core.window = optional_window; + } + if (!Input_Init(&g_core.input, g_core.window)) { // the input system needs the glfw window which is created by the renderer // hence the order here is important diff --git a/src/core/core.h b/src/core/core.h index ac07c50..17561f3 100644 --- a/src/core/core.h +++ b/src/core/core.h @@ -26,11 +26,16 @@ struct Renderer; Core* get_global_core(); -/** @brief Throws error if the core cannot be instantiated */ -void Core_Bringup(); +/** + @brief Throws error if the core cannot be instantiated + @param [in] optional_window - Leave NULL if you want Celeritas to instantiate its own window with GLFW, if you + want to provide the glfw window then pass it in here. +*/ +void Core_Bringup(GLFWwindow* optional_window); void Core_Shutdown(); bool ShouldExit(); +GLFWwindow* Core_GetGlfwWindowPtr(Core* core); struct Renderer* Core_GetRenderer(Core* core); void Frame_Begin(); diff --git a/src/new_render/render.c b/src/new_render/render.c index adf56b1..a5eae33 100644 --- a/src/new_render/render.c +++ b/src/new_render/render.c @@ -44,7 +44,7 @@ struct Renderer { Renderer* get_renderer() { return g_core.renderer; } -bool Renderer_Init(RendererConfig config, Renderer* ren, GLFWwindow** out_window) { +bool Renderer_Init(RendererConfig config, Renderer* ren, GLFWwindow** out_window, GLFWwindow* optional_window) { INFO("Renderer init"); ren->frame_arena = arena_create(malloc(FRAME_ARENA_SIZE), FRAME_ARENA_SIZE); @@ -56,33 +56,49 @@ bool Renderer_Init(RendererConfig config, Renderer* ren, GLFWwindow** out_window ResourcePools_Init(&pool_arena, ren->resource_pools); // GLFW window creation - - // NOTE: all platforms use GLFW at the moment but thats subject to change - glfwInit(); - -#if defined(CEL_REND_BACKEND_OPENGL) - glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); - glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); - glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); - glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); -#elif defined(CEL_REND_BACKEND_VULKAN) - glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); -#endif - - GLFWwindow* window = - glfwCreateWindow(config.scr_width, config.scr_height, config.window_name, NULL, NULL); - if (window == NULL) { - ERROR("Failed to create GLFW window\n"); - glfwTerminate(); - return false; + GLFWwindow* window; + if (optional_window != NULL) { + INFO("GLFWwindow pointer was provided!!!! Skipping generic glfw init.."); + window = optional_window; + } else { + // NOTE: all platforms use GLFW at the moment but thats subject to change + glfwInit(); + + #if defined(CEL_REND_BACKEND_OPENGL) + glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); + glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); + glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); + #elif defined(CEL_REND_BACKEND_VULKAN) + glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); + #endif + + GLFWwindow* window = + glfwCreateWindow(config.scr_width, config.scr_height, config.window_name, NULL, NULL); + if (window == NULL) { + ERROR("Failed to create GLFW window\n"); + glfwTerminate(); + return false; + } } + + // #if defined(CEL_REND_BACKEND_OPENGL) + // glfwWindowHint(GLFW_CONTEXT_VERSION_MAJOR, 4); + // glfwWindowHint(GLFW_CONTEXT_VERSION_MINOR, 1); + // glfwWindowHint(GLFW_OPENGL_PROFILE, GLFW_OPENGL_CORE_PROFILE); + // glfwWindowHint(GLFW_OPENGL_FORWARD_COMPAT, GL_TRUE); + // #elif defined(CEL_REND_BACKEND_VULKAN) + // glfwWindowHint(GLFW_CLIENT_API, GLFW_NO_API); + // #endif + ren->window = window; *out_window = window; glfwMakeContextCurrent(ren->window); - DEBUG("Set up GLFW window callbacks"); - glfwSetWindowSizeCallback(window, Render_WindowSizeChanged); + // FIXME + // DEBUG("Set up GLFW window callbacks"); + // glfwSetWindowSizeCallback(window, Render_WindowSizeChanged); // set the RAL backend up if (!GPU_Backend_Init(config.window_name, window, ren->resource_pools)) { diff --git a/src/new_render/render.h b/src/new_render/render.h index 233c934..1f80290 100644 --- a/src/new_render/render.h +++ b/src/new_render/render.h @@ -28,7 +28,7 @@ typedef struct RenderCtx { // --- Lifecycle -PUB bool Renderer_Init(RendererConfig config, Renderer* renderer, GLFWwindow** out_window); +PUB bool Renderer_Init(RendererConfig config, Renderer* renderer, GLFWwindow** out_window, GLFWwindow* optional_window); PUB void Renderer_Shutdown(Renderer* renderer); PUB size_t Renderer_GetMemReqs(); void Render_WindowSizeChanged(GLFWwindow* window, i32 new_width, i32 new_height); diff --git a/src/systems/terrain.c b/src/systems/terrain.c index c19ba33..3743a9b 100644 --- a/src/systems/terrain.c +++ b/src/systems/terrain.c @@ -8,6 +8,7 @@ #include "log.h" #include "maths.h" #include "mem.h" +#include "ral_common.h" #include "ral_impl.h" #include "ral_types.h" #include "render.h" @@ -27,10 +28,6 @@ bool Terrain_Init(Terrain_Storage* storage) { }; storage->hmap_renderpass = GPU_Renderpass_Create(rpass_desc); - VertexDescription builder = { .debug_label = "pos only" }; - VertexDesc_AddAttr(&builder, "inPosition", ATTR_F32x3); - builder.use_full_vertex_size = true; - arena scratch = arena_create(malloc(1024 * 1024), 1024 * 1024); Str8 vert_path = str8("assets/shaders/terrain.vert"); @@ -42,12 +39,13 @@ bool Terrain_Init(Terrain_Storage* storage) { } ShaderData camera_data = { .get_layout = &Binding_Camera_GetLayout }; + ShaderData terrain_data = { .get_layout = &TerrainUniforms_GetLayout}; GraphicsPipelineDesc pipeline_desc = { .debug_name = "terrain rendering pipeline", - .vertex_desc = builder, - .data_layouts = { camera_data }, - .data_layouts_count = 1, + .vertex_desc = static_3d_vertex_description(), + .data_layouts = { camera_data, terrain_data }, + .data_layouts_count = 2, .vs = { .debug_name = "terrain vertex shader", .filepath = vert_path, @@ -58,10 +56,12 @@ bool Terrain_Init(Terrain_Storage* storage) { .filepath = frag_path, .code = fragment_shader.contents, }, - .wireframe = true, + .wireframe = false, }; storage->hmap_pipeline = GPU_GraphicsPipeline_Create(pipeline_desc, storage->hmap_renderpass); + storage->texture = TextureLoadFromFile("assets/demo/textures/grass2.png"); + return true; } @@ -94,7 +94,11 @@ void Terrain_LoadHeightmap(Terrain_Storage* storage, Heightmap hmap, f32 grid_sc assert(index < num_vertices); f32 height = Heightmap_HeightXZ(&hmap, i, j); - Vertex v = { .pos_only.position = vec3_create(i * grid_scale, height, j * grid_scale) }; + Vec3 v_pos = vec3_create(i * grid_scale, height, j * grid_scale); + Vec3 v_normal = VEC3_Y; + float tiling_factor = 505.0f; + Vec2 v_uv = vec2((f32)i / width * tiling_factor , (f32)j / height * tiling_factor); + Vertex v = { .static_3d = {.position = v_pos, .normal = v_normal, .tex_coords = v_uv} }; Vertex_darray_push(vertices, v); index++; } @@ -165,6 +169,13 @@ void Terrain_Draw(Terrain_Storage* storage) { GPU_EncodeBindShaderData( enc, 0, (ShaderData){ .data = &camera_data, .get_layout = &Binding_Camera_GetLayout }); + TerrainUniforms uniforms = { + .tex_slot_1 = storage->texture + }; + ShaderData terrain_data = { .data = &uniforms, .get_layout = &TerrainUniforms_GetLayout}; + GPU_EncodeBindShaderData(enc, 1, terrain_data); + + GPU_EncodeSetVertexBuffer(enc, storage->vertex_buffer); GPU_EncodeSetIndexBuffer(enc, storage->index_buffer); @@ -179,4 +190,20 @@ f32 Heightmap_HeightXZ(const Heightmap* hmap, u32 x, u32 z) { u8 channel = bytes[position]; float value = (float)channel / 2.0; /// 255.0; return value; +} + +ShaderDataLayout TerrainUniforms_GetLayout(void* data) { + TerrainUniforms* d = data; + bool has_data = data != NULL; + + ShaderBinding b1 = { + .label = "TextureSlot1", + .kind = BINDING_TEXTURE, + .vis = VISIBILITY_FRAGMENT, + }; + + if (has_data) { + b1.data.texture.handle = d->tex_slot_1; + } + return (ShaderDataLayout){ .bindings = { b1 }, .binding_count = 1 }; } \ No newline at end of file diff --git a/src/systems/terrain.h b/src/systems/terrain.h index 2e05a14..664aa8e 100644 --- a/src/systems/terrain.h +++ b/src/systems/terrain.h @@ -35,6 +35,7 @@ typedef struct Heightmap { Heightmap heightmap; // NULL = no heightmap GPU_Renderpass* hmap_renderpass; GPU_Pipeline* hmap_pipeline; + TextureHandle texture; bool hmap_loaded; BufferHandle vertex_buffer; @@ -69,4 +70,8 @@ Vec3 Heightmap_NormalXZ(const Heightmap* hmap, f32 x, f32 z); // /** @brief Generate the `geometry_data` for a heightmap ready to be uploaded to the GPU */ // Geometry geo_heightmap(arena* a, Heightmap heightmap); +typedef struct TerrainUniforms { + TextureHandle tex_slot_1; +} TerrainUniforms; + ShaderDataLayout TerrainUniforms_GetLayout(void* data); \ No newline at end of file -- cgit v1.2.3-70-g09d2